From 95864521f36de851d7b2c1431cedd589cf0bb6a0 Mon Sep 17 00:00:00 2001 From: "ityurner02@mail.ru" Date: Sun, 18 Sep 2022 14:39:26 +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 --- .../AntiAircraftGun/DrawingAntiAircraftGun.cs | 7 ++++ .../DrawingObjectAntiAircraftGun.cs | 35 ++++++++++++++++ .../AntiAircraftGun/IDrawingObject.cs | 42 +++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 AntiAircraftGun/AntiAircraftGun/DrawingObjectAntiAircraftGun.cs create mode 100644 AntiAircraftGun/AntiAircraftGun/IDrawingObject.cs diff --git a/AntiAircraftGun/AntiAircraftGun/DrawingAntiAircraftGun.cs b/AntiAircraftGun/AntiAircraftGun/DrawingAntiAircraftGun.cs index 71380eb..a1a9e67 100644 --- a/AntiAircraftGun/AntiAircraftGun/DrawingAntiAircraftGun.cs +++ b/AntiAircraftGun/AntiAircraftGun/DrawingAntiAircraftGun.cs @@ -185,5 +185,12 @@ namespace AntiAircraftGun _startPosY = _pictureHeight.Value - _antiAircrafGunHeight; } } + /// + /// Получение текущей позиции объекта + /// + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosY, _startPosX + _antiAircrafGunWidth, _startPosY + _antiAircrafGunHeight); + } } } diff --git a/AntiAircraftGun/AntiAircraftGun/DrawingObjectAntiAircraftGun.cs b/AntiAircraftGun/AntiAircraftGun/DrawingObjectAntiAircraftGun.cs new file mode 100644 index 0000000..6f82639 --- /dev/null +++ b/AntiAircraftGun/AntiAircraftGun/DrawingObjectAntiAircraftGun.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AntiAircraftGun +{ + internal class DrawingObjectAntiAircraftGun : IDrawingObject + { + private DrawingAntiAircraftGun _antiAircraftGun = null; + public DrawingObjectAntiAircraftGun(DrawingAntiAircraftGun antiAircraftGun) + { + _antiAircraftGun = antiAircraftGun; + } + public float Step => _antiAircraftGun?.AntiAircraftGun?.Step ?? 0; + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _antiAircraftGun?.GetCurrentPosition() ?? default; + } + public void MoveObject(Direction direction) + { + _antiAircraftGun?.MoveTransport(direction); + } + public void SetObject(int x, int y, int width, int height) + { + _antiAircraftGun.SetPosition(x, y, width, height); + } + + void IDrawingObject.DrawingObjectAntiAircraftGun(Graphics g) + { + _antiAircraftGun?.DrawTransport(g); + } + } +} diff --git a/AntiAircraftGun/AntiAircraftGun/IDrawingObject.cs b/AntiAircraftGun/AntiAircraftGun/IDrawingObject.cs new file mode 100644 index 0000000..ee0ad14 --- /dev/null +++ b/AntiAircraftGun/AntiAircraftGun/IDrawingObject.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AntiAircraftGun +{ + /// + /// Интерфейс для работы с объектом, прорисовываемом на форме + /// + internal interface IDrawingObject + { + /// + /// Шаг перемещения объекта + /// + public float Step { get; } + /// + /// Установка позиции объекта + /// + /// Координата X + /// Координата Y + /// Ширина полотна + /// Высота полотна + void SetObject(int x, int y, int width, int height); + /// + /// Изменение направления пермещения объекта + /// + /// Направление + void MoveObject(Direction direction); + /// + /// Отрисовка объекта + /// + /// + void DrawingObjectAntiAircraftGun(Graphics g); + /// + /// Получение текущей позиции объекта + /// + /// + (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + } +}