From a22e2833b2b80a2349d704dd12bf10a43907a667 Mon Sep 17 00:00:00 2001 From: ilyaryabovv Date: Mon, 19 Feb 2024 14:07:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D0=B2=D1=91=D0=BB=20=D0=BA=D1=80?= =?UTF-8?q?=D0=B0=D1=81=D0=BE=D1=82=D1=83,=20=D1=83=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=BF=D1=83=D1=81=D1=82=D1=8B=D0=B5=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectStormtrooper/Drawnings/DrawingStormtrooper.cs | 3 --- .../Drawnings/DrawningBaseStormtrooper.cs | 3 --- .../ProjectStormtrooper/FormStormtrooper.cs | 8 -------- .../MovementStrategy/AbstractStrategy.cs | 5 ----- .../ProjectStormtrooper/MovementStrategy/MoveToBorder.cs | 6 +++--- .../ProjectStormtrooper/MovementStrategy/MoveToCenter.cs | 3 +-- .../MovementStrategy/MovementDirection.cs | 3 +-- .../MovementStrategy/StrategyStatus.cs | 3 +-- 8 files changed, 6 insertions(+), 28 deletions(-) diff --git a/ProjectStormtrooper/ProjectStormtrooper/Drawnings/DrawingStormtrooper.cs b/ProjectStormtrooper/ProjectStormtrooper/Drawnings/DrawingStormtrooper.cs index edd944e..d8c1982 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/Drawnings/DrawingStormtrooper.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/Drawnings/DrawingStormtrooper.cs @@ -19,9 +19,6 @@ public class DrawingStormtrooper : DrawningBaseStormtrooper { EntityBaseStormtrooper = new EntityStormtrooper(speed, weight, bodyColor, additionalColor, bombs, rockets); } - - - /// /// Прорисовка объекта /// diff --git a/ProjectStormtrooper/ProjectStormtrooper/Drawnings/DrawningBaseStormtrooper.cs b/ProjectStormtrooper/ProjectStormtrooper/Drawnings/DrawningBaseStormtrooper.cs index 5aaf5b3..c6d6575 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/Drawnings/DrawningBaseStormtrooper.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/Drawnings/DrawningBaseStormtrooper.cs @@ -1,5 +1,4 @@ using ProjectStormtrooper.Entities; - namespace ProjectStormtrooper.Drawnings; public class DrawningBaseStormtrooper @@ -222,7 +221,6 @@ public class DrawningBaseStormtrooper } Pen pen = new(Color.Black); Brush bodyColorBrush = new SolidBrush(EntityBaseStormtrooper.BodyColor); - //Тело бомбардировщика g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 60, 120, 20); //Задние крылья бомбардировщика @@ -244,7 +242,6 @@ public class DrawningBaseStormtrooper Nose[1].X = _startPosX.Value; Nose[1].Y = _startPosY.Value + 70; Nose[2].X = _startPosX.Value + 20; Nose[2].Y = _startPosY.Value + 60; g.FillPolygon(bodyColorBrush, Nose); - } } diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooper.cs b/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooper.cs index d138b22..c1bda8f 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooper.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooper.cs @@ -14,7 +14,6 @@ namespace ProjectStormtrooper private DrawningBaseStormtrooper? _drawningBaseStormtrooper; private AbstractStrategy? _strategy; - /// /// Конструктор формы /// @@ -23,8 +22,6 @@ namespace ProjectStormtrooper InitializeComponent(); _strategy = null; } - - /// /// Метод прорисовки бомбардировщика /// @@ -40,7 +37,6 @@ namespace ProjectStormtrooper _drawningBaseStormtrooper.DrawTransport(gr); pictureBoxStormtrooper.Image = bmp; } - /// /// Создание объекта класса-перемещения /// @@ -63,7 +59,6 @@ namespace ProjectStormtrooper default: return; } - _drawningBaseStormtrooper.SetPictureSize(pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height); _drawningBaseStormtrooper.SetPosition(random.Next(10, 100), random.Next(10, 100)); _strategy = null; @@ -84,7 +79,6 @@ namespace ProjectStormtrooper { CreateObject(nameof(DrawningBaseStormtrooper)); } - /// /// Перемещение объекта по форме (нажатие кнопок навигации) /// @@ -92,7 +86,6 @@ namespace ProjectStormtrooper /// private void ButtonMove_Click(object sender, EventArgs e) { - if (_drawningBaseStormtrooper == null) { return; @@ -162,5 +155,4 @@ namespace ProjectStormtrooper } } } - } diff --git a/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/AbstractStrategy.cs b/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/AbstractStrategy.cs index 04507a6..cba80d2 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/AbstractStrategy.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/AbstractStrategy.cs @@ -1,6 +1,5 @@ namespace ProjectStormtrooper.MovementStrategy; - /// /// Класс-стратегия перемещения объекта /// @@ -44,7 +43,6 @@ public abstract class AbstractStrategy _state = StrategyStatus.NotInit; return; } - _state = StrategyStatus.InProgress; _moveableObject = moveableObject; FieldWidth = width; @@ -60,13 +58,11 @@ public abstract class AbstractStrategy { return; } - if (IsTargetDestinaion()) { _state = StrategyStatus.Finish; return; } - MoveToTarget(); } @@ -134,7 +130,6 @@ public abstract class AbstractStrategy { return false; } - return _moveableObject?.TryMoveObject(movementDirection) ?? false; } } \ No newline at end of file diff --git a/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MoveToBorder.cs b/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MoveToBorder.cs index d13a51d..0e18375 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MoveToBorder.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MoveToBorder.cs @@ -1,5 +1,7 @@ namespace ProjectStormtrooper.MovementStrategy; - +/// +/// Стратегия перемещения объекта в правый нижний угол +/// public class MoveToBorder : AbstractStrategy { protected override bool IsTargetDestinaion() @@ -14,7 +16,6 @@ public class MoveToBorder : AbstractStrategy objParams.TopBorder - GetStep() <= 0 || objParams.ObjectMiddleVertical + GetStep() >= FieldHeight; } - protected override void MoveToTarget() { ObjectParameters? objParams = GetObjectParameters; @@ -22,7 +23,6 @@ public class MoveToBorder : AbstractStrategy { return; } - //реализация в правый нижний угол int x = objParams.RightBorder; if (x + GetStep() < FieldWidth) MoveRight(); int y = objParams.DownBorder; diff --git a/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MoveToCenter.cs b/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MoveToCenter.cs index 8d996b6..5c06695 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MoveToCenter.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MoveToCenter.cs @@ -15,7 +15,6 @@ public class MoveToCenter : AbstractStrategy return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2; } - protected override void MoveToTarget() { ObjectParameters? objParams = GetObjectParameters; @@ -36,7 +35,7 @@ public class MoveToCenter : AbstractStrategy MoveRight(); } } - + int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2; if (Math.Abs(diffY) > GetStep()) { diff --git a/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MovementDirection.cs b/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MovementDirection.cs index 2124b25..ca78f1d 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MovementDirection.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/MovementDirection.cs @@ -1,5 +1,4 @@ - -namespace ProjectStormtrooper.MovementStrategy; +namespace ProjectStormtrooper.MovementStrategy; /// /// Направление перемещения /// diff --git a/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/StrategyStatus.cs b/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/StrategyStatus.cs index 725fb1d..f4464ec 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/StrategyStatus.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/MovementStrategy/StrategyStatus.cs @@ -1,5 +1,4 @@ - -namespace ProjectStormtrooper.MovementStrategy; +namespace ProjectStormtrooper.MovementStrategy; public enum StrategyStatus {