diff --git a/Warship/Warship/DrawingObjectWarship.cs b/Warship/Warship/DrawingObjectWarship.cs new file mode 100644 index 0000000..439f636 --- /dev/null +++ b/Warship/Warship/DrawingObjectWarship.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AircraftCarrier +{ + internal class DrawingObjectWarship : IDrawingObject + { + private DrawingWarship _ship = null; + public DrawingObjectWarship(DrawingWarship ship) + { + _ship = ship; + } + public float Step => _ship?.Ship?.Step ?? 0; + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _ship?.GetCurrentPosition() ?? default; + } + public void MoveObject(Direction direction) + { + _ship?.MoveTransport(direction); + } + public void SetObject(int x, int y, int width, int height) + { + _ship.SetPosition(x, y, width, height); + } + public void DrawningObject(Graphics g) + { + // TODO + } + } +} diff --git a/Warship/Warship/DrawingWarship.cs b/Warship/Warship/DrawingWarship.cs index b5406a1..ca377a2 100644 --- a/Warship/Warship/DrawingWarship.cs +++ b/Warship/Warship/DrawingWarship.cs @@ -185,6 +185,15 @@ namespace AircraftCarrier _startPosY = _pictureHeight.Value - _shipHeight; } } + /// + /// Получение текущей позиции объекта + /// + /// + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosY, _startPosX + _shipWidth, _startPosY + + _shipHeight); + } } } diff --git a/Warship/Warship/IDrawingObject.cs b/Warship/Warship/IDrawingObject.cs new file mode 100644 index 0000000..284bbbb --- /dev/null +++ b/Warship/Warship/IDrawingObject.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AircraftCarrier +{ + /// + /// Интерфейс для работы с объектом, прорисовываемым на форме + /// + internal interface IDrawingObject + { + /// + /// Шаг перемещения объекта + /// + public float Step { get; } + /// + /// Установка позиции объекта + /// + /// Координата X + /// Координата Y + /// Ширина полотна + /// Высота полотна + void SetObject(int x, int y, int width, int height); + /// + /// Изменение направления пермещения объекта + /// + /// Направление + void MoveObject(Direction direction); + /// + /// Отрисовка объекта + /// + /// + void DrawningObject(Graphics g); + /// + /// Получение текущей позиции объекта + /// + /// + (float Left, float Right, float Top, float Bottom) + GetCurrentPosition(); + } +}