From 8c4a09a8b517a97c557b5dafb2672824e39cd510 Mon Sep 17 00:00:00 2001 From: ikswi Date: Mon, 1 Apr 2024 00:59:32 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=8B=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2?= =?UTF-8?q?=20=D0=B8=D0=BC=D0=B5=D0=BD=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 16 ++--- .../CollectionGenericObjects/Angar.cs | 2 +- .../Drawnings/DrawningAirFighter.cs | 12 ++-- ...ngPlane.cs => DrawningMilitaryAircraft.cs} | 60 +++++++++---------- .../AirFighter/Entities/EntityAirFighter.cs | 2 +- ...tityPlane.cs => EntityMilitaryAircraft.cs} | 6 +- .../AirFighter/FormAirCollection.Designer.cs | 2 +- AirFighter/AirFighter/FormAirCollection.cs | 24 ++++---- AirFighter/AirFighter/FormAirCollection.resx | 2 +- AirFighter/AirFighter/FormAirFighter.cs | 26 ++++---- AirFighter/AirFighter/FormAirFighter.resx | 2 +- .../MovementStrategy/MoveToBorder.cs | 6 +- .../MovementStrategy/MoveToCenter.cs | 6 +- ...ableAir.cs => MoveableMilitaryAircraft.cs} | 24 ++++---- .../AirFighter/Properties/Resources.resx | 2 +- 15 files changed, 98 insertions(+), 94 deletions(-) rename AirFighter/AirFighter/Drawnings/{DrawningPlane.cs => DrawningMilitaryAircraft.cs} (71%) rename AirFighter/AirFighter/Entities/{EntityPlane.cs => EntityMilitaryAircraft.cs} (77%) rename AirFighter/AirFighter/MovementStrategy/{MoveableAir.cs => MoveableMilitaryAircraft.cs} (52%) diff --git a/AirFighter/AirFighter/CollectionGenericObjects/AbstractCompany.cs b/AirFighter/AirFighter/CollectionGenericObjects/AbstractCompany.cs index 8b7128a..2fce08a 100644 --- a/AirFighter/AirFighter/CollectionGenericObjects/AbstractCompany.cs +++ b/AirFighter/AirFighter/CollectionGenericObjects/AbstractCompany.cs @@ -30,7 +30,7 @@ public abstract class AbstractCompany /// /// Коллекция автомобилей /// - protected ICollectionGenericObjects? _collection = null; + protected ICollectionGenericObjects? _collection = null; /// /// Вычисление максимального количества элементов, который можно разместить в окне @@ -43,7 +43,7 @@ public abstract class AbstractCompany /// Ширина окна /// Высота окна /// Коллекция автомобилей - public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection) + public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection) { _pictureWidth = picWidth; _pictureHeight = picHeight; @@ -55,11 +55,11 @@ public abstract class AbstractCompany /// Перегрузка оператора сложения для класса /// /// Компания - /// Добавляемый объект + /// Добавляемый объект /// - public static int operator +(AbstractCompany company, DrawningPlane plane) + public static int operator +(AbstractCompany company, DrawningMilitaryAircraft militaryAircraft) { - return company._collection.Insert(plane); + return company._collection.Insert(militaryAircraft); } /// @@ -68,7 +68,7 @@ public abstract class AbstractCompany /// Компания /// Номер удаляемого объекта /// - public static DrawningPlane operator -(AbstractCompany company, int position) + public static DrawningMilitaryAircraft operator -(AbstractCompany company, int position) { return company._collection.Remove(position); } @@ -77,7 +77,7 @@ public abstract class AbstractCompany /// Получение случайного объекта из коллекции /// /// - public DrawningPlane? GetRandomObject() + public DrawningMilitaryAircraft? GetRandomObject() { Random rnd = new(); return _collection?.Get(rnd.Next(GetMaxCount)); @@ -96,7 +96,7 @@ public abstract class AbstractCompany SetObjectsPosition(); for (int i = 0; i < (_collection?.Count ?? 0); ++i) { - DrawningPlane? obj = _collection?.Get(i); + DrawningMilitaryAircraft? obj = _collection?.Get(i); obj?.DrawTransport(graphics); } diff --git a/AirFighter/AirFighter/CollectionGenericObjects/Angar.cs b/AirFighter/AirFighter/CollectionGenericObjects/Angar.cs index 0f8af18..39ea8e8 100644 --- a/AirFighter/AirFighter/CollectionGenericObjects/Angar.cs +++ b/AirFighter/AirFighter/CollectionGenericObjects/Angar.cs @@ -13,7 +13,7 @@ public class Angar : AbstractCompany /// /// /// - public Angar(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) + public Angar(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) { } diff --git a/AirFighter/AirFighter/Drawnings/DrawningAirFighter.cs b/AirFighter/AirFighter/Drawnings/DrawningAirFighter.cs index cdc7933..7dab3a2 100644 --- a/AirFighter/AirFighter/Drawnings/DrawningAirFighter.cs +++ b/AirFighter/AirFighter/Drawnings/DrawningAirFighter.cs @@ -5,7 +5,7 @@ namespace ProjectAirFighter.Drawnings; /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности /// -public class DrawningAirFighter : DrawningPlane +public class DrawningAirFighter : DrawningMilitaryAircraft { /// @@ -19,22 +19,22 @@ public class DrawningAirFighter : DrawningPlane /// Признак наличия ракет public DrawningAirFighter (int speed, double weight, Color bodyColor, Color additionalColor, bool wings, bool rockets) : base (70, 70) { - EntityPlane = new EntityAirFighter(speed, weight, bodyColor, additionalColor, wings, rockets); + EntityMilitaryAircraft = new EntityAirFighter(speed, weight, bodyColor, additionalColor, wings, rockets); } public override void DrawTransport(Graphics g) { - if (EntityPlane == null || EntityPlane is not EntityAirFighter planeFighter || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityMilitaryAircraft == null || EntityMilitaryAircraft is not EntityAirFighter militaryAircraftFighter || !_startPosX.HasValue || !_startPosY.HasValue) { return; } Pen pen = new(Color.Black); - Brush additionalBrush = new SolidBrush(planeFighter.AdditionalColor); + Brush additionalBrush = new SolidBrush(militaryAircraftFighter.AdditionalColor); base.DrawTransport(g); - if (planeFighter.Wings) + if (militaryAircraftFighter.Wings) { Point wings1 = new Point(_startPosX.Value + 45, _startPosY.Value + 30); Point wings2 = new Point(_startPosX.Value + 45, _startPosY.Value + 15); @@ -53,7 +53,7 @@ public class DrawningAirFighter : DrawningPlane g.DrawPolygon(pen, DownWing); } - if (planeFighter.Rockets) + if (militaryAircraftFighter.Rockets) { Point rocket1 = new Point(_startPosX.Value + 40, _startPosY.Value + 5); Point rocket2 = new Point(_startPosX.Value + 15, _startPosY.Value + 5); diff --git a/AirFighter/AirFighter/Drawnings/DrawningPlane.cs b/AirFighter/AirFighter/Drawnings/DrawningMilitaryAircraft.cs similarity index 71% rename from AirFighter/AirFighter/Drawnings/DrawningPlane.cs rename to AirFighter/AirFighter/Drawnings/DrawningMilitaryAircraft.cs index e4e632c..03123c8 100644 --- a/AirFighter/AirFighter/Drawnings/DrawningPlane.cs +++ b/AirFighter/AirFighter/Drawnings/DrawningMilitaryAircraft.cs @@ -5,12 +5,12 @@ namespace ProjectAirFighter.Drawnings; /// /// Класс, отвечающий за прорисовку и перемещение базового объекта-сущности /// -public class DrawningPlane +public class DrawningMilitaryAircraft { /// /// Класс-сущность /// - public EntityPlane? EntityPlane { get; protected set; } + public EntityMilitaryAircraft? EntityMilitaryAircraft { get; protected set; } /// /// Ширина окна @@ -35,12 +35,12 @@ public class DrawningPlane /// /// Ширина прорисовки самолёта /// - private readonly int _drawningFighterWidth = 70; + private readonly int _drawningMilitaryAircraftWidth = 70; /// /// Высота прорисовки самолёта /// - private readonly int _drawningFighterHeight = 70; + private readonly int _drawningMilitaryAircraftHeight = 70; /// /// Координата X объекта @@ -55,17 +55,17 @@ public class DrawningPlane /// /// Ширина объекта /// - public int GetWidth => _drawningFighterWidth; + public int GetWidth => _drawningMilitaryAircraftWidth; /// /// Высота объекта /// - public int GetHeight => _drawningFighterHeight; + public int GetHeight => _drawningMilitaryAircraftHeight; /// /// Пустой конструктор /// - private DrawningPlane() + private DrawningMilitaryAircraft() { _pictureWidth = null; _pictureHeight = null; @@ -79,25 +79,25 @@ public class DrawningPlane /// Скорость /// Вес /// Основной цвет - public DrawningPlane (int speed, double weight, Color bodyColor) : this() + public DrawningMilitaryAircraft (int speed, double weight, Color bodyColor) : this() { - EntityPlane = new EntityPlane(speed, weight, bodyColor); + EntityMilitaryAircraft = new EntityMilitaryAircraft(speed, weight, bodyColor); } /// /// Конструктор для наследников /// - /// Ширина прорисовки самолёта - /// Высота прорисовки самолёта - protected DrawningPlane(int drawningFighterWidth, int drawningFighterHeight) : this() + /// Ширина прорисовки самолёта + /// Высота прорисовки самолёта + protected DrawningMilitaryAircraft(int drawningMilitaryAircraftWidth, int drawningMilitaryAircraftHeight) : this() { - _drawningFighterWidth = drawningFighterWidth; - _drawningFighterHeight = drawningFighterHeight; + _drawningMilitaryAircraftWidth = drawningMilitaryAircraftWidth; + _drawningMilitaryAircraftHeight = drawningMilitaryAircraftHeight; } public bool SetPictureSize(int width, int height) { - if (_drawningFighterWidth < width && _drawningFighterHeight < height) + if (_drawningMilitaryAircraftWidth < width && _drawningMilitaryAircraftHeight < height) { _pictureWidth = width; _pictureHeight = height; @@ -118,9 +118,9 @@ public class DrawningPlane return; } - if (x + _drawningFighterWidth > _pictureWidth) + if (x + _drawningMilitaryAircraftWidth > _pictureWidth) { - _startPosX = _pictureWidth - _drawningFighterWidth; + _startPosX = _pictureWidth - _drawningMilitaryAircraftWidth; } else if (x < 0) { @@ -130,9 +130,9 @@ public class DrawningPlane { _startPosX = x; } - if (y + _drawningFighterHeight > _pictureHeight) + if (y + _drawningMilitaryAircraftHeight > _pictureHeight) { - _startPosY = _pictureHeight - _drawningFighterHeight; + _startPosY = _pictureHeight - _drawningMilitaryAircraftHeight; } else if (y < 0) { @@ -146,7 +146,7 @@ public class DrawningPlane public bool MoveTransport(DirectionType direction) { - if (EntityPlane == null || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityMilitaryAircraft == null || !_startPosX.HasValue || !_startPosY.HasValue) { return false; } @@ -154,27 +154,27 @@ public class DrawningPlane switch (direction) { case DirectionType.Left: - if (_startPosX.Value - EntityPlane.Step > 0) + if (_startPosX.Value - EntityMilitaryAircraft.Step > 0) { - _startPosX -= (int)EntityPlane.Step; + _startPosX -= (int)EntityMilitaryAircraft.Step; } return true; case DirectionType.Up: - if (_startPosY.Value - EntityPlane.Step > 0) + if (_startPosY.Value - EntityMilitaryAircraft.Step > 0) { - _startPosY -= (int)EntityPlane.Step; + _startPosY -= (int)EntityMilitaryAircraft.Step; } return true; case DirectionType.Right: - if (_startPosX.Value + _drawningFighterWidth + EntityPlane.Step < _pictureWidth) + if (_startPosX.Value + _drawningMilitaryAircraftWidth + EntityMilitaryAircraft.Step < _pictureWidth) { - _startPosX += (int)EntityPlane.Step; + _startPosX += (int)EntityMilitaryAircraft.Step; } return true; case DirectionType.Down: - if (_startPosY.Value + _drawningFighterHeight + EntityPlane.Step < _pictureHeight) + if (_startPosY.Value + _drawningMilitaryAircraftHeight + EntityMilitaryAircraft.Step < _pictureHeight) { - _startPosY += (int)EntityPlane.Step; + _startPosY += (int)EntityMilitaryAircraft.Step; } return true; default: @@ -184,13 +184,13 @@ public class DrawningPlane public virtual void DrawTransport(Graphics g) { - if (EntityPlane == null || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityMilitaryAircraft == null || !_startPosX.HasValue || !_startPosY.HasValue) { return; } Pen pen = new(Color.Black); - Brush br = new SolidBrush(EntityPlane.BodyColor); + Brush br = new SolidBrush(EntityMilitaryAircraft.BodyColor); g.FillRectangle(br, _startPosX.Value + 10, _startPosY.Value + 30, 60, 10); g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 30, 60, 10); diff --git a/AirFighter/AirFighter/Entities/EntityAirFighter.cs b/AirFighter/AirFighter/Entities/EntityAirFighter.cs index 4e6c8b3..c42b4fb 100644 --- a/AirFighter/AirFighter/Entities/EntityAirFighter.cs +++ b/AirFighter/AirFighter/Entities/EntityAirFighter.cs @@ -3,7 +3,7 @@ /// /// Класс-сущность "Истребитель" /// -public class EntityAirFighter : EntityPlane +public class EntityAirFighter : EntityMilitaryAircraft { public Color AdditionalColor { get; private set; } diff --git a/AirFighter/AirFighter/Entities/EntityPlane.cs b/AirFighter/AirFighter/Entities/EntityMilitaryAircraft.cs similarity index 77% rename from AirFighter/AirFighter/Entities/EntityPlane.cs rename to AirFighter/AirFighter/Entities/EntityMilitaryAircraft.cs index df8a889..4ecd8ab 100644 --- a/AirFighter/AirFighter/Entities/EntityPlane.cs +++ b/AirFighter/AirFighter/Entities/EntityMilitaryAircraft.cs @@ -1,9 +1,9 @@ namespace ProjectAirFighter.Entities; /// -/// Класс-сущность "Истребитель" +/// Класс-сущность "Военный самолёт" /// -public class EntityPlane +public class EntityMilitaryAircraft { public int Speed { get; private set; } @@ -20,7 +20,7 @@ public class EntityPlane /// Вес автомобиля /// Основной цвет - public EntityPlane (int speed, double weight, Color bodyColor) + public EntityMilitaryAircraft (int speed, double weight, Color bodyColor) { Speed = speed; Weight = weight; diff --git a/AirFighter/AirFighter/FormAirCollection.Designer.cs b/AirFighter/AirFighter/FormAirCollection.Designer.cs index 144c845..0efeb4f 100644 --- a/AirFighter/AirFighter/FormAirCollection.Designer.cs +++ b/AirFighter/AirFighter/FormAirCollection.Designer.cs @@ -127,7 +127,7 @@ comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSelectorCompany.FormattingEnabled = true; - comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); + comboBoxSelectorCompany.Items.AddRange(new object[] { "Ангар" }); comboBoxSelectorCompany.Location = new Point(6, 26); comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Size = new Size(194, 28); diff --git a/AirFighter/AirFighter/FormAirCollection.cs b/AirFighter/AirFighter/FormAirCollection.cs index 8b0b217..25df9aa 100644 --- a/AirFighter/AirFighter/FormAirCollection.cs +++ b/AirFighter/AirFighter/FormAirCollection.cs @@ -28,7 +28,7 @@ public partial class FormAirCollection : Form switch (comboBoxSelectorCompany.Text) { case "Хранилище": - _company = new Angar(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); + _company = new Angar(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); break; } } @@ -38,7 +38,7 @@ public partial class FormAirCollection : Form /// /// /// - private void buttonAddAir_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlane)); + private void buttonAddAir_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningMilitaryAircraft)); /// /// Добавление истребителя @@ -55,14 +55,14 @@ public partial class FormAirCollection : Form } Random random = new(); - DrawningPlane drawningFighter; + DrawningMilitaryAircraft drawningMilitaryAircraft; switch (type) { - case nameof(DrawningPlane): - drawningFighter = new DrawningPlane(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); + case nameof(DrawningMilitaryAircraft): + drawningMilitaryAircraft = new DrawningMilitaryAircraft(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); break; case nameof(DrawningAirFighter): - drawningFighter = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000), + drawningMilitaryAircraft = new DrawningAirFighter(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), GetColor(random), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); break; @@ -70,7 +70,7 @@ public partial class FormAirCollection : Form return; } - if (_company + drawningFighter != -1) + if (_company + drawningMilitaryAircraft != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show(); @@ -140,11 +140,11 @@ public partial class FormAirCollection : Form return; } - DrawningPlane? plane = null; + DrawningMilitaryAircraft? militaryAircraft = null; int counter = 100; - while (plane == null) + while (militaryAircraft == null) { - plane = _company.GetRandomObject(); + militaryAircraft = _company.GetRandomObject(); counter--; if (counter <= 0) { @@ -152,14 +152,14 @@ public partial class FormAirCollection : Form } } - if (plane == null) + if (militaryAircraft == null) { return; } FormAirFighter form = new() { - SetAir = plane + SetAir = militaryAircraft }; form.ShowDialog(); } diff --git a/AirFighter/AirFighter/FormAirCollection.resx b/AirFighter/AirFighter/FormAirCollection.resx index 39e9e6f..af32865 100644 --- a/AirFighter/AirFighter/FormAirCollection.resx +++ b/AirFighter/AirFighter/FormAirCollection.resx @@ -28,7 +28,7 @@ There are any number of "resheader" rows that contain simple - name/value pplanes. + name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support diff --git a/AirFighter/AirFighter/FormAirFighter.cs b/AirFighter/AirFighter/FormAirFighter.cs index eeb7a06..c6a3be9 100644 --- a/AirFighter/AirFighter/FormAirFighter.cs +++ b/AirFighter/AirFighter/FormAirFighter.cs @@ -5,7 +5,7 @@ namespace ProjectAirFighter; public partial class FormAirFighter : Form { - private DrawningPlane? _drawningFighter; + private DrawningMilitaryAircraft? _drawningMilitaryAircraft; private AbstractStrategy? _strategy; @@ -15,12 +15,12 @@ public partial class FormAirFighter : Form _strategy = null; } - public DrawningPlane SetAir + public DrawningMilitaryAircraft SetAir { set { - _drawningFighter = value; - _drawningFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); + _drawningMilitaryAircraft = value; + _drawningMilitaryAircraft.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); comboBoxStrategy.Enabled = true; _strategy = null; Draw(); @@ -29,20 +29,20 @@ public partial class FormAirFighter : Form private void Draw() { - if (_drawningFighter == null) + if (_drawningMilitaryAircraft == null) { return; } Bitmap bmp = new(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); Graphics gr = Graphics.FromImage(bmp); - _drawningFighter.DrawTransport(gr); + _drawningMilitaryAircraft.DrawTransport(gr); pictureBoxAirFighter.Image = bmp; } private void ButtonMove_Click(object sender, EventArgs e) { - if (_drawningFighter == null) + if (_drawningMilitaryAircraft == null) { return; } @@ -52,16 +52,16 @@ public partial class FormAirFighter : Form switch (name) { case "buttonUp": - result = _drawningFighter.MoveTransport(DirectionType.Up); + result = _drawningMilitaryAircraft.MoveTransport(DirectionType.Up); break; case "buttonDown": - result = _drawningFighter.MoveTransport(DirectionType.Down); + result = _drawningMilitaryAircraft.MoveTransport(DirectionType.Down); break; case "buttonLeft": - result = _drawningFighter.MoveTransport(DirectionType.Left); + result = _drawningMilitaryAircraft.MoveTransport(DirectionType.Left); break; case "buttonRight": - result = _drawningFighter.MoveTransport(DirectionType.Right); + result = _drawningMilitaryAircraft.MoveTransport(DirectionType.Right); break; } @@ -73,7 +73,7 @@ public partial class FormAirFighter : Form private void ButtonStrategyStep_Click(object sender, EventArgs e) { - if (_drawningFighter == null) + if (_drawningMilitaryAircraft == null) { return; } @@ -90,7 +90,7 @@ public partial class FormAirFighter : Form { return; } - _strategy.SetData(new MoveableAir(_drawningFighter), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); + _strategy.SetData(new MoveableMilitaryAircraft(_drawningMilitaryAircraft), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height); } if (_strategy == null) diff --git a/AirFighter/AirFighter/FormAirFighter.resx b/AirFighter/AirFighter/FormAirFighter.resx index 39e9e6f..b5123c1 100644 --- a/AirFighter/AirFighter/FormAirFighter.resx +++ b/AirFighter/AirFighter/FormAirFighter.resx @@ -28,7 +28,7 @@ There are any number of "resheader" rows that contain simple - name/value pplanes. + name/value pmilitaryAircrafts. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support diff --git a/AirFighter/AirFighter/MovementStrategy/MoveToBorder.cs b/AirFighter/AirFighter/MovementStrategy/MoveToBorder.cs index 6fd964a..a92cd93 100644 --- a/AirFighter/AirFighter/MovementStrategy/MoveToBorder.cs +++ b/AirFighter/AirFighter/MovementStrategy/MoveToBorder.cs @@ -10,8 +10,10 @@ public class MoveToBorder : AbstractStrategy return false; } - return objParams.RightBorder <= FieldWidth && objParams.RightBorder + GetStep() >= FieldWidth && - objParams.DownBorder <= FieldHeight && objParams.DownBorder + GetStep() >= FieldHeight; + return objParams.RightBorder <= FieldWidth && + objParams.RightBorder + GetStep() >= FieldWidth && + objParams.DownBorder <= FieldHeight && + objParams.DownBorder + GetStep() >= FieldHeight; } protected override void MoveToTarget() diff --git a/AirFighter/AirFighter/MovementStrategy/MoveToCenter.cs b/AirFighter/AirFighter/MovementStrategy/MoveToCenter.cs index b7dd88e..ed3f1fc 100644 --- a/AirFighter/AirFighter/MovementStrategy/MoveToCenter.cs +++ b/AirFighter/AirFighter/MovementStrategy/MoveToCenter.cs @@ -13,8 +13,10 @@ public class MoveToCenter : AbstractStrategy return false; } - return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && - objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2; + 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() diff --git a/AirFighter/AirFighter/MovementStrategy/MoveableAir.cs b/AirFighter/AirFighter/MovementStrategy/MoveableMilitaryAircraft.cs similarity index 52% rename from AirFighter/AirFighter/MovementStrategy/MoveableAir.cs rename to AirFighter/AirFighter/MovementStrategy/MoveableMilitaryAircraft.cs index 3238dcd..c019b02 100644 --- a/AirFighter/AirFighter/MovementStrategy/MoveableAir.cs +++ b/AirFighter/AirFighter/MovementStrategy/MoveableMilitaryAircraft.cs @@ -3,46 +3,46 @@ namespace ProjectAirFighter.MovementStrategy; /// -/// Класс-реализация IMoveableObject с использованием DrawningCar +/// Класс-реализация IMoveableObject с использованием DrawningMilitaryAircraft /// -public class MoveableAir : IMoveableObject +public class MoveableMilitaryAircraft : IMoveableObject { /// - /// Поле-объект класса DrawningCar или его наследника + /// Поле-объект класса DrawningMilitaryAircraft или его наследника /// - private readonly DrawningPlane? _plane = null; + private readonly DrawningMilitaryAircraft? _militaryAircraft = null; /// /// Конструктор /// - /// Объект класса DrawningCar - public MoveableAir(DrawningPlane plane) + /// Объект класса DrawningMilitaryAircraft + public MoveableMilitaryAircraft(DrawningMilitaryAircraft militaryAircraft) { - _plane = plane; + _militaryAircraft = militaryAircraft; } public ObjectParameters? GetObjectPosition { get { - if (_plane == null || _plane.EntityPlane == null || !_plane.GetPosX.HasValue || !_plane.GetPosY.HasValue) + if (_militaryAircraft == null || _militaryAircraft.EntityMilitaryAircraft == null || !_militaryAircraft.GetPosX.HasValue || !_militaryAircraft.GetPosY.HasValue) { return null; } - return new ObjectParameters(_plane.GetPosX.Value, _plane.GetPosY.Value, _plane.GetWidth, _plane.GetHeight); + return new ObjectParameters(_militaryAircraft.GetPosX.Value, _militaryAircraft.GetPosY.Value, _militaryAircraft.GetWidth, _militaryAircraft.GetHeight); } } - public int GetStep => (int)(_plane?.EntityPlane?.Step ?? 0); + public int GetStep => (int)(_militaryAircraft?.EntityMilitaryAircraft?.Step ?? 0); public bool TryMoveObject(MovementDirection direction) { - if (_plane == null || _plane.EntityPlane == null) + if (_militaryAircraft == null || _militaryAircraft.EntityMilitaryAircraft == null) { return false; } - return _plane.MoveTransport(GetDirectionType(direction)); + return _militaryAircraft.MoveTransport(GetDirectionType(direction)); } /// diff --git a/AirFighter/AirFighter/Properties/Resources.resx b/AirFighter/AirFighter/Properties/Resources.resx index 07a09cc..5f05973 100644 --- a/AirFighter/AirFighter/Properties/Resources.resx +++ b/AirFighter/AirFighter/Properties/Resources.resx @@ -28,7 +28,7 @@ There are any number of "resheader" rows that contain simple - name/value pplanes. + name/value pmilitaryAircrafts. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support