diff --git a/WinFormsLabRad1/WinFormsLabRad1/DrawningTankZU.cs b/WinFormsLabRad1/WinFormsLabRad1/DrawningTankZU.cs
deleted file mode 100644
index 6dde841..0000000
--- a/WinFormsLabRad1/WinFormsLabRad1/DrawningTankZU.cs
+++ /dev/null
@@ -1,250 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WinFormsLabRad1
-{
- ///
- /// Класс, отвечающий за прорисовку и перемещение объекта-сущности
- ///
- public class DrawningTankZU
- {
- ///
- /// Класс-сущность
- ///
- public EntityTankZU? EntityTankZU { get; private set; }
- ///
- /// Ширина окна
- ///
- private int? _pictureWidth;
- ///
- /// Высота окна
- ///
- private int? _pictureHeight;
- ///
- /// Левая координата прорисовки автомобиля
- ///
- private int? _startPosX;
- ///
- /// Верхняя кооридната прорисовки автомобиля
- ///
- private int? _startPosY;
- ///
- /// Ширина прорисовки автомобиля
- ///
- private readonly int _drawningTankWidth = 90;
- ///
- /// Высота прорисовки автомобиля
- ///
- private readonly int _drawningTankHeight = 70;
-
- ///
- /// Инициализация свойств
- ///
- /// Скорость
- /// Вес автомобиля
- /// Основной цвет
- /// Дополнительный цвет
- /// Признак наличия обвеса
- /// Признак наличия антикрыла
- /// Признак наличия гоночной полосы
- public void Init(int speed, double weight, Color bodyColor,
- Color additionalColor, bool bashnya, bool zenorudie,
- bool radar)
- {
- EntityTankZU = new EntityTankZU();
- EntityTankZU.Init(speed, weight, bodyColor, additionalColor, bashnya, zenorudie, radar);
- _pictureWidth = null;
- _pictureHeight = null;
- _startPosX = null;
- _startPosY = null;
- }
-
- ///
- /// Установка границ поля
- ///
- /// Ширина поля
- /// Высота поля
- /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
- public bool SetPictureSize(int width, int height)
- {
- // TODO проверка, что объект "влезает" в размеры поля
- // Паша - написаЛ проверку:
- if (width <= _drawningTankWidth || height <= _drawningTankHeight)
- {
- return false;
- }
- // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
- _pictureWidth = width;
- _pictureHeight = height;
- return true;
- }
-
- ///
- /// Установка позиции
- ///
- /// Координата X
- /// Координата Y
- public void SetPosition(int x, int y)
- {
- int endx = x + _drawningTankWidth;
-
- int endy = y + _drawningTankHeight;
-
- if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
- {
- return;
- }
- // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
- // Паша - написаЛ проверку
- // то надо изменить координаты, чтобы он оставался в этих границах
- if (endx > _pictureWidth || x < 0 || endy > _pictureHeight || y < 0)
- {
- x = 0;
- y = 0;
- }
- else
- {
- _startPosX = x;
- _startPosY = y;
- }
-
- }
- public bool MoveTransport(DirectionType direction)
- {
- if (EntityTankZU == null || !_startPosX.HasValue || !_startPosY.HasValue)
- {
- return false;
- }
- switch (direction)
- {
- //влево
- case DirectionType.Left:
- if (_startPosX.Value - EntityTankZU.Step > 0)
- {
- _startPosX -= (int)EntityTankZU.Step;
- }
- return true;
- //вверх
- case DirectionType.Up:
- if (_startPosY.Value - EntityTankZU.Step > 0)
- {
- _startPosY -= (int)EntityTankZU.Step;
- }
- return true;
- // вправо
- case DirectionType.Right:
- //TODO прописать логику сдвига в право
- //Паша - НаписаЛ
- if (_startPosX.Value + _drawningTankWidth + EntityTankZU.Step < _pictureWidth)
- {
- _startPosX += (int)EntityTankZU.Step;
- }
- return true;
- //вниз
- case DirectionType.Down:
- //TODO прописать логику сдвига в вниз
- //Паша - НаписаЛ
- if (_startPosY.Value + _drawningTankHeight + EntityTankZU.Step < _pictureHeight)
- {
- _startPosY += (int)EntityTankZU.Step;
- }
- return true;
- default:
- return false;
- }
- }
- ///
- /// Прорисовка объекта
- ///
- ///
- public void DrawTransport(Graphics g)
- {
- if (EntityTankZU == null || !_startPosX.HasValue || !_startPosY.HasValue)
- {
- return;
- }
-
- Pen pen = new(Color.Black);
-
- Brush additionalBrush = new SolidBrush(EntityTankZU.AdditionalColor);
-
- // Осн. корпус
- Brush br = new SolidBrush(EntityTankZU.BodyColor);
-
- // Гусеницы, колёса
- g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 60, 70, 10);
- g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 50, 20, 20);
- g.DrawEllipse(pen, _startPosX.Value + 70, _startPosY.Value + 50, 20, 20);
- g.DrawEllipse(pen, _startPosX.Value + 22, _startPosY.Value + 50, 20, 20);
- g.DrawEllipse(pen, _startPosX.Value + 45, _startPosY.Value + 50, 20, 20);
- g.FillEllipse(br, _startPosX.Value, _startPosY.Value + 50, 20, 20);
- g.FillEllipse(br, _startPosX.Value + 70, _startPosY.Value + 50, 20, 20);
- g.FillEllipse(br, _startPosX.Value + 22, _startPosY.Value + 50, 20, 20);
- g.FillEllipse(br, _startPosX.Value + 45, _startPosY.Value + 50, 20, 20);
-
- // ВЛД контур
- g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 40, 70, 20);
- g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 50, 10, 10);
- g.DrawRectangle(pen, _startPosX.Value + 80, _startPosY.Value + 50, 10, 10);
- g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 40, 20, 20);
- g.DrawEllipse(pen, _startPosX.Value + 70, _startPosY.Value + 40, 20, 20);
-
- // ВЛД заливка
- g.FillRectangle(br, _startPosX.Value + 10, _startPosY.Value + 40, 70, 20);
- g.FillRectangle(br, _startPosX.Value, _startPosY.Value + 50, 10, 10);
- g.FillRectangle(br, _startPosX.Value + 80, _startPosY.Value + 50, 10, 10);
- g.FillEllipse(br, _startPosX.Value, _startPosY.Value + 40, 20, 20);
- g.FillEllipse(br, _startPosX.Value + 70, _startPosY.Value + 40, 20, 20);
-
- // Допы
-
- //Зенорудие
- if (EntityTankZU.Zenorudie)
- {
- g.DrawRectangle(pen, _startPosX.Value + 40, _startPosY.Value + 30, 10, 10);
- g.DrawRectangle(pen, _startPosX.Value + 50, _startPosY.Value + 30, 10, 10);
- g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 30, 10, 10);
- g.DrawRectangle(pen, _startPosX.Value + 40, _startPosY.Value + 20, 10, 10);
- g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 30, _startPosX.Value + 80, _startPosY.Value);
- g.DrawLine(pen, _startPosX.Value + 40, _startPosY.Value + 30, _startPosX.Value + 70, _startPosY.Value);
- g.FillRectangle(additionalBrush, _startPosX.Value + 40, _startPosY.Value + 30, 10, 10);
- g.FillRectangle(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 30, 10, 10);
- g.FillRectangle(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 30, 10, 10);
- g.FillRectangle(additionalBrush, _startPosX.Value + 40, _startPosY.Value + 20, 10, 10);
- }
-
- // Башня
- if (EntityTankZU.Bashnya)
- {
- g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 20, 30, 20);
- g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 30, 10, 10);
- g.DrawRectangle(pen, _startPosX.Value + 60, _startPosY.Value + 30, 10, 10);
- g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 20, 20, 20);
- g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 20, 20, 20);
- g.FillRectangle(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 20, 30, 20);
- g.FillRectangle(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 30, 10, 10);
- g.FillRectangle(additionalBrush, _startPosX.Value + 60, _startPosY.Value + 30, 10, 10);
- g.FillEllipse(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 20, 20, 20);
- g.FillEllipse(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 20, 20, 20);
- }
-
- // Радар
- if (EntityTankZU.Radar)
- {
- g.DrawLine(pen, _startPosX.Value + 0, _startPosY.Value + 50, _startPosX.Value + 10, _startPosY.Value + 20);
- g.DrawLine(pen, _startPosX.Value + 20, _startPosY.Value + 40, _startPosX.Value + 10, _startPosY.Value + 20);
- g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 20, _startPosX.Value + 25, _startPosY.Value);
-
- Point point1 = new Point(_startPosX.Value + 10, _startPosY.Value);
- Point point3 = new Point(_startPosX.Value + 10, _startPosY.Value + 20);
- Point point5 = new Point(_startPosX.Value + 30, _startPosY.Value + 10);
- Point[] curvePoints = { point1, point3, point5 };
- float tension = 0.8F;
- g.DrawCurve(pen, curvePoints, tension);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/WinFormsLabRad1/WinFormsLabRad1/DirectionType.cs b/WinFormsLabRad1/WinFormsLabRad1/Drawnings/DirectionType.cs
similarity index 94%
rename from WinFormsLabRad1/WinFormsLabRad1/DirectionType.cs
rename to WinFormsLabRad1/WinFormsLabRad1/Drawnings/DirectionType.cs
index e605801..5df2d6a 100644
--- a/WinFormsLabRad1/WinFormsLabRad1/DirectionType.cs
+++ b/WinFormsLabRad1/WinFormsLabRad1/Drawnings/DirectionType.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace WinFormsLabRad1
+namespace WinFormsLabRad1.Drawnings
{
///
/// Направление перемещения
diff --git a/WinFormsLabRad1/WinFormsLabRad1/Drawnings/DrawningPlatforma.cs b/WinFormsLabRad1/WinFormsLabRad1/Drawnings/DrawningPlatforma.cs
new file mode 100644
index 0000000..b000e75
--- /dev/null
+++ b/WinFormsLabRad1/WinFormsLabRad1/Drawnings/DrawningPlatforma.cs
@@ -0,0 +1,207 @@
+using WinFormsLabRad1.Entities;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WinFormsLabRad1.Drawnings
+{
+ ///
+ /// Класс, отвечающий за прорисовку и перемещение объекта базовой сущности
+ ///
+ public class DrawningPlatforma
+ {
+ ///
+ /// Класс-сущность
+ ///
+ public EntityPlatforma? EntityPlatforma { get; protected set; }
+ ///
+ /// Ширина окна
+ ///
+ private int? _pictureWidth;
+ ///
+ /// Высота окна
+ ///
+ private int? _pictureHeight;
+ ///
+ /// Левая координата прорисовки автомобиля
+ ///
+ protected int? _startPosX;
+ ///
+ /// Верхняя кооридната прорисовки автомобиля
+ ///
+ protected int? _startPosY;
+ ///
+ /// Ширина прорисовки автомобиля
+ ///
+ private readonly int _drawningPlatformaWidth = 90;
+ ///
+ /// Высота прорисовки автомобиля
+ ///
+ private readonly int _drawningPlatformaHeight = 30;
+
+ private DrawningPlatforma()
+ {
+ _pictureWidth = null;
+ _pictureHeight = null;
+ _startPosX = null;
+ _startPosY = null;
+ }
+
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ public DrawningPlatforma(int speed, double weight, Color bodyColor) : this()
+ {
+ EntityPlatforma = new EntityPlatforma(speed, weight, bodyColor);
+ }
+ ///
+ /// Конструктор для наследников
+ ///
+ /// Ширина прорисовки машины
+ /// Высота прорисовки машины
+ protected DrawningPlatforma(int drawningMachineWidth, int drawningMachineHeight) : this()
+ {
+ _drawningPlatformaWidth = drawningMachineWidth;
+ _pictureHeight = drawningMachineHeight;
+ }
+
+ ///
+ /// Установка границ поля
+ ///
+ /// Ширина поля
+ /// Высота поля
+ /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
+ public bool SetPictureSize(int width, int height)
+ {
+ // TODO проверка, что объект "влезает" в размеры поля
+ // Паша - написаЛ проверку:
+ if (width <= _drawningPlatformaWidth || height <= _drawningPlatformaHeight)
+ {
+ return false;
+ }
+ // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
+ _pictureWidth = width;
+ _pictureHeight = height;
+ return true;
+ }
+
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ public void SetPosition(int x, int y)
+ {
+ // int endx = x + _drawningTankWidth;
+
+ // int endy = y + _drawningTankHeight;
+
+ if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ {
+ return;
+ }
+ // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
+ // Паша - написаЛ проверку
+ // то надо изменить координаты, чтобы он оставался в этих границах
+ if (x > _pictureWidth || x < 0 || y > _pictureHeight || y < 0)
+ {
+ x = 0;
+ y = 0;
+ }
+ _startPosX = x;
+ _startPosY = y;
+
+ }
+ public bool MoveTransport(DirectionType direction)
+ {
+ if (EntityPlatforma == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return false;
+ }
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX.Value - EntityPlatforma.Step > 0)
+ {
+ _startPosX -= (int)EntityPlatforma.Step;
+ }
+ return true;
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY.Value - EntityPlatforma.Step > 0)
+ {
+ _startPosY -= (int)EntityPlatforma.Step;
+ }
+ return true;
+ // вправо
+ case DirectionType.Right:
+ //TODO прописать логику сдвига в право
+ //Паша - НаписаЛ
+ if (_startPosX.Value + _drawningPlatformaWidth + EntityPlatforma.Step < _pictureWidth)
+ {
+ _startPosX += (int)EntityPlatforma.Step;
+ }
+ return true;
+ //вниз
+ case DirectionType.Down:
+ //TODO прописать логику сдвига в вниз
+ //Паша - НаписаЛ
+ if (_startPosY.Value + _drawningPlatformaHeight + EntityPlatforma.Step < _pictureHeight)
+ {
+ _startPosY += (int)EntityPlatforma.Step;
+ }
+ return true;
+ default:
+ return false;
+ }
+ }
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public virtual void DrawTransport(Graphics g)
+ {
+ if (EntityPlatforma == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+
+ // Осн. корпус
+ Brush br = new SolidBrush(EntityPlatforma.BodyColor);
+
+ // Гусеницы, колёса
+ g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 20, 70, 10);
+ g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 10, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 70, _startPosY.Value + 10, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 22, _startPosY.Value + 10, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 45, _startPosY.Value + 10, 20, 20);
+ g.FillEllipse(br, _startPosX.Value, _startPosY.Value + 10, 20, 20);
+ g.FillEllipse(br, _startPosX.Value + 70, _startPosY.Value + 10, 20, 20);
+ g.FillEllipse(br, _startPosX.Value + 22, _startPosY.Value + 10, 20, 20);
+ g.FillEllipse(br, _startPosX.Value + 45, _startPosY.Value + 10, 20, 20);
+
+ // ВЛД контур
+ g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value, 70, 20);
+ g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 10, 10, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 80, _startPosY.Value + 10, 10, 10);
+ g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 70, _startPosY.Value, 20, 20);
+
+ // ВЛД заливка
+ g.FillRectangle(br, _startPosX.Value + 10, _startPosY.Value, 70, 20);
+ g.FillRectangle(br, _startPosX.Value, _startPosY.Value + 10, 10, 10);
+ g.FillRectangle(br, _startPosX.Value + 80, _startPosY.Value + 10, 10, 10);
+ g.FillEllipse(br, _startPosX.Value, _startPosY.Value, 20, 20);
+ g.FillEllipse(br, _startPosX.Value + 70, _startPosY.Value, 20, 20);
+
+ }
+ }
+}
diff --git a/WinFormsLabRad1/WinFormsLabRad1/Drawnings/DrawningTankZU.cs b/WinFormsLabRad1/WinFormsLabRad1/Drawnings/DrawningTankZU.cs
new file mode 100644
index 0000000..c657f53
--- /dev/null
+++ b/WinFormsLabRad1/WinFormsLabRad1/Drawnings/DrawningTankZU.cs
@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WinFormsLabRad1.Entities;
+
+namespace WinFormsLabRad1.Drawnings
+{
+ ///
+ /// Класс, отвечающий за прорисовку и перемещение объекта-сущности
+ ///
+ public class DrawningTankZU : DrawningPlatforma
+ {
+
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия обвеса
+ /// Признак наличия антикрыла
+ /// Признак наличия гоночной полосы
+ public DrawningTankZU(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) : base(90, 70)
+ {
+ EntityPlatforma = new EntityTankZU(speed, weight, bodyColor, additionalColor, bodyKit, wing, sportLine);
+ }
+
+
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public override void DrawTransport(Graphics g)
+ {
+ if (EntityPlatforma == null || EntityPlatforma is not EntityTankZU TankZU || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+
+ Brush additionalBrush = new SolidBrush(TankZU.AdditionalColor);
+
+ // Допы
+
+ //Зенорудие
+ if (TankZU.Zenorudie)
+ {
+ g.DrawRectangle(pen, _startPosX.Value + 40, _startPosY.Value + 30, 10, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 50, _startPosY.Value + 30, 10, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 30, 10, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 40, _startPosY.Value + 20, 10, 10);
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 30, _startPosX.Value + 80, _startPosY.Value);
+ g.DrawLine(pen, _startPosX.Value + 40, _startPosY.Value + 30, _startPosX.Value + 70, _startPosY.Value);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 40, _startPosY.Value + 30, 10, 10);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 30, 10, 10);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 30, 10, 10);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 40, _startPosY.Value + 20, 10, 10);
+ }
+
+ // Башня
+ if (TankZU.Bashnya)
+ {
+ g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 20, 30, 20);
+ g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 30, 10, 10);
+ g.DrawRectangle(pen, _startPosX.Value + 60, _startPosY.Value + 30, 10, 10);
+ g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 20, 20, 20);
+ g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 20, 20, 20);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 20, 30, 20);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 30, 10, 10);
+ g.FillRectangle(additionalBrush, _startPosX.Value + 60, _startPosY.Value + 30, 10, 10);
+ g.FillEllipse(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 20, 20, 20);
+ g.FillEllipse(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 20, 20, 20);
+ }
+
+ // Радар
+ if (TankZU.Radar)
+ {
+ g.DrawLine(pen, _startPosX.Value + 0, _startPosY.Value + 50, _startPosX.Value + 10, _startPosY.Value + 20);
+ g.DrawLine(pen, _startPosX.Value + 20, _startPosY.Value + 40, _startPosX.Value + 10, _startPosY.Value + 20);
+ g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 20, _startPosX.Value + 25, _startPosY.Value);
+
+ Point point1 = new Point(_startPosX.Value + 10, _startPosY.Value);
+ Point point3 = new Point(_startPosX.Value + 10, _startPosY.Value + 20);
+ Point point5 = new Point(_startPosX.Value + 30, _startPosY.Value + 10);
+ Point[] curvePoints = { point1, point3, point5 };
+ float tension = 0.8F;
+ g.DrawCurve(pen, curvePoints, tension);
+ }
+
+ _startPosY += 40;
+ base.DrawTransport(g);
+ }
+ }
+}
\ No newline at end of file
diff --git a/WinFormsLabRad1/WinFormsLabRad1/Entities/EntityPlatforma.cs b/WinFormsLabRad1/WinFormsLabRad1/Entities/EntityPlatforma.cs
new file mode 100644
index 0000000..b975455
--- /dev/null
+++ b/WinFormsLabRad1/WinFormsLabRad1/Entities/EntityPlatforma.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WinFormsLabRad1.Entities
+{
+ ///
+ /// Класс-сущность "Платформа(ходовая)"
+ ///
+ public class EntityPlatforma
+ {
+ ///
+ /// Скорость
+ ///
+ 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 EntityPlatforma(int speed, double weight, Color bodyColor)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ }
+ }
+}
diff --git a/WinFormsLabRad1/WinFormsLabRad1/Entities/EntityTankZU.cs b/WinFormsLabRad1/WinFormsLabRad1/Entities/EntityTankZU.cs
new file mode 100644
index 0000000..6b62839
--- /dev/null
+++ b/WinFormsLabRad1/WinFormsLabRad1/Entities/EntityTankZU.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WinFormsLabRad1.Entities
+///
+/// Класс-сущность "ЗУ с башней, с З.О. и Радаром"
+///
+{
+ public class EntityTankZU : EntityPlatforma
+ {
+ public Color AdditionalColor { get; private set; }
+ ///
+ /// Признак (опция) наличия башни
+ ///
+ public bool Bashnya { get; private set; }
+ ///
+ /// Признак (опция) наличия З.О.
+ ///
+ public bool Zenorudie { get; private set; }
+ ///
+ /// Признак (опция) наличия радара
+ ///
+ public bool Radar { get; private set; }
+
+ ///
+ /// Должен быть конструктор наследника
+ ///
+ /// Дополнительный цвет
+ /// Признак наличия обвеса
+ /// Признак наличия антикрыла
+ /// Признак наличия гоночной полосы
+ public EntityTankZU(int speed, double weight, Color bodyColor,
+ Color additionalColor, bool bashnya, bool zenorudie,
+ bool radar) : base (speed, weight, bodyColor)
+ {
+ AdditionalColor = additionalColor;
+ Bashnya = bashnya;
+ Zenorudie = zenorudie;
+ Radar = radar;
+ }
+ }
+}
diff --git a/WinFormsLabRad1/WinFormsLabRad1/EntityTankZU.cs b/WinFormsLabRad1/WinFormsLabRad1/EntityTankZU.cs
deleted file mode 100644
index 3058c8c..0000000
--- a/WinFormsLabRad1/WinFormsLabRad1/EntityTankZU.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace WinFormsLabRad1
-///
-/// Класс-сущность "ЗУ с башней, с З.О. и Радаром"
-///
-{
- public class EntityTankZU
- {
- ///
- /// Скорость
- ///
- public int Speed { get; private set; }
- ///
- /// Вес
- ///
- public double Weight { get; private set; }
- ///
- /// Основной цвет
- ///
- public Color BodyColor { get; private set; }
- ///
- /// Дополнительный цвет (для опциональных элементов)
- ///
- public Color AdditionalColor { get; private set; }
- ///
- /// Признак (опция) наличия башни
- ///
- public bool Bashnya { get; private set; }
- ///
- /// Признак (опция) наличия З.О.
- ///
- public bool Zenorudie { get; private set; }
- ///
- /// Признак (опция) наличия радара
- ///
- public bool Radar { get; private set; }
- ///
- /// Шаг перемещения машины
- ///
- public double Step => Speed * 100 / Weight;
-
- ///
- /// Инициализация полей объекта-класса спортивного автомобиля
- ///
- /// Скорость
- /// Вес автомобиля
- /// Основной цвет
- /// Дополнительный цвет
- /// Признак наличия обвеса
- /// Признак наличия антикрыла
- /// Признак наличия гоночной полосы
- public void Init(int speed,double weight, Color bodyColor,
- Color additionalColor, bool bashnya, bool zenorudie,
- bool radar)
- { Speed = speed;
- Weight = weight;
- BodyColor = bodyColor;
- AdditionalColor = additionalColor;
- Bashnya = bashnya;
- Zenorudie = zenorudie;
- Radar = radar;
- }
- }
-}
diff --git a/WinFormsLabRad1/WinFormsLabRad1/FormTankZU.Designer.cs b/WinFormsLabRad1/WinFormsLabRad1/FormTankZU.Designer.cs
index bc8dd21..efef748 100644
--- a/WinFormsLabRad1/WinFormsLabRad1/FormTankZU.Designer.cs
+++ b/WinFormsLabRad1/WinFormsLabRad1/FormTankZU.Designer.cs
@@ -29,11 +29,12 @@
private void InitializeComponent()
{
pictureBox1 = new PictureBox();
- buttonCreate = new Button();
+ buttonCreateZU = new Button();
buttonLeft = new Button();
buttonRight = new Button();
buttonUp = new Button();
buttonDown = new Button();
+ buttonCreatePlatforma = new Button();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
@@ -47,16 +48,16 @@
pictureBox1.TabIndex = 0;
pictureBox1.TabStop = false;
//
- // buttonCreate
+ // buttonCreateZU
//
- buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
- buttonCreate.Location = new Point(12, 289);
- buttonCreate.Name = "buttonCreate";
- buttonCreate.Size = new Size(102, 23);
- buttonCreate.TabIndex = 1;
- buttonCreate.Text = "Новая машина";
- buttonCreate.UseVisualStyleBackColor = true;
- buttonCreate.Click += buttonCreate_Click_1;
+ buttonCreateZU.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonCreateZU.Location = new Point(12, 289);
+ buttonCreateZU.Name = "buttonCreateZU";
+ buttonCreateZU.Size = new Size(69, 23);
+ buttonCreateZU.TabIndex = 1;
+ buttonCreateZU.Text = "Новая ЗУ";
+ buttonCreateZU.UseVisualStyleBackColor = true;
+ buttonCreateZU.Click += buttonCreate_Click_1;
//
// buttonLeft
//
@@ -106,16 +107,28 @@
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += ButtonMove_Click;
//
+ // buttonCreatePlatforma
+ //
+ buttonCreatePlatforma.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+ buttonCreatePlatforma.Location = new Point(87, 289);
+ buttonCreatePlatforma.Name = "buttonCreatePlatforma";
+ buttonCreatePlatforma.Size = new Size(115, 23);
+ buttonCreatePlatforma.TabIndex = 6;
+ buttonCreatePlatforma.Text = "Новая платформа";
+ buttonCreatePlatforma.UseVisualStyleBackColor = true;
+ buttonCreatePlatforma.Click += buttonCreatePlatforma_Click;
+ //
// FormTankZU
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(874, 324);
+ Controls.Add(buttonCreatePlatforma);
Controls.Add(buttonDown);
Controls.Add(buttonUp);
Controls.Add(buttonRight);
Controls.Add(buttonLeft);
- Controls.Add(buttonCreate);
+ Controls.Add(buttonCreateZU);
Controls.Add(pictureBox1);
Name = "FormTankZU";
StartPosition = FormStartPosition.CenterScreen;
@@ -128,10 +141,11 @@
#endregion
private PictureBox pictureBox1;
- private Button buttonCreate;
+ private Button buttonCreateZU;
private Button buttonLeft;
private Button buttonRight;
private Button buttonUp;
private Button buttonDown;
+ private Button buttonCreatePlatforma;
}
}
\ No newline at end of file
diff --git a/WinFormsLabRad1/WinFormsLabRad1/FormTankZU.cs b/WinFormsLabRad1/WinFormsLabRad1/FormTankZU.cs
index 61884d8..5887b6f 100644
--- a/WinFormsLabRad1/WinFormsLabRad1/FormTankZU.cs
+++ b/WinFormsLabRad1/WinFormsLabRad1/FormTankZU.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using WinFormsLabRad1.Drawnings;
namespace WinFormsLabRad1
{
@@ -18,7 +19,7 @@ namespace WinFormsLabRad1
///
/// Поле-объект для прорисовки объекта
///
- private DrawningTankZU? _drawningTankZU;
+ private DrawningPlatforma? _drawningPlatforma;
///
/// Конструктор формы
///
@@ -32,34 +33,62 @@ namespace WinFormsLabRad1
///
private void Draw()
{
- if (_drawningTankZU == null)
+ if (_drawningPlatforma == null)
{
return;
}
Bitmap bmp = new(pictureBox1.Width, pictureBox1.Height);
Graphics gr = Graphics.FromImage(bmp);
- _drawningTankZU.DrawTransport(gr);
+ _drawningPlatforma.DrawTransport(gr);
pictureBox1.Image = bmp;
}
///
- /// Обработка нажатия кнопки "Создать"
+ /// Создание объекта класса-перемещения
+ ///
+ /// Тип создаваемого объекта
+ private void CreateObject(string type)
+ {
+ Random random = new();
+ switch (type)
+ {
+ case nameof(DrawningPlatforma):
+ _drawningPlatforma = new DrawningPlatforma(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(DrawningTankZU):
+ _drawningPlatforma = new DrawningTankZU(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)), Convert.ToBoolean(random.Next(0, 2)));
+ break;
+ default:
+ return;
+ }
+ _drawningPlatforma.SetPictureSize(pictureBox1.Width, pictureBox1.Height);
+ _drawningPlatforma.SetPosition(random.Next(10, 100), random.Next(10, 100));
+ // _strategy = null;
+ // comboBoxStrategy.Enabled = true;
+ Draw();
+ }
+
+ ///
+ /// Обработка нажатия кнопки "Создать Платформу"
///
///
///
- private void buttonCreate_Click_1(object sender, EventArgs e)
- {
- Random random = new();
- _drawningTankZU = new DrawningTankZU();
- _drawningTankZU.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)), Convert.ToBoolean(random.Next(0, 2)));
- _drawningTankZU.SetPictureSize(pictureBox1.Width, pictureBox1.Height);
- _drawningTankZU.SetPosition(random.Next(10, 100), random.Next(10, 100));
- Draw();
- }
+ private void buttonCreatePlatforma_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlatforma));
+
+
+ ///
+ /// Обработка нажатия кнопки "Создать ЗУ"
+ ///
+ ///
+ ///
+
+ private void buttonCreate_Click_1(object sender, EventArgs e) => CreateObject(nameof(DrawningTankZU));
+
///
/// Перемещение объекта по форме (нажатие кнопок навигации)
@@ -68,7 +97,7 @@ namespace WinFormsLabRad1
///
private void ButtonMove_Click(object sender, EventArgs e)
{
- if (_drawningTankZU == null)
+ if (_drawningPlatforma == null)
{
return;
}
@@ -76,23 +105,24 @@ namespace WinFormsLabRad1
bool result = false;
switch (name)
{
- case "buttonUp":
- result = _drawningTankZU.MoveTransport(DirectionType.Up);
- break;
- case "buttonDown":
- result = _drawningTankZU.MoveTransport(DirectionType.Down);
- break;
- case "buttonLeft":
- result = _drawningTankZU.MoveTransport(DirectionType.Left);
- break;
- case "buttonRight":
- result = _drawningTankZU.MoveTransport(DirectionType.Right);
- break;
+ case "buttonUp":
+ result = _drawningPlatforma.MoveTransport(DirectionType.Up);
+ break;
+ case "buttonDown":
+ result = _drawningPlatforma.MoveTransport(DirectionType.Down);
+ break;
+ case "buttonLeft":
+ result = _drawningPlatforma.MoveTransport(DirectionType.Left);
+ break;
+ case "buttonRight":
+ result = _drawningPlatforma.MoveTransport(DirectionType.Right);
+ break;
}
if (result)
{
Draw();
}
}
+
}
}