From 37572c6e3c316a98985b9f633fc1268621d5083d Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Sun, 8 Oct 2023 00:16:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tank/Tank/DrawArmoVehicle.cs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Tank/Tank/DrawArmoVehicle.cs b/Tank/Tank/DrawArmoVehicle.cs index 9996ee2..be5947b 100644 --- a/Tank/Tank/DrawArmoVehicle.cs +++ b/Tank/Tank/DrawArmoVehicle.cs @@ -22,20 +22,6 @@ namespace Tank public int GetWidth => _Width; public int GetHeight => _Height; - public bool CanMove(Direction direction) - { - if (Tank == null) - return false; - return direction switch - { - Direction.Left => _startPosX - Tank.Step > 0, - Direction.Up => _startPosY - Tank.Step > 0, - Direction.Right => _startPosX + _Width + Tank.Step < _pictureWidth, - Direction.Down => _startPosY + _Height + Tank.Step < _pictureHeight, - _ => false - - }; - } // Конструктор класса public DrawArmoVehicle(int speed, double weight, Color bodyColor, int width, int height) { @@ -57,6 +43,21 @@ namespace Tank Tank = new EntityBase(speed, weight, bodyColor); } + public bool CanMove(Direction direction) + { + if (Tank == null) + return false; + return direction switch + { + Direction.Left => _startPosX - Tank.Step > 0, + Direction.Up => _startPosY - Tank.Step > 0, + Direction.Right => _startPosX + _Width + Tank.Step < _pictureWidth, + Direction.Down => _startPosY + _Height + Tank.Step < _pictureHeight, + _ => false + + }; + } + public void SetPosition(int x, int y) { _startPosX = x;