From 066f232018875d6b70d40c749345db9678d91dd6 Mon Sep 17 00:00:00 2001 From: just1valery Date: Tue, 27 Sep 2022 13:19:40 +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 --- WarmlyShip/WarmlyShip/DrawningShip.cs | 8 +++++ WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs | 4 +-- WarmlyShip/WarmlyShip/DrwaningObjectShip.cs | 40 +++++++++++++++++++++ WarmlyShip/WarmlyShip/IDrawningObject.cs | 40 +++++++++++++++++++++ 4 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 WarmlyShip/WarmlyShip/DrwaningObjectShip.cs create mode 100644 WarmlyShip/WarmlyShip/IDrawningObject.cs diff --git a/WarmlyShip/WarmlyShip/DrawningShip.cs b/WarmlyShip/WarmlyShip/DrawningShip.cs index 6fb6d1b..851afa4 100644 --- a/WarmlyShip/WarmlyShip/DrawningShip.cs +++ b/WarmlyShip/WarmlyShip/DrawningShip.cs @@ -184,5 +184,13 @@ _startPosY = _pictureHeight.Value - _shipHeight; } } + /// + /// Получение текущей позиции объекта + /// + /// + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosY, _startPosX + _carWidth, _startPosY + _carHeight); + } } } diff --git a/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs index 3a10285..873a682 100644 --- a/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs @@ -18,7 +18,7 @@ namespace WarmlyShip /// Признак наличия труб /// Признак наличия топливного отсека public DrawningWarmlyShip(int speed, float weight, Color bodyColor, Color dopColor, bool pipes, bool fuelCompartment) : - base(speed, weight, bodyColor, 175, 65) + base(speed, weight, bodyColor, 170, 95) { Ship = new EntityWarmlyShip(speed, weight, bodyColor, dopColor, pipes, fuelCompartment); } @@ -43,10 +43,8 @@ namespace WarmlyShip } - //_startPosX += 10; _startPosY += 30; base.DrawTransport(g); - //_startPosX -= 10; _startPosY -= 30; if (warmlyShip.FuelCompartment) diff --git a/WarmlyShip/WarmlyShip/DrwaningObjectShip.cs b/WarmlyShip/WarmlyShip/DrwaningObjectShip.cs new file mode 100644 index 0000000..d27cfd9 --- /dev/null +++ b/WarmlyShip/WarmlyShip/DrwaningObjectShip.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WarmlyShip +{ + internal class DrwaningObjectShip : IDrawningObject + { + private DrawningShip _ship = null; + + public DrwaningObjectShip(DrawningShip 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 IDrawningObject.DrawningObject(Graphics g) + { + _ship.DrawTransport(g); + } + } +} diff --git a/WarmlyShip/WarmlyShip/IDrawningObject.cs b/WarmlyShip/WarmlyShip/IDrawningObject.cs new file mode 100644 index 0000000..86c4476 --- /dev/null +++ b/WarmlyShip/WarmlyShip/IDrawningObject.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WarmlyShip +{ + 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(); + } +}