diff --git a/ProjectSeaplane/ProjectSeaplane/DirectionType.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DirectionType.cs
similarity index 67%
rename from ProjectSeaplane/ProjectSeaplane/DirectionType.cs
rename to ProjectSeaplane/ProjectSeaplane/Drawnings/DirectionType.cs
index c462152..5bc54ff 100644
--- a/ProjectSeaplane/ProjectSeaplane/DirectionType.cs
+++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DirectionType.cs
@@ -1,4 +1,4 @@
-namespace ProjectSeaplane;
+namespace ProjectSeaplane.Drawnings;
///
/// Направление перемещения
///
@@ -7,24 +7,24 @@ public enum DirectionType
///
/// Вверх
///
-
+
Up = 1,
-
+
///
- /// Вниз
+ /// Вниз
///
-
+
Down = 2,
-
+
///
- /// Влево
- ///
-
+ /// Влево
+ ///
+
Left = 3,
-
+
///
- /// Вправо
- ///
-
+ /// Вправо
+ ///
+
Right = 4,
}
diff --git a/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingBasicSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingBasicSeaplane.cs
new file mode 100644
index 0000000..b0ab4a1
--- /dev/null
+++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingBasicSeaplane.cs
@@ -0,0 +1,261 @@
+using ProjectSeaplane.Entities;
+
+namespace ProjectSeaplane.Drawnings;
+
+public class DrawingBasicSeaplane
+{
+ ///
+ /// Класс-сущность
+ ///
+ public EntityBasicSeaplane? EntityBasicSeaplane { get; private set; }
+
+ ///
+ /// Ширина окна
+ ///
+ private int? _pictureWidth;
+
+ ///
+ /// Высота окна
+ ///
+ private int? _pictureHeight;
+
+ ///
+ /// Левая координата прорисовки автомобиля
+ ///
+ private int? _startPosX;
+
+ ///
+ /// Верхняя кооридната прорисовки автомобиля
+ ///
+ private int? _startPosY;
+
+ ///
+ /// Ширина прорисовки автомобиля
+ ///
+ private readonly int _drawningSeaplaneWidth = 155;
+
+ ///
+ /// Высота прорисовки автомобиля
+ ///
+ private readonly int _drawningSeaplaneHeight = 70;
+
+ ///
+ /// Инициализация свойств
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+
+ public void Init(int speed, double weight, Color bodyColor)
+ {
+ EntityBasicSeaplane = new EntityBasicSeaplane(speed, weight, bodyColor);
+ _pictureWidth = null;
+ _pictureHeight = null;
+ _startPosX = null;
+ _startPosY = null;
+ }
+
+ ///
+ /// Установка границ поля
+ ///
+ /// Ширина поля
+ /// Высота поля
+ /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
+ public bool SetPictureSize(int width, int height)
+ {
+ // TODO проверка, что объект "влезает" в размеры поля
+ // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
+
+ if (_drawningSeaplaneWidth < width && _drawningSeaplaneHeight < height)
+ {
+ _pictureWidth = width;
+ _pictureHeight = height;
+ if (_startPosX != null && _startPosY != null)
+ {
+ if (_startPosX + _drawningSeaplaneWidth > width)
+ {
+ _startPosX = width - (_drawningSeaplaneWidth + 1);
+
+ }
+ if (_startPosY + _drawningSeaplaneWidth > height)
+ {
+ _startPosY = height - (_drawningSeaplaneHeight + 1);
+ }
+
+
+
+ }
+
+ return true;
+
+
+ }
+
+ return false;
+
+
+
+ }
+
+ ///
+ /// Установка позиции
+ ///
+ /// Координата X
+ /// Координата Y
+ public void SetPosition(int x, int y)
+ {
+ if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ {
+ return;
+ }
+
+ // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
+ // то надо изменить координаты, чтобы он оставался в этих границах
+ _startPosX = x;
+ _startPosY = y;
+
+ if (_startPosX < 0)
+ {
+ _startPosX = 0;
+ }
+ if (_startPosY < 0)
+ {
+ _startPosY = 0;
+ }
+ if (_startPosX + _drawningSeaplaneWidth > _pictureWidth)
+ {
+ _startPosX = _pictureWidth - _drawningSeaplaneWidth;
+ }
+ if (_startPosY - _drawningSeaplaneHeight > _pictureHeight)
+ {
+ _startPosY = _pictureHeight - _drawningSeaplaneHeight;
+ }
+ }
+
+ ///
+ /// Изменение направления перемещения
+ ///
+ /// Направление
+ /// true - перемещене выполнено, false - перемещение невозможно
+ public bool MoveTransport(DirectionType direction)
+ {
+ if (EntityBasicSeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return false;
+ }
+
+ switch (direction)
+ {
+ //влево
+ case DirectionType.Left:
+ if (_startPosX.Value - EntityBasicSeaplane.Step > 0)
+ {
+ _startPosX -= (int)EntityBasicSeaplane.Step;
+ }
+ return true;
+ //вверх
+ case DirectionType.Up:
+ if (_startPosY.Value - EntityBasicSeaplane.Step > 0)
+ {
+ _startPosY -= (int)EntityBasicSeaplane.Step;
+ }
+ return true;
+ // вправо
+ case DirectionType.Right:
+
+ if (_startPosX + (int)EntityBasicSeaplane.Step < _pictureWidth - _drawningSeaplaneWidth)
+ {
+ _startPosX += (int)EntityBasicSeaplane.Step;
+ }
+ return true;
+ //вниз
+ case DirectionType.Down:
+
+ if (_startPosY + (int)EntityBasicSeaplane.Step < _pictureHeight - _drawningSeaplaneHeight)
+ {
+ _startPosY += (int)EntityBasicSeaplane.Step;
+ }
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ ///
+ /// Прорисовка объекта
+ ///
+ ///
+ public void DrawTransport(Graphics g)
+ {
+ if (EntityBasicSeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue)
+ {
+ return;
+ }
+
+ Pen pen = new(Color.Black);
+ Pen penKraya = new(Color.Black, 2);
+
+
+
+ //Начинаем рисовать
+
+
+
+ //Полигон для хвоста
+ Point point1 = new Point(_startPosX.Value, _startPosY.Value);
+ Point point2 = new Point(_startPosX.Value + 35, _startPosY.Value + 35);
+ Point point3 = new Point(_startPosX.Value, _startPosY.Value + 35);
+ Point point4 = new Point(_startPosX.Value, _startPosY.Value);
+ Point[] Hvost =
+ {
+ point1, point2 , point3 , point4
+ };
+ Point point5 = new Point(_startPosX.Value + 50, _startPosY.Value + 22);
+ Point point6 = new Point(_startPosX.Value + 45, _startPosY.Value + 30);
+ Point point7 = new Point(_startPosX.Value + 55, _startPosY.Value + 30);
+ Point point8 = new Point(_startPosX.Value + 50, _startPosY.Value + 22);
+ Point[] Radar =
+ {
+ point5, point6 , point7 , point8
+ };
+
+ //Кисти для основного цвета и дополнительного
+ Brush brBody = new SolidBrush(EntityBasicSeaplane.BodyColor);
+ Brush brBlack = new SolidBrush(Color.Black);
+ Brush brWhity = new SolidBrush(Color.GhostWhite);
+ //Хвост
+ g.FillPolygon(brBody, Hvost);
+ //Тело
+
+
+ g.FillRectangle(brBody, _startPosX.Value + 30, _startPosY.Value + 30, 85, 25);
+
+
+ g.FillEllipse(brBody, _startPosX.Value + 45, _startPosY.Value + 30, 110, 24);
+
+
+ g.FillEllipse(brBody, _startPosX.Value - 5, _startPosY.Value + 30, 100, 24);
+ g.DrawEllipse(penKraya, _startPosX.Value, _startPosY.Value + 27, 17, 6);
+ g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value + 27, 17, 6);
+
+
+
+ //Крыло
+ g.FillEllipse(brBlack, _startPosX.Value + 45, _startPosY.Value + 43, 50, 7);
+
+ //Иллюминаторы
+
+ for (int i = 0; i < 80; i += 10)
+ {
+
+ g.FillEllipse(brWhity, _startPosX.Value + 30 + i, _startPosY.Value + 34, 6, 6);
+
+
+ }
+
+ //Пилоты
+ g.FillEllipse(brWhity, _startPosX.Value + 115, _startPosY.Value + 34, 20, 8);
+
+
+ }
+}
diff --git a/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingSeaplane.cs
similarity index 99%
rename from ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs
rename to ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingSeaplane.cs
index 2ea84ca..ada6ae7 100644
--- a/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs
+++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawingSeaplane.cs
@@ -1,4 +1,6 @@
-namespace ProjectSeaplane;
+using ProjectSeaplane.Entities;
+
+namespace ProjectSeaplane.Drawnings;
///
/// Отрисовка и перемещение
///
@@ -78,14 +80,14 @@ public class DrawingSeaplane
if (_startPosX + _drawningSeaplaneWidth > width)
{
_startPosX = width - (_drawningSeaplaneWidth + 1);
-
+
}
if (_startPosY + _drawningSeaplaneWidth > height)
{
_startPosY = height - (_drawningSeaplaneHeight + 1);
}
-
-
+
+
}
@@ -285,7 +287,7 @@ public class DrawingSeaplane
//Пилоты
g.FillEllipse(brWhity, _startPosX.Value + 115, _startPosY.Value + 34, 20, 8);
-
+
diff --git a/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs
new file mode 100644
index 0000000..39c57fa
--- /dev/null
+++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntityBasicSeaplane.cs
@@ -0,0 +1,41 @@
+namespace ProjectSeaplane.Entities;
+///
+/// Класс-сущность "Простой Гидросамолет"
+///
+public class EntityBasicSeaplane
+{
+ ///
+ /// Скорость
+ ///
+ 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 EntityBasicSeaplane(int speed, double weight, Color bodyColor)
+ {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+
+
+ }
+}
+
diff --git a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs
similarity index 93%
rename from ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs
rename to ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs
index 4a80778..87f94c7 100644
--- a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs
+++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs
@@ -1,4 +1,4 @@
-namespace ProjectSeaplane;
+namespace ProjectSeaplane.Entities;
///
/// Класс-сущность Гидросамолета
///
@@ -27,7 +27,7 @@ public class EntitySeaplane
///
/// Признак наличия радара
///
- public bool Radar { get; private set; }
+ public bool Radar { get; private set; }
///
/// Расстояние шага передвижения
///
@@ -45,10 +45,10 @@ public class EntitySeaplane
{
Speed = speed;
Weight = weight;
- BodyColor = bodyColor;
+ BodyColor = bodyColor;
AdditionalColor = additionalColor;
LandingGear = landingGear;
Radar = radar;
-
+
}
}
diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs
index df68e98..048ddc8 100644
--- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs
+++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs
@@ -1,4 +1,6 @@
-namespace ProjectSeaplane
+using ProjectSeaplane.Drawnings;
+
+namespace ProjectSeaplane
///
/// Форма работы с объектом "Гидросамолет"
///