From 7a919fc4d0a4a92c70f4a3185e43c86ba465471d Mon Sep 17 00:00:00 2001 From: Danil Kargin Date: Wed, 5 Oct 2022 23:19:25 +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 --- AirFighter/AirFighter/DrawningAirFighter.cs | 8 ++++ .../AirFighter/DrawningObjectAirFighter.cs | 38 ++++++++++++++++ AirFighter/AirFighter/IDrawningObject.cs | 44 +++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 AirFighter/AirFighter/DrawningObjectAirFighter.cs create mode 100644 AirFighter/AirFighter/IDrawningObject.cs diff --git a/AirFighter/AirFighter/DrawningAirFighter.cs b/AirFighter/AirFighter/DrawningAirFighter.cs index f42f2e4..12f3ab9 100644 --- a/AirFighter/AirFighter/DrawningAirFighter.cs +++ b/AirFighter/AirFighter/DrawningAirFighter.cs @@ -188,5 +188,13 @@ namespace AirFighter _startPosY = _pictureHeight.Value - _airFighterHeight; } } + /// + /// Получение текущей позиции объекта + /// + /// + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosX + _airFighterWidth, _startPosY, _startPosY + _airFighterHeight); + } } } diff --git a/AirFighter/AirFighter/DrawningObjectAirFighter.cs b/AirFighter/AirFighter/DrawningObjectAirFighter.cs new file mode 100644 index 0000000..3e5f997 --- /dev/null +++ b/AirFighter/AirFighter/DrawningObjectAirFighter.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirFighter +{ + internal class DrawningObjectAirFighter : IDrawningObject + { + private DrawningAirFighter _airFighter = null; + public float Step => _airFighter?.AirFighter.Step ?? 0; + public DrawningObjectAirFighter(DrawningAirFighter airFighter) + { + _airFighter = airFighter; + } + + void IDrawningObject.DrawningObject(Graphics g) + { + _airFighter.DrawAirFighter(g); + } + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _airFighter?.GetCurrentPosition() ?? default; + } + + public void MoveObject(Direction direction) + { + _airFighter?.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _airFighter?.SetPosition(x, y, width, height); + } + } +} diff --git a/AirFighter/AirFighter/IDrawningObject.cs b/AirFighter/AirFighter/IDrawningObject.cs new file mode 100644 index 0000000..8f8230b --- /dev/null +++ b/AirFighter/AirFighter/IDrawningObject.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirFighter +{ + /// + /// Интерфейс для работы с объектом, прорисовываемым на форме + /// + internal interface IDrawningObject + { + /// + /// Шаг перемещения объекта + /// + 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(); + + } +}