From 27127e27fa150e154c55e9fc861caa3443bb4adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=A7=D0=B5=D1=80?= =?UTF-8?q?=D0=BD=D1=8B=D1=88=D0=BE=D0=B2?= Date: Sat, 8 Oct 2022 16:34:56 +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 --- Warship/Warship/DrawingObjectWarship.cs | 34 +++++++++++++++++++ Warship/Warship/DrawingWarship.cs | 9 ++++++ Warship/Warship/IDrawingObject.cs | 43 +++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 Warship/Warship/DrawingObjectWarship.cs create mode 100644 Warship/Warship/IDrawingObject.cs 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(); + } +}