From f97ced21c75e3b5f430b0d690c00b01a2b0ca854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=82=D1=8F=20=D0=98=D1=85=D0=BE=D0=BD=D0=BA?= =?UTF-8?q?=D0=B8=D0=BD=D0=B0?= Date: Sun, 2 Oct 2022 19:42:09 +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 --- MotorBoat/MotorBoat/DrawningBoat.cs | 6 +++- MotorBoat/MotorBoat/DrawningObjectBoat.cs | 40 +++++++++++++++++++++++ MotorBoat/MotorBoat/IDrawningObject.cs | 40 +++++++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 MotorBoat/MotorBoat/DrawningObjectBoat.cs create mode 100644 MotorBoat/MotorBoat/IDrawningObject.cs diff --git a/MotorBoat/MotorBoat/DrawningBoat.cs b/MotorBoat/MotorBoat/DrawningBoat.cs index 03db994..1b834bf 100644 --- a/MotorBoat/MotorBoat/DrawningBoat.cs +++ b/MotorBoat/MotorBoat/DrawningBoat.cs @@ -40,7 +40,7 @@ namespace MotorBoat if (_startPosY - _boatHeight < 0) { _startPosY = _boatHeight + 10; } if (_startPosY + _boatHeight > _pictureHeight) { _startPosY -= _boatHeight; } } - public void MoveBoats(Direction direction) + public void MoveTransport(Direction direction) { if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) { @@ -124,5 +124,9 @@ namespace MotorBoat _startPosY = _pictureHeight.Value - _boatHeight; } } + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return (_startPosX, _startPosY, _startPosX + _boatWidth, _startPosY + _boatHeight); + } } } diff --git a/MotorBoat/MotorBoat/DrawningObjectBoat.cs b/MotorBoat/MotorBoat/DrawningObjectBoat.cs new file mode 100644 index 0000000..e5d43bc --- /dev/null +++ b/MotorBoat/MotorBoat/DrawningObjectBoat.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorBoat +{ + internal class DrawningObjectBoat : IDrawningObject + { + private DrawningBoat _boat = null; + + public DrawningObjectBoat(DrawningBoat boat) + { + _boat = boat; + } + + public float Step => _boat?.Boat?.Step ?? 0; + + public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() + { + return _boat?.GetCurrentPosition() ?? default; + } + + public void MoveObject(Direction direction) + { + _boat?.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _boat.SetPosition(x, y, width, height); + } + + void IDrawningObject.DrawningObject(Graphics g) + { + // TODO + } + } +} diff --git a/MotorBoat/MotorBoat/IDrawningObject.cs b/MotorBoat/MotorBoat/IDrawningObject.cs new file mode 100644 index 0000000..68c9958 --- /dev/null +++ b/MotorBoat/MotorBoat/IDrawningObject.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MotorBoat +{ + 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(); + } +} \ No newline at end of file