From 43563881626f4fb1cbcb463ab21090f3e23840b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Tue, 4 Oct 2022 21:57:28 +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/DrawningObjectShip.cs | 40 +++++++++++++++++++++ WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs | 5 +++ WarmlyShip/WarmlyShip/IDrawningObject.cs | 17 +++++++++ 3 files changed, 62 insertions(+) create mode 100644 WarmlyShip/WarmlyShip/DrawningObjectShip.cs create mode 100644 WarmlyShip/WarmlyShip/IDrawningObject.cs diff --git a/WarmlyShip/WarmlyShip/DrawningObjectShip.cs b/WarmlyShip/WarmlyShip/DrawningObjectShip.cs new file mode 100644 index 0000000..eaecf5e --- /dev/null +++ b/WarmlyShip/WarmlyShip/DrawningObjectShip.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 DrawningObjectShip : IDrawningObject + { + private DrawningWarmlyShip _warmlyShip = null; + + public DrawningObjectShip(DrawningWarmlyShip warmlyShip) + { + _warmlyShip = warmlyShip; + } + + public float Step => _warmlyShip?.warmlyShip?.Step ?? 0; + + public void DrawningObject(Graphics g) + { + _warmlyShip?.DrawTransport(g); + } + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _warmlyShip?.GetCurrentPosition() ?? default; + } + + public void MoveObject(Direction direction) + { + _warmlyShip?.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _warmlyShip?.SetPosition(x, y, width, height); + } + } +} diff --git a/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs b/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs index 74f0c7b..d6624ae 100644 --- a/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/DrawningWarmlyShip.cs @@ -114,5 +114,10 @@ namespace WarmlyShip } } + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosY, _startPosX + _warmlyShipWidth, _startPosY + _warmlyShipHeight); + } } } diff --git a/WarmlyShip/WarmlyShip/IDrawningObject.cs b/WarmlyShip/WarmlyShip/IDrawningObject.cs new file mode 100644 index 0000000..a732b2c --- /dev/null +++ b/WarmlyShip/WarmlyShip/IDrawningObject.cs @@ -0,0 +1,17 @@ +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; } + 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(); + } +}