From 6789fca1cb29b86774238097c42ec2e0f6a4a674 Mon Sep 17 00:00:00 2001 From: AnnZhimol Date: Tue, 20 Sep 2022 22:10:16 +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 | 39 +++++++++++++++++++++++++ Warship/Warship/DrawingWarship.cs | 4 +++ Warship/Warship/IDrawingObject.cs | 17 +++++++++++ 3 files changed, 60 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..875e142 --- /dev/null +++ b/Warship/Warship/DrawingObjectWarship.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Warship +{ + internal class DrawingObjectWarship : IDrawingObject + { + private DrawingWarship _warship=null; + + public DrawingObjectWarship(DrawingWarship warship) + { + _warship= warship; + } + public float Step => _warship?.Warship?.Step ?? 0; + + void IDrawingObject.DrawingObject(Graphics g) + { + _warship.DrawTransport(g); + } + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _warship?.GetCurrentPosition() ?? default; + } + + public void MoveObject(Direction direction) + { + _warship?.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _warship.SetPosition(x,y,width,height); + } + } +} diff --git a/Warship/Warship/DrawingWarship.cs b/Warship/Warship/DrawingWarship.cs index 0f7cf91..30f4f44 100644 --- a/Warship/Warship/DrawingWarship.cs +++ b/Warship/Warship/DrawingWarship.cs @@ -140,5 +140,9 @@ namespace Warship _startPosY = _pictureHeight.Value - _warshipHeight; } } + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosY, _startPosX + _warshipWidth, _startPosY + _warshipHeight); + } } } diff --git a/Warship/Warship/IDrawingObject.cs b/Warship/Warship/IDrawingObject.cs new file mode 100644 index 0000000..3aa306a --- /dev/null +++ b/Warship/Warship/IDrawingObject.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Warship +{ + internal interface IDrawingObject + { + public float Step { get; } + void SetObject(int x, int y, int width, int height); + void MoveObject(Direction direction); + void DrawingObject(Graphics g); + (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + } +}