From 21f5c7ac1be9e54f85d3911511080fcac57f5e49 Mon Sep 17 00:00:00 2001 From: malimova Date: Fri, 6 Oct 2023 23:57:59 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D1=82=D0=B5=D0=B3=D0=B8=D0=B8=20MoveToBorder?= =?UTF-8?q?=20+=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=BE=D0=B1=D0=BE=D0=B8=D1=85=20=D0=BE=D0=B1=D1=8A=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirBomber.cs | 2 +- AirBomber/AirBomber/DrawningAirPlane.cs | 4 ++-- AirBomber/AirBomber/FormAirBomber.cs | 2 +- AirBomber/AirBomber/MoveToBorder.cs | 27 ++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 AirBomber/AirBomber/MoveToBorder.cs diff --git a/AirBomber/AirBomber/DrawningAirBomber.cs b/AirBomber/AirBomber/DrawningAirBomber.cs index acb1c5c..b8eabe9 100644 --- a/AirBomber/AirBomber/DrawningAirBomber.cs +++ b/AirBomber/AirBomber/DrawningAirBomber.cs @@ -24,7 +24,7 @@ namespace AirBomber public DrawningAirBomber(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, Color bombsColor, bool fuelTanks, int width, int height) : - base(speed, weight, bodyColor, width, height, 110, 60) + base(speed, weight, bodyColor, width, height, 160, 118) { if (EntityAirPlane != null) { diff --git a/AirBomber/AirBomber/DrawningAirPlane.cs b/AirBomber/AirBomber/DrawningAirPlane.cs index 18f23d8..64dce49 100644 --- a/AirBomber/AirBomber/DrawningAirPlane.cs +++ b/AirBomber/AirBomber/DrawningAirPlane.cs @@ -32,11 +32,11 @@ namespace AirBomber /// /// Ширина прорисовки самолета /// - protected readonly int _airPlaneWidth = 100; + protected readonly int _airPlaneWidth = 150; /// /// Высота прорисовки самолета /// - protected readonly int _airPlaneHeight = 55; + protected readonly int _airPlaneHeight = 118; /// /// Конструктор /// diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index 785941a..45f158b 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -81,7 +81,7 @@ switch { 0 => new MoveToCenter(), - //1 => new MoveToBorder(), + 1 => new MoveToBorder(), _ => null, }; if (_abstractStrategy == null) diff --git a/AirBomber/AirBomber/MoveToBorder.cs b/AirBomber/AirBomber/MoveToBorder.cs new file mode 100644 index 0000000..435ab8d --- /dev/null +++ b/AirBomber/AirBomber/MoveToBorder.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + public class MoveToBorder : AbstractStrategy + { + protected override bool IsTargetDestinaion() + { + var objParams = GetObjectParameters; + if (objParams == null) return false; + + return objParams.RightBorder >= FieldWidth - GetStep() && objParams.DownBorder >= FieldHeight - GetStep(); + } + + protected override void MoveToTarget() + { + var objParams = GetObjectParameters; + if (objParams == null) return; + if (objParams.RightBorder < FieldWidth - GetStep()) MoveRight(); + + } + } +}