diff --git a/ContainerShip/ContainerShip/DrawingObjectShip.cs b/ContainerShip/ContainerShip/DrawingObjectShip.cs new file mode 100644 index 0000000..ad486ff --- /dev/null +++ b/ContainerShip/ContainerShip/DrawingObjectShip.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ContainerShip +{ + internal class DrawingObjectShip : IDrawingObject + { + private DrawingShip _ship = null; + + public DrawingObjectShip(DrawingShip 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); + } + + void IDrawingObject.DrawingObject(Graphics g) + { + //TODO + } + } +} diff --git a/ContainerShip/ContainerShip/DrawingShip.cs b/ContainerShip/ContainerShip/DrawingShip.cs index e11497c..49b7aa4 100644 --- a/ContainerShip/ContainerShip/DrawingShip.cs +++ b/ContainerShip/ContainerShip/DrawingShip.cs @@ -155,5 +155,14 @@ namespace ContainerShip _startPosY = _pictureHeight.Value - _shipHeight; } } + + /// + /// Получение текущей позиции объекта + /// + /// + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosY, _startPosX + _shipWidth, _startPosY + _shipHeight); + } } } diff --git a/ContainerShip/ContainerShip/IDrawingObject.cs b/ContainerShip/ContainerShip/IDrawingObject.cs new file mode 100644 index 0000000..9cc5652 --- /dev/null +++ b/ContainerShip/ContainerShip/IDrawingObject.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ContainerShip +{ + internal interface IDrawingObject + { + /// + /// Шаг перемещения объекта + /// + public float Step { get; } + /// + /// Установка позиции объекта + /// + /// Координата X + /// Координата Y + /// Ширина полотна + /// Высота полотна + void SetObject(int x, int y, int width, int height); + /// + /// Изменение направления пермещения объекта + /// + /// Направление + /// + void MoveObject(Direction direction); + /// + /// Отрисовка объекта + /// + /// + void DrawingObject(Graphics g); + /// + /// Получение текущей позиции объекта + /// + /// + (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + } +}