Interface "IdrawningObject" added

This commit is contained in:
Valitov.Damir 2023-03-18 02:49:20 +04:00
parent d5a0b336e8
commit 58de90de09
4 changed files with 90 additions and 1 deletions

View File

@ -166,5 +166,13 @@ namespace Sailboat
_startPosY = _pictureHeight.Value - _boatHeight;
}
}
/// <summary>
/// Получение текущей позиции объекта
/// </summary>
/// <returns></returns>
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return (_startPosX, _startPosY, _startPosX + _boatWidth, _startPosY + _boatHeight);
}
}
}

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sailboat
{
class DrawingObjectBoat : IDrawingObject
{
private DrawingBoat _boat;
public DrawingObjectBoat(DrawingBoat boat)
{
_boat = boat;
}
public float Step => _boat?.Boat?.Step ?? 0;
public void DrawingObject(Graphics g)
{
_boat.DrawTransport(g);
}
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
throw new NotImplementedException();
}
void IDrawingObject.MoveObject(Direction direction)
{
_boat?.MoveTransport(direction);
}
public void SetObject(int x, int y, int width, int height)
{
_boat.SetPosition(x, y, width, height);
}
}
}

View File

@ -21,7 +21,7 @@ namespace Sailboat
/// <param name="sail">Признак наличия паруса</param>
/// <param name="extendedBody">Признак наличия усиленного корпуса</param>
public DrawingSailboat(int speed, float weight, Color bodyColor, bool sail, bool extendedBody) :
base(speed, weight, bodyColor, 50, 120)
base(speed, weight, bodyColor, 80, 135)
{
Boat = new Sailboat(speed, weight, bodyColor, sail, extendedBody);
}

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sailboat
{
interface IDrawingObject
{
/// <summary>
/// Шаг перемещения объекта
/// </summary>
public float Step { get; }
/// <summary>
/// Установка позиции объекта
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
/// <param name="width">Ширина полотна</param>
/// <param name="height">Высота полотна</param>
void SetObject(int x, int y, int width, int height);
/// <summary>
/// Изменение направления пермещения объекта
/// </summary>
/// <param name="direction">Направление</param>
/// <returns></returns>
void MoveObject(Direction direction);
/// <summary>
/// Отрисовка объекта
/// </summary>
/// <param name="g"></param>
void DrawingObject(Graphics g);
/// <summary>
/// Получение текущей позиции объекта
/// </summary>
/// <returns></returns>
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
}
}