From fecbbfd46911cce19608bc2f8c60388dc3227603 Mon Sep 17 00:00:00 2001 From: ksenianeva <95441235+ksenianeva@users.noreply.github.com> Date: Tue, 4 Oct 2022 00:57:48 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5?= =?UTF-8?q?=D0=B9=D1=81=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContainerShip/DrawingObjectShip.cs | 40 +++++++++++++++++++ ContainerShip/ContainerShip/DrawingShip.cs | 9 +++++ ContainerShip/ContainerShip/IDrawingObject.cs | 40 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 ContainerShip/ContainerShip/DrawingObjectShip.cs create mode 100644 ContainerShip/ContainerShip/IDrawingObject.cs 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(); + } +}