diff --git a/Project1/Project1.sln b/Project1/Project1.sln
deleted file mode 100644
index 449dbc7..0000000
--- a/Project1/Project1.sln
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.8.34525.116
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project1", "Project1\Project1.vcxproj", "{AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Debug|x64.ActiveCfg = Debug|x64
- {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Debug|x64.Build.0 = Debug|x64
- {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Debug|x86.ActiveCfg = Debug|Win32
- {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Debug|x86.Build.0 = Debug|Win32
- {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Release|x64.ActiveCfg = Release|x64
- {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Release|x64.Build.0 = Release|x64
- {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Release|x86.ActiveCfg = Release|Win32
- {AB7EA6C4-E58F-4C10-A6D7-63D958F07D30}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {CFB832FC-6360-4FE9-9C85-0C6C32CF4B4F}
- EndGlobalSection
-EndGlobal
diff --git a/Project1/Project1/Project1.vcxproj b/Project1/Project1/Project1.vcxproj
deleted file mode 100644
index e154bc4..0000000
--- a/Project1/Project1/Project1.vcxproj
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 17.0
- Win32Proj
- {ab7ea6c4-e58f-4c10-a6d7-63d958f07d30}
- Project1
- 10.0
-
-
-
- Application
- true
- v143
- Unicode
-
-
- Application
- false
- v143
- true
- Unicode
-
-
- Application
- true
- v143
- Unicode
-
-
- Application
- false
- v143
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Level3
- true
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
- true
- true
-
-
-
-
- Level3
- true
- _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
- true
- true
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Project1/Project1/Project1.vcxproj.filters b/Project1/Project1/Project1.vcxproj.filters
deleted file mode 100644
index 9327ccf..0000000
--- a/Project1/Project1/Project1.vcxproj.filters
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Исходные файлы
-
-
-
\ No newline at end of file
diff --git a/Project1/Project1/Source.c b/Project1/Project1/Source.c
deleted file mode 100644
index edd2450..0000000
--- a/Project1/Project1/Source.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include
-
-void main() {
-
- for (int n = 1000; n < 10000; n++) {
- for (int x = 1000; x < 10000; x++) {
- int e = 0;
- for (int y = 1000; y < 10000; y++) {
- if ((15 * x + 200 * y) == n) {
- e += 1;
- printf("x = %d, y = %d, n = %d\n", x, y, n);
- if (e == 4) {
- printf("e = 4, x = %d, y = %d, n = %d\n", x, y, n);
- printf("%d", n);
- return;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ProjectAirFighter/ProjectAirFighter/DirectionType.cs b/ProjectAirFighter/ProjectAirFighter/Drawning/DirectionType.cs
similarity index 72%
rename from ProjectAirFighter/ProjectAirFighter/DirectionType.cs
rename to ProjectAirFighter/ProjectAirFighter/Drawning/DirectionType.cs
index 871d9d7..22c4210 100644
--- a/ProjectAirFighter/ProjectAirFighter/DirectionType.cs
+++ b/ProjectAirFighter/ProjectAirFighter/Drawning/DirectionType.cs
@@ -1,9 +1,13 @@
-namespace ProjectAirFighter;
+namespace ProjectAirFighter.Drawning;
///
/// Направление перемещения
///
public enum DirectionType
{
+ ///
+ /// Неизвестное напрвление
+ ///
+ Unknow = -1,
///
/// Вверх
///
diff --git a/ProjectAirFighter/ProjectAirFighter/Drawning/DrawningAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/Drawning/DrawningAirFighter.cs
new file mode 100644
index 0000000..9a4eed4
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/Drawning/DrawningAirFighter.cs
@@ -0,0 +1,80 @@
+using System.Net.NetworkInformation;
+using System.Net.Sockets;
+using ProjectAirFighter.Entities;
+
+namespace ProjectAirFighter.Drawning;
+
+///
+/// класс отвечающий за прорисовку и перемещение объекта-сущности
+///
+public class DrawningAirFighter : DrawningWarPlane
+{
+
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия корпуса
+ /// Признак наличия рокет
+ /// Признак наличия дополнительных крыльев
+ //public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool additionalWing)
+ public DrawningAirFighter(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool additionalWing) : base(120,140)
+ {
+ EntityWarPlane = new EntityAirFighter(speed, weight, bodyColor, additionalColor, rocket, additionalWing);
+
+
+ }
+
+
+
+ public override void DrawTransport(Graphics g)
+ {
+ if (EntityWarPlane == null || EntityWarPlane is not EntityAirFighter warPlane||!_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black, 3);
+ Pen pen_rocket = new(Color.Black);
+
+ Brush brAdd = new SolidBrush(warPlane.AdditionalColor);
+
+ //ракеты
+ if (warPlane.Rocket)
+ {
+ Point[] FirstRocket = { new Point(_startPosX.Value + 55, _startPosY.Value + 110), new Point(_startPosX.Value + 95, _startPosY.Value + 110),
+ new Point(_startPosX.Value + 105, _startPosY.Value + 115),new Point(_startPosX.Value + 95, _startPosY.Value + 120),
+ new Point(_startPosX.Value + 55, _startPosY.Value + 120) };
+ g.DrawPolygon(pen_rocket, FirstRocket);
+ Point[] SecondRocket = { new Point(_startPosX.Value + 55, _startPosY.Value + 30), new Point(_startPosX.Value + 95, _startPosY.Value + 30),
+ new Point(_startPosX.Value + 105, _startPosY.Value + 35),new Point(_startPosX.Value + 95, _startPosY.Value + 40),
+ new Point(_startPosX.Value + 55, _startPosY.Value + 40) };
+ g.DrawPolygon(pen_rocket, SecondRocket);
+
+ g.FillPolygon(brAdd, FirstRocket);
+ g.FillPolygon(brAdd, SecondRocket);
+ }
+ base.DrawTransport(g);
+ if (warPlane.AdditionalWing)
+ {
+ Point[] AddWingLower = { new Point(_startPosX.Value + 60, _startPosY.Value + 80),
+ new Point(_startPosX.Value + 60, _startPosY.Value + 140), new Point(_startPosX.Value + 50, _startPosY.Value + 140),
+ new Point(_startPosX.Value + 40, _startPosY.Value + 80) };
+ g.DrawPolygon(pen, AddWingLower);
+
+ Point[] AddWingUpper = { new Point(_startPosX.Value + 60, _startPosY.Value + 60), new Point(_startPosX.Value + 60, _startPosY.Value),
+ new Point(_startPosX.Value + 50, _startPosY.Value), new Point(_startPosX.Value + 40, _startPosY.Value + 60) };
+ g.DrawPolygon(pen, AddWingUpper);
+
+ g.FillPolygon(brAdd, AddWingUpper);
+ g.FillPolygon(brAdd, AddWingLower);
+ }
+
+ }
+
+
+
+
+}
diff --git a/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/Drawning/DrawningWarPlane.cs
similarity index 51%
rename from ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs
rename to ProjectAirFighter/ProjectAirFighter/Drawning/DrawningWarPlane.cs
index 073191e..17e0fb6 100644
--- a/ProjectAirFighter/ProjectAirFighter/DrawningAirFighter.cs
+++ b/ProjectAirFighter/ProjectAirFighter/Drawning/DrawningWarPlane.cs
@@ -1,17 +1,18 @@
-using System.Net.NetworkInformation;
+using ProjectAirFighter.Entities;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
-namespace ProjectAirFighter;
+namespace ProjectAirFighter.Drawning;
-///
-/// класс отвечающий за прорисовку и перемещение объекта-сущности
-///
-public class DrawningAirFighter
+public class DrawningWarPlane
{
-
///
/// Класс-сущность
///
- public EntityAirFighter? EntityAirFighter { get; private set; }
+ public EntityWarPlane? EntityWarPlane { get; protected set; }
///
/// Ширина окна
@@ -24,46 +25,73 @@ public class DrawningAirFighter
private int? _pictureHeight;
///
- /// Левая координата прорисовки истребителя
+ /// Левая координата прорисовки самолета
///
- private int? _startPosX;
+ protected int? _startPosX;
///
- /// Верхняя координата прорисовки истребителя
+ /// Верхняя координата прорисовки самолета
///
- private int? _startPosY;
+ protected int? _startPosY;
///
- /// Ширина прорисовки истребителя
+ /// Ширина прорисовки самолета
///
- private int? _drawningAirFlighterWidth = 120;
+ private readonly int _drawningWarPlaneWidth = 120;
///
- /// Высота прорисовки истребителя
+ /// Высота прорисовки самолета
///
- private int? _drawningAirFlighterHeight = 140;
+ private readonly int _drawningWarPlaneHeight = 140;
///
- /// Иницифлизация полей объекта-класса истребителя
+ /// Координаты X объекта
///
- /// Скорость
- /// Вес
- /// Основной цвет
- /// Дополнительный цвет
- /// Признак наличия корпуса
- /// Признак наличия рокет
- /// Признак наличия дополнительных крыльев
- //public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool additionalWing)
- public void Init(EntityAirFighter entityAirFighter)
- {
- EntityAirFighter = entityAirFighter;
- //EntityAirFighter.Init(speed, weight, bodyColor, additionalColor, rocket, additionalWing);
+ public int? GetPosX => _startPosX;
+
+ ///
+ /// Координаты Y объекта
+ ///
+ public int? GetPosY => _startPosY;
+
+ ///
+ /// Высота объекта
+ ///
+ public int GetHeight => _drawningWarPlaneHeight;
+
+ ///
+ /// Ширина объекта
+ ///
+ public int GetWigdth => _drawningWarPlaneWidth;
+ private DrawningWarPlane() {
_pictureHeight = null;
_pictureWidth = null;
_startPosX = null;
_startPosY = null;
}
-
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ public DrawningWarPlane(int speed, double weight, Color bodyColor) : this()
+ {
+ EntityWarPlane = new EntityWarPlane(speed, weight, bodyColor);
+
+ }
+ ///
+ /// Конструктор для наслдеников
+ ///
+ /// Высота прорисовки самолета
+ /// Ширина прорисовки самолета
+ public DrawningWarPlane(int drawningWarPlaneWidth,int drawningWarPlaneHeight) : this()
+ {
+ _drawningWarPlaneWidth = drawningWarPlaneWidth;
+ _drawningWarPlaneHeight = drawningWarPlaneHeight;
+
+ }
+
///
/// Установка границ поля
@@ -73,7 +101,7 @@ public class DrawningAirFighter
///
public bool SetPictureSize(int width, int height)
{
- if (width > _drawningAirFlighterWidth && height > _drawningAirFlighterHeight)
+ if (width > _drawningWarPlaneWidth && height > _drawningWarPlaneHeight)
{
_pictureWidth = width;
_pictureHeight = height;
@@ -87,13 +115,13 @@ public class DrawningAirFighter
{
_startPosY = 0;
}
- if (_startPosX.Value + _drawningAirFlighterWidth > _pictureWidth)
+ if (_startPosX.Value + _drawningWarPlaneWidth > _pictureWidth)
{
- _startPosX = _pictureWidth - _drawningAirFlighterWidth;
+ _startPosX = _pictureWidth - _drawningWarPlaneWidth;
}
- if (_startPosY.Value + _drawningAirFlighterHeight > _pictureHeight)
+ if (_startPosY.Value + _drawningWarPlaneHeight > _pictureHeight)
{
- _startPosY = _pictureHeight - _drawningAirFlighterHeight;
+ _startPosY = _pictureHeight - _drawningWarPlaneHeight;
}
}
@@ -108,7 +136,7 @@ public class DrawningAirFighter
///
/// Координата X
/// Координата Y
- public void SetPosition(int x, int y)
+ public void SetPosition(int x, int y)
{
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
{
@@ -126,13 +154,13 @@ public class DrawningAirFighter
{
_startPosY = 0;
}
- if (_startPosX + _drawningAirFlighterWidth > _pictureWidth)
+ if (_startPosX + _drawningWarPlaneWidth > _pictureWidth)
{
- _startPosX = _pictureWidth - _drawningAirFlighterWidth;
+ _startPosX = _pictureWidth - _drawningWarPlaneWidth;
}
- if (_startPosY + _drawningAirFlighterHeight > _pictureHeight)
+ if (_startPosY + _drawningWarPlaneHeight > _pictureHeight)
{
- _startPosY = _pictureHeight - _drawningAirFlighterHeight;
+ _startPosY = _pictureHeight - _drawningWarPlaneHeight;
}
}
@@ -146,9 +174,9 @@ public class DrawningAirFighter
///
/// Направление
/// true - перемещение выполнено, false - перемещение невозможно
- public bool MoveTransport(DirectionType direction)
+ public virtual bool MoveTransport(DirectionType direction)
{
- if (EntityAirFighter == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ if (EntityWarPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return false;
}
@@ -156,30 +184,30 @@ public class DrawningAirFighter
{
//влево
case DirectionType.Left:
- if (_startPosX.Value - EntityAirFighter.Step > 0)
+ if (_startPosX.Value - EntityWarPlane.Step > 0)
{
- _startPosX -= (int)EntityAirFighter.Step;
+ _startPosX -= (int)EntityWarPlane.Step;
}
return true;
//вверх
case DirectionType.Up:
- if (_startPosY.Value - EntityAirFighter.Step > 0)
+ if (_startPosY.Value - EntityWarPlane.Step > 0)
{
- _startPosY -= (int)EntityAirFighter.Step;
+ _startPosY -= (int)EntityWarPlane.Step;
}
return true;
//вниз
case DirectionType.Down:
- if (_startPosY.Value + EntityAirFighter.Step + _drawningAirFlighterHeight < _pictureHeight)
+ if (_startPosY.Value + EntityWarPlane.Step + _drawningWarPlaneWidth < _pictureHeight)
{
- _startPosY += (int)EntityAirFighter.Step;
+ _startPosY += (int)EntityWarPlane.Step;
}
return true;
//вправо
case DirectionType.Right:
- if (_startPosX.Value + EntityAirFighter.Step + _drawningAirFlighterWidth < _pictureWidth)
+ if (_startPosX.Value + EntityWarPlane.Step + _drawningWarPlaneWidth < _pictureWidth)
{
- _startPosX += (int)EntityAirFighter.Step;
+ _startPosX += (int)EntityWarPlane.Step;
}
return true;
default:
@@ -187,37 +215,19 @@ public class DrawningAirFighter
}
}
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
- if (EntityAirFighter == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ if (EntityWarPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
- Pen pen = new(Color.Black,3);
+ Pen pen = new(Color.Black, 3);
Pen pen_rocket = new(Color.Black);
-
- Brush brAdd = new SolidBrush(EntityAirFighter.AdditionalColor);
-
- //ракеты
- if (EntityAirFighter.Rocket)
- {
- Point[] FirstRocket = { new Point(_startPosX.Value + 55, _startPosY.Value + 110), new Point(_startPosX.Value + 95, _startPosY.Value + 110),
- new Point(_startPosX.Value + 105, _startPosY.Value + 115),new Point(_startPosX.Value + 95, _startPosY.Value + 120),
- new Point(_startPosX.Value + 55, _startPosY.Value + 120) };
- g.DrawPolygon(pen_rocket, FirstRocket);
- Point[] SecondRocket = { new Point(_startPosX.Value + 55, _startPosY.Value + 30), new Point(_startPosX.Value + 95, _startPosY.Value + 30),
- new Point(_startPosX.Value + 105, _startPosY.Value + 35),new Point(_startPosX.Value + 95, _startPosY.Value + 40),
- new Point(_startPosX.Value + 55, _startPosY.Value + 40) };
- g.DrawPolygon(pen_rocket, SecondRocket);
-
- g.FillPolygon(brAdd, FirstRocket);
- g.FillPolygon(brAdd, SecondRocket);
- }
//корпус
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 60, 100, 20);
- Point[] body = { new Point(_startPosX.Value + 100, _startPosY.Value + 80),
+ Point[] body = { new Point(_startPosX.Value + 100, _startPosY.Value + 80),
new Point(_startPosX.Value + 120, _startPosY.Value + 70), new Point(_startPosX.Value + 100, _startPosY.Value + 60) };
g.DrawPolygon(pen, body);
//нижнее крыло
@@ -226,7 +236,7 @@ public class DrawningAirFighter
new Point(_startPosX.Value + 60, _startPosY.Value + 80) };
g.DrawPolygon(pen, wingUpper);
//верхнее крыло
- Point[] wingLower = { new Point(_startPosX.Value + 80, _startPosY.Value + 60), new Point(_startPosX.Value + 80, _startPosY.Value),
+ Point[] wingLower = { new Point(_startPosX.Value + 80, _startPosY.Value + 60), new Point(_startPosX.Value + 80, _startPosY.Value),
new Point(_startPosX.Value + 70, _startPosY.Value), new Point(_startPosX.Value + 60, _startPosY.Value + 60) };
g.DrawPolygon(pen, wingLower);
//задние крылья
@@ -239,33 +249,20 @@ public class DrawningAirFighter
new Point(_startPosX.Value, _startPosY.Value + 110),new Point(_startPosX.Value + 25, _startPosY.Value + 90),
new Point(_startPosX.Value + 25, _startPosY.Value + 80) };
g.DrawPolygon(pen, rearWingLower);
-
+
//залив носа
Brush brBlack = new SolidBrush(Color.Black);
g.FillPolygon(brBlack, body);
//залив корпуса
- Brush br = new SolidBrush(EntityAirFighter.BodyColor);
+ Brush br = new SolidBrush(EntityWarPlane.BodyColor);
g.FillRectangle(br, _startPosX.Value, _startPosY.Value + 60, 100, 20);
-
+
g.FillPolygon(br, wingLower);
g.FillPolygon(br, wingUpper);
g.FillPolygon(br, rearWingUpper);
g.FillPolygon(br, rearWingLower);
- if (EntityAirFighter.AdditionalWing)
- {
- Point[] AddWingLower = { new Point(_startPosX.Value + 60, _startPosY.Value + 80),
- new Point(_startPosX.Value + 60, _startPosY.Value + 140), new Point(_startPosX.Value + 50, _startPosY.Value + 140),
- new Point(_startPosX.Value + 40, _startPosY.Value + 80) };
- g.DrawPolygon(pen, AddWingLower);
-
- Point[] AddWingUpper = { new Point(_startPosX.Value + 60, _startPosY.Value + 60), new Point(_startPosX.Value + 60, _startPosY.Value),
- new Point(_startPosX.Value + 50, _startPosY.Value), new Point(_startPosX.Value + 40, _startPosY.Value + 60) };
- g.DrawPolygon(pen, AddWingUpper);
-
- g.FillPolygon(brAdd, AddWingUpper);
- g.FillPolygon(brAdd, AddWingLower);
- }
- }
+
+ }
}
diff --git a/ProjectAirFighter/ProjectAirFighter/EntityAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs
similarity index 86%
rename from ProjectAirFighter/ProjectAirFighter/EntityAirFighter.cs
rename to ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs
index 4869273..c6984d2 100644
--- a/ProjectAirFighter/ProjectAirFighter/EntityAirFighter.cs
+++ b/ProjectAirFighter/ProjectAirFighter/Entities/EntityAirFighter.cs
@@ -1,8 +1,8 @@
-namespace ProjectAirFighter;
+namespace ProjectAirFighter.Entities;
///
/// Класс-сущность "Истребитель"
///
-public class EntityAirFighter
+public class EntityAirFighter : EntityWarPlane
{
///
/// Скорость
@@ -48,11 +48,9 @@ public class EntityAirFighter
/// Дополнительный цвет
/// Признак наличия рокет
/// Признак наличия дополнительных крыльев
- public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool additionalWing)
+ public EntityAirFighter(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool additionalWing) :base(speed, weight, bodyColor)
{
- Speed = speed;
- Weight = weight;
- BodyColor = bodyColor;
+
AdditionalColor = additionalColor;
Rocket = rocket;
AdditionalWing = additionalWing;
@@ -60,4 +58,4 @@ public class EntityAirFighter
}
}
-
+
diff --git a/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs b/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs
new file mode 100644
index 0000000..d62fb0d
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/Entities/EntityWarPlane.cs
@@ -0,0 +1,43 @@
+namespace ProjectAirFighter.Entities;
+///
+/// Класс-сущность "Военный самолет"
+///
+
+public class EntityWarPlane
+{
+ ///
+ /// Скорость
+ ///
+ public int Speed { get; private set; }
+
+ ///
+ /// Вес
+ ///
+ public double Weight { get; private set; }
+
+ ///
+ /// Основной цвет
+ ///
+ public Color BodyColor { get; private set; }
+
+ ///
+ /// Шаг
+ ///
+ public double Step => Speed * 100 / Weight;
+
+ ///
+ /// Конструктор сущности
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия рокет
+ /// Признак наличия дополнительных крыльев
+ public EntityWarPlane(int speed, double weight, Color bodyColor)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ }
+}
diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs
index 4b6b0f1..71347d9 100644
--- a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs
+++ b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.Designer.cs
@@ -34,6 +34,9 @@
buttonUp = new Button();
buttonDown = new Button();
buttonRight = new Button();
+ buttonCreateWarPlane = new Button();
+ comboBoxStrategy = new ComboBox();
+ buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).BeginInit();
SuspendLayout();
//
@@ -41,22 +44,19 @@
//
pictureBoxAirFighter.Dock = DockStyle.Fill;
pictureBoxAirFighter.Location = new Point(0, 0);
- pictureBoxAirFighter.Margin = new Padding(3, 4, 3, 4);
pictureBoxAirFighter.Name = "pictureBoxAirFighter";
- pictureBoxAirFighter.Size = new Size(1056, 743);
+ pictureBoxAirFighter.Size = new Size(924, 557);
pictureBoxAirFighter.TabIndex = 0;
pictureBoxAirFighter.TabStop = false;
-
//
// buttonCreate
//
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreate.Location = new Point(14, 635);
- buttonCreate.Margin = new Padding(3, 4, 3, 4);
+ buttonCreate.Location = new Point(0, 522);
buttonCreate.Name = "buttonCreate";
- buttonCreate.Size = new Size(86, 31);
+ buttonCreate.Size = new Size(232, 23);
buttonCreate.TabIndex = 1;
- buttonCreate.Text = "Создать";
+ buttonCreate.Text = "Создать истребитель";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
@@ -65,10 +65,9 @@
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonLeft.BackgroundImage = Properties.Resources.left;
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
- buttonLeft.Location = new Point(897, 680);
- buttonLeft.Margin = new Padding(3, 4, 3, 4);
+ buttonLeft.Location = new Point(785, 510);
buttonLeft.Name = "buttonLeft";
- buttonLeft.Size = new Size(40, 47);
+ buttonLeft.Size = new Size(35, 35);
buttonLeft.TabIndex = 2;
buttonLeft.UseVisualStyleBackColor = true;
buttonLeft.ClientSizeChanged += FormAirFighter_SizeChanged;
@@ -79,10 +78,9 @@
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonUp.BackgroundImage = Properties.Resources.up;
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
- buttonUp.Location = new Point(946, 625);
- buttonUp.Margin = new Padding(3, 4, 3, 4);
+ buttonUp.Location = new Point(828, 469);
buttonUp.Name = "buttonUp";
- buttonUp.Size = new Size(40, 47);
+ buttonUp.Size = new Size(35, 35);
buttonUp.TabIndex = 3;
buttonUp.UseVisualStyleBackColor = true;
buttonUp.ClientSizeChanged += FormAirFighter_SizeChanged;
@@ -93,10 +91,9 @@
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonDown.BackgroundImage = Properties.Resources.down;
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
- buttonDown.Location = new Point(946, 680);
- buttonDown.Margin = new Padding(3, 4, 3, 4);
+ buttonDown.Location = new Point(828, 510);
buttonDown.Name = "buttonDown";
- buttonDown.Size = new Size(40, 47);
+ buttonDown.Size = new Size(35, 35);
buttonDown.TabIndex = 4;
buttonDown.UseVisualStyleBackColor = true;
buttonDown.ClientSizeChanged += FormAirFighter_SizeChanged;
@@ -107,27 +104,59 @@
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRight.BackgroundImage = Properties.Resources.right;
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
- buttonRight.Location = new Point(993, 680);
- buttonRight.Margin = new Padding(3, 4, 3, 4);
+ buttonRight.Location = new Point(869, 510);
buttonRight.Name = "buttonRight";
- buttonRight.Size = new Size(40, 47);
+ buttonRight.Size = new Size(35, 35);
buttonRight.TabIndex = 5;
buttonRight.UseVisualStyleBackColor = true;
buttonRight.ClientSizeChanged += FormAirFighter_SizeChanged;
buttonRight.Click += ButtonMove_Click;
//
+ // buttonCreateWarPlane
+ //
+ buttonCreateWarPlane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonCreateWarPlane.Location = new Point(238, 522);
+ buttonCreateWarPlane.Name = "buttonCreateWarPlane";
+ buttonCreateWarPlane.Size = new Size(232, 23);
+ buttonCreateWarPlane.TabIndex = 6;
+ buttonCreateWarPlane.Text = "Создать военный самолет";
+ buttonCreateWarPlane.UseVisualStyleBackColor = true;
+ buttonCreateWarPlane.Click += buttonCreateWarPlane_Click;
+ //
+ // comboBoxStrategy
+ //
+ comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
+ comboBoxStrategy.FormattingEnabled = true;
+ comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
+ comboBoxStrategy.Location = new Point(791, 12);
+ comboBoxStrategy.Name = "comboBoxStrategy";
+ comboBoxStrategy.Size = new Size(121, 23);
+ comboBoxStrategy.TabIndex = 7;
+ //
+ // buttonStrategyStep
+ //
+ buttonStrategyStep.Location = new Point(829, 41);
+ buttonStrategyStep.Name = "buttonStrategyStep";
+ buttonStrategyStep.Size = new Size(75, 23);
+ buttonStrategyStep.TabIndex = 8;
+ buttonStrategyStep.Text = "Шаг";
+ buttonStrategyStep.UseVisualStyleBackColor = true;
+ buttonStrategyStep.Click += buttonStrategyStep_Click;
+ //
// FormAirFighter
//
- AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(1056, 743);
+ ClientSize = new Size(924, 557);
+ Controls.Add(buttonStrategyStep);
+ Controls.Add(comboBoxStrategy);
+ Controls.Add(buttonCreateWarPlane);
Controls.Add(buttonRight);
Controls.Add(buttonDown);
Controls.Add(buttonUp);
Controls.Add(buttonLeft);
Controls.Add(buttonCreate);
Controls.Add(pictureBoxAirFighter);
- Margin = new Padding(3, 4, 3, 4);
Name = "FormAirFighter";
Text = "Истребитель";
SizeChanged += FormAirFighter_SizeChanged;
@@ -143,5 +172,8 @@
private Button buttonUp;
private Button buttonDown;
private Button buttonRight;
+ private Button buttonCreateWarPlane;
+ private ComboBox comboBoxStrategy;
+ private Button buttonStrategyStep;
}
}
\ No newline at end of file
diff --git a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs
index 6b7188e..6a77d56 100644
--- a/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs
+++ b/ProjectAirFighter/ProjectAirFighter/FormAirFighter.cs
@@ -7,6 +7,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using ProjectAirFighter.Drawning;
+using ProjectAirFighter.Entities;
+using ProjectAirFighter.MovementStrategy;
namespace ProjectAirFighter
{
@@ -14,43 +17,75 @@ namespace ProjectAirFighter
{
- private DrawningAirFighter? _drawningAirFighter;
+ private DrawningWarPlane? _drawningWarPlane;
- private EntityAirFighter? _entityAirFighter;
+ ///
+ /// Стратегия перемещения
+ ///
+ private AbstractStrategy? _strategy;
+ ///
+ /// Конструктор формы
+ ///
public FormAirFighter()
{
InitializeComponent();
+ _strategy = null;
}
-
+ ///
+ /// Метод прорисовки
+ ///
private void Draw()
{
- if (_drawningAirFighter == null) return;
+ if (_drawningWarPlane == null) return;
Bitmap bmp = new(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
Graphics gr = Graphics.FromImage(bmp);
- _drawningAirFighter.DrawTransport(gr);
+ _drawningWarPlane.DrawTransport(gr);
pictureBoxAirFighter.Image = bmp;
}
+ private void CreateObject(string type)
+ {
+ Random random = new();
+ switch (type)
+ {
+ case nameof(DrawningWarPlane):
+ _drawningWarPlane = new DrawningWarPlane(random.Next(100, 300),
+ random.Next(1000, 3000),
+ Color.FromArgb(random.Next(0, 256),
+ random.Next(0, 256), random.Next(0, 256)));
+ break;
+ case nameof(DrawningAirFighter):
+ _drawningWarPlane = new DrawningAirFighter(random.Next(100,
+ 300), random.Next(1000, 3000),
+ Color.FromArgb(random.Next(0, 256),
+ random.Next(0, 256), random.Next(0, 256)),
+ Color.FromArgb(random.Next(0, 256),
+ random.Next(0, 256), random.Next(0, 256)),
+ Convert.ToBoolean(random.Next(0, 2)),
+ Convert.ToBoolean(random.Next(0, 2)));
+ break;
+ default:
+ return;
+ }
+ _drawningWarPlane.SetPictureSize(pictureBoxAirFighter.Width,
+ pictureBoxAirFighter.Height);
+ _drawningWarPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
+ _strategy = null;
+ comboBoxStrategy.Enabled = true;
+ Draw();
+ }
private void ButtonCreate_Click(object sender, EventArgs e)
{
- Random random = new();
- _drawningAirFighter = new DrawningAirFighter();
- _entityAirFighter = new EntityAirFighter();
-
- _entityAirFighter.Init(random.Next(100, 300), random.Next(1000, 3000),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
- Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
- _drawningAirFighter.Init(_entityAirFighter);
- _drawningAirFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
- _drawningAirFighter.SetPosition(random.Next(40, 100), random.Next(40, 100));
-
- Draw();
+ CreateObject(nameof(DrawningAirFighter));
+ }
+ private void buttonCreateWarPlane_Click(object sender, EventArgs e)
+ {
+ CreateObject(nameof(DrawningWarPlane));
}
private void ButtonMove_Click(object sender, EventArgs e)
{
- if (_drawningAirFighter == null)
+ if (_drawningWarPlane == null)
{
return;
}
@@ -60,16 +95,16 @@ namespace ProjectAirFighter
switch (name)
{
case "buttonUp":
- result = _drawningAirFighter.MoveTransport(DirectionType.Up);
+ result = _drawningWarPlane.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
- result = _drawningAirFighter.MoveTransport(DirectionType.Down);
+ result = _drawningWarPlane.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
- result = _drawningAirFighter.MoveTransport(DirectionType.Left);
+ result = _drawningWarPlane.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
- result = _drawningAirFighter.MoveTransport(DirectionType.Right);
+ result = _drawningWarPlane.MoveTransport(DirectionType.Right);
break;
}
if (result)
@@ -81,19 +116,54 @@ namespace ProjectAirFighter
}
private void FormAirFighter_SizeChanged(object sender, EventArgs e)
{
- if (_drawningAirFighter == null) return;
+ if (_drawningWarPlane == null) return;
- _drawningAirFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
+ _drawningWarPlane.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
- if (_drawningAirFighter.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height))
+ if (_drawningWarPlane.SetPictureSize(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height))
{
Draw();
}
}
-
+ private void buttonStrategyStep_Click(object sender, EventArgs e)
+ {
+ if (_drawningWarPlane == null)
+ {
+ return;
+ }
+ if (comboBoxStrategy.Enabled)
+ {
+ _strategy = comboBoxStrategy.SelectedIndex switch
+ {
+ 0 => new MoveToCenter(),
+ 1 => new MoveToBorder(),
+ _ => null,
+ };
+ if (_strategy == null)
+ {
+ return;
+ }
+ _strategy.SetDate(new MoveableWarPlane(_drawningWarPlane), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
+ }
+
+ if (_strategy == null)
+ {
+ return;
+ }
+
+ comboBoxStrategy.Enabled = false;
+ _strategy.MakeStep();
+ Draw();
+
+ if (_strategy.GetStatus() == StrategyStatus.Finish)
+ {
+ comboBoxStrategy.Enabled = true;
+ _strategy = null;
+ }
+ }
}
}
diff --git a/ProjectAirFighter/ProjectAirFighter/MovementStrategy/AbstractStrategy.cs b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/AbstractStrategy.cs
new file mode 100644
index 0000000..fd5fed0
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/AbstractStrategy.cs
@@ -0,0 +1,123 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirFighter.MovementStrategy;
+
+public abstract class AbstractStrategy
+{
+ ///
+ /// Перемещенный объект
+ ///
+ private IMoveableObject? _moveableObject;
+
+ ///
+ /// Статус перемещения
+ ///
+ private StrategyStatus _state = StrategyStatus.NotInit;
+
+ ///
+ /// Ширина поля
+ ///
+ protected int FieldWidth { get; private set; }
+
+ ///
+ /// Высота поля
+ ///
+ protected int FieldHeight { get; private set; }
+
+ ///
+ /// Статус перемещения
+ ///
+ public StrategyStatus GetStatus() { return _state; }
+
+ public void SetDate(IMoveableObject moveableObject, int width, int height)
+ {
+ if (moveableObject == null)
+ {
+ _state = StrategyStatus.NotInit;
+ return;
+ }
+
+ _state = StrategyStatus.InProgress;
+ _moveableObject = moveableObject;
+ FieldWidth = width;
+ FieldHeight = height;
+ }
+
+ public void MakeStep()
+ {
+ if (_state != StrategyStatus.InProgress)
+ {
+ return;
+ }
+ if (IsTargetDestinaion())
+ {
+ _state = StrategyStatus.Finish;
+ return;
+ }
+ MoveToTarget();
+ }
+ ///
+ /// Перемещение влево
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveLeft() => MoveTo(MovementDirection.Left);
+ ///
+ /// Перемещение вправо
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveRight() => MoveTo(MovementDirection.Right);
+ ///
+ /// Перемещение вверх
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveUp() => MoveTo(MovementDirection.Up);
+ ///
+ /// Перемещение вниз
+ ///
+ /// Результат перемещения (true - удалось переместиться, false - неудача)
+ protected bool MoveDown() => MoveTo(MovementDirection.Down);
+ ///
+ /// Параметры объекта
+ ///
+ protected ObjectParameters? GetObjectParameters =>
+ _moveableObject?.GetObjectPosition;
+ ///
+ /// Шаг объекта
+ ///
+ ///
+ protected int? GetStep()
+ {
+ if (_state != StrategyStatus.InProgress)
+ {
+ return null;
+ }
+ return _moveableObject?.GetStep;
+ }
+ ///
+ /// Перемещение к цели
+ ///
+ protected abstract void MoveToTarget();
+ ///
+ /// Достигнута ли цель
+ ///
+ ///
+ protected abstract bool IsTargetDestinaion();
+ ///
+ /// Попытка перемещения в требуемом направлении
+ ///
+ /// Направление
+ /// Результат попытки (true - удалось переместиться, false - неудача)
+ private bool MoveTo(MovementDirection movementDirection)
+ {
+ if (_state != StrategyStatus.InProgress)
+ {
+ return false;
+ }
+ return _moveableObject?.TryMoveObject(movementDirection) ?? false;
+ }
+}
+
diff --git a/ProjectAirFighter/ProjectAirFighter/MovementStrategy/IMoveableObject.cs b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/IMoveableObject.cs
new file mode 100644
index 0000000..4f53874
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/IMoveableObject.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirFighter.MovementStrategy;
+
+public interface IMoveableObject
+{
+ ///
+ /// Получение координаты объекта
+ ///
+ ObjectParameters? GetObjectPosition { get; }
+
+ ///
+ /// Шаг объекта
+ ///
+ int GetStep { get; }
+
+ bool TryMoveObject(MovementDirection direction);
+}
diff --git a/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveToBorder.cs b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveToBorder.cs
new file mode 100644
index 0000000..2a83b99
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveToBorder.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirFighter.MovementStrategy;
+
+public class MoveToBorder : AbstractStrategy
+{
+ protected override bool IsTargetDestinaion()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return false;
+ }
+ return objParams.LeftBorder - GetStep() <= 0 || objParams.RightBorder + GetStep() >= FieldWidth ||
+ objParams.TopBorder - GetStep() <= 0 || objParams.ObjectMiddleVertical + GetStep() >= FieldHeight;
+ }
+
+ protected override void MoveToTarget()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return;
+ }
+ int x = objParams.RightBorder;
+ if (x + GetStep() < FieldWidth) MoveRight();
+ int y = objParams.DownBorder;
+ if (y + GetStep() < FieldHeight) MoveDown();
+ }
+}
diff --git a/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveToCenter.cs b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveToCenter.cs
new file mode 100644
index 0000000..13468e0
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveToCenter.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirFighter.MovementStrategy;
+
+public class MoveToCenter : AbstractStrategy
+{
+ protected override bool IsTargetDestinaion()
+ {
+ ObjectParameters? objParams = GetObjectParameters;
+ if (objParams == null)
+ {
+ return false;
+ }
+ 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;
+ if (objParams == null)
+ {
+ return;
+ }
+ int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
+ if (Math.Abs(diffX) > GetStep())
+ {
+ if (diffX > 0)
+ {
+ MoveLeft();
+ }
+ else
+ {
+ MoveRight();
+ }
+ }
+ int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
+ if (Math.Abs(diffY) > GetStep())
+ {
+ if (diffY > 0)
+ {
+ MoveUp();
+ }
+ else
+ {
+ MoveDown();
+ }
+
+ }
+ }
+ }
diff --git a/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveableWarPlane.cs b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveableWarPlane.cs
new file mode 100644
index 0000000..1fa15ed
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MoveableWarPlane.cs
@@ -0,0 +1,67 @@
+using ProjectAirFighter.Drawning;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirFighter.MovementStrategy;
+
+///
+/// класс реализация IMoveableObject с исользованием DrawningWarPlane
+///
+public class MoveableWarPlane: IMoveableObject
+{
+ ///
+ /// Полк объекта DrawningWarPlane или его наследника
+ ///
+ private readonly DrawningWarPlane? _warPlane = null;
+
+ ///
+ /// Конструктор
+ ///
+ /// Объект класса DrawningWarPlane
+ public MoveableWarPlane(DrawningWarPlane warPlane)
+ {
+ _warPlane = warPlane;
+ }
+
+ public ObjectParameters? GetObjectPosition {
+ get
+ {
+ if (_warPlane == null || _warPlane.EntityWarPlane == null || !_warPlane.GetPosX.HasValue || !_warPlane.GetPosY.HasValue)
+ {
+ return null;
+ }
+ return new ObjectParameters(_warPlane.GetPosX.Value, _warPlane.GetPosY.Value, _warPlane.GetWigdth, _warPlane.GetHeight);
+ }
+ }
+
+ public int GetStep => (int)(_warPlane?.EntityWarPlane?.Step ?? 0);
+
+ public bool TryMoveObject(MovementDirection direction)
+ {
+ if (_warPlane == null || _warPlane.EntityWarPlane == null)
+ {
+ return false;
+ }
+ return _warPlane.MoveTransport(GetDirectionType(direction));
+ }
+
+ ///
+ /// Конвертация из MovementDirection в DirectionType
+ ///
+ /// MovementDirection
+ /// DirectionType
+ private static DirectionType GetDirectionType(MovementDirection direction)
+ {
+ return direction switch
+ {
+ MovementDirection.Left => DirectionType.Left,
+ MovementDirection.Right => DirectionType.Right,
+ MovementDirection.Up => DirectionType.Up,
+ MovementDirection.Down => DirectionType.Down,
+ _ => DirectionType.Unknow,
+ };
+ }
+}
diff --git a/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MovementDirection.cs b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MovementDirection.cs
new file mode 100644
index 0000000..c22a919
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/MovementDirection.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirFighter.MovementStrategy;
+
+public enum MovementDirection
+{
+
+ ///
+ /// Вверх
+ ///
+ Up = 1,
+
+ ///
+ /// Вниз
+ ///
+ Down = 2,
+
+ ///
+ /// Влево
+ ///
+ Left = 3,
+
+ ///
+ /// Вправо
+ ///
+ Right = 4
+}
diff --git a/ProjectAirFighter/ProjectAirFighter/MovementStrategy/ObjectParameters.cs b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/ObjectParameters.cs
new file mode 100644
index 0000000..96d9888
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/ObjectParameters.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirFighter.MovementStrategy;
+
+public class ObjectParameters {
+ ///
+/// Координата X
+///
+private readonly int _x;
+
+///
+/// Координата Y
+///
+private readonly int _y;
+
+///
+/// Ширина объекта
+///
+private readonly int _width;
+
+///
+/// Высота объекта
+///
+private readonly int _height;
+
+///
+/// Левая граница
+///
+public int LeftBorder => _x;
+
+///
+/// Верхняя граница
+///
+public int TopBorder => _y;
+
+///
+/// Правая граница
+///
+public int RightBorder => _x + _width;
+
+///
+/// Нижняя граница
+///
+public int DownBorder => _y + _height;
+
+///
+/// Середина объекта
+///
+public int ObjectMiddleHorizontal => _x + _width / 2;
+
+///
+/// Середина объекта
+///
+public int ObjectMiddleVertical => _y + _height / 2;
+
+///
+/// Конструктор
+///
+/// Координата X
+/// Координата Y
+/// Ширина объекта
+/// Высота объекта
+public ObjectParameters(int x, int y, int width, int height)
+{
+ _x = x;
+ _y = y;
+ _width = width;
+ _height = height;
+}
+
+}
diff --git a/ProjectAirFighter/ProjectAirFighter/MovementStrategy/StrategyStatus.cs b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/StrategyStatus.cs
new file mode 100644
index 0000000..0cf805c
--- /dev/null
+++ b/ProjectAirFighter/ProjectAirFighter/MovementStrategy/StrategyStatus.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectAirFighter.MovementStrategy;
+///
+/// Статус выполнения операции перемещения
+///
+public enum StrategyStatus
+{
+ ///
+ /// Все готово к началу
+ ///
+ NotInit,
+ ///
+ /// Выполняется
+ ///
+ InProgress,
+ ///
+ /// Завершено
+ ///
+ Finish
+
+}
diff --git a/ProjectAirFighter/ProjectAirFighter/ProjectAirFighter.csproj b/ProjectAirFighter/ProjectAirFighter/ProjectAirFighter.csproj
index af03d74..629ec08 100644
--- a/ProjectAirFighter/ProjectAirFighter/ProjectAirFighter.csproj
+++ b/ProjectAirFighter/ProjectAirFighter/ProjectAirFighter.csproj
@@ -2,7 +2,7 @@
WinExe
- net8.0-windows
+ net8.0-windows7.0
enable
true
enable