From bf2857c8ca914741eea7a010cbb87d7a3d6b13fd Mon Sep 17 00:00:00 2001
From: Esenia12 <148366616+Esenia12@users.noreply.github.com>
Date: Thu, 29 Feb 2024 20:20:16 +0400
Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?=
=?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D0=B0=20=E2=84=962?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 3 +
.../ProjectDumpTruck/DirectionType.cs | 30 ---
.../ProjectDumpTruck/DrawningDumpTrack.cs | 221 ------------------
.../ProjectDumpTruck/EntityDumpTruck.cs | 68 ------
4 files changed, 3 insertions(+), 319 deletions(-)
delete mode 100644 ProjectDumpTruck/ProjectDumpTruck/DirectionType.cs
delete mode 100644 ProjectDumpTruck/ProjectDumpTruck/DrawningDumpTrack.cs
delete mode 100644 ProjectDumpTruck/ProjectDumpTruck/EntityDumpTruck.cs
diff --git a/.gitignore b/.gitignore
index ca1c7a3..cc13ce9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -398,3 +398,6 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml
+/ProjectDumpTruck/ProjectDumpTruck/DirectionType.cs
+/ProjectDumpTruck/ProjectDumpTruck/DrawningDumpTrack.cs
+/ProjectDumpTruck/ProjectDumpTruck/EntityDumpTruck.cs
diff --git a/ProjectDumpTruck/ProjectDumpTruck/DirectionType.cs b/ProjectDumpTruck/ProjectDumpTruck/DirectionType.cs
deleted file mode 100644
index 770f543..0000000
--- a/ProjectDumpTruck/ProjectDumpTruck/DirectionType.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-namespace ProjectDumpTruck;
-
-///
-/// Направление перемещения
-///
-public enum DirectionType
-{
- ///
- /// Вверх
- ///
- Up = 1,
-
- ///
- /// Вниз
- ///
- Down = 2,
-
- ///
- /// Влево
- ///
- Left = 3,
-
- ///
- /// Вправо
- ///
- Right = 4
-
-
-}
-
diff --git a/ProjectDumpTruck/ProjectDumpTruck/DrawningDumpTrack.cs b/ProjectDumpTruck/ProjectDumpTruck/DrawningDumpTrack.cs
deleted file mode 100644
index 8a5572e..0000000
--- a/ProjectDumpTruck/ProjectDumpTruck/DrawningDumpTrack.cs
+++ /dev/null
@@ -1,221 +0,0 @@
-namespace ProjectDumpTruck;
-
-///
-/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
-///
-public class DrawningDumpTrack
-{
- ///
- /// Класс-сущность
- ///
- public EntityDumpTruck? EntityDumpTruck { get; private set; }
-
- ///
- /// Ширина окна
- ///
- private int? _pictureWidth;
-
- ///
- /// Высота окна
- ///
- private int? _pictureHeight;
-
- ///
- /// Левая координата прорисовки самосвала
- ///
- private int? _startPosX;
-
- ///
- /// Верхняя координата прорисовки самосвала
- ///
- private int? _startPosY;
-
- ///
- /// Ширина прорисовки самосвала
- ///
- private readonly int _drawningDumpTrackWidth = 130;
-
- ///
- /// Высота прорисовки самосвала
- ///
- private readonly int _drawningDumpTrackHeight = 90;
-
-
-
- ///
- /// Инициализация свойств
- ///
- /// Скорость
- /// Вес
- /// Основной цвет
- /// Дополнительный цвет
- /// Признак наличия кузова
- /// Признак наличия тента
-
-
- public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodywork, bool awning)
- {
- EntityDumpTruck = new EntityDumpTruck();
- EntityDumpTruck.Init(speed, weight, bodyColor, additionalColor, bodywork, awning);
- _pictureWidth = null;
- _pictureHeight = null;
- _startPosX = null;
- _startPosY = null;
- }
-
-
-
-
- ///
- /// Установка границ поля
- ///
- /// Ширина поля
- /// Высота поля
- /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
- public bool SetPictureSize( int width, int height)
- {
- // TODO проверка, что объект "влезает" в размеры поля
- // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
- if (_drawningDumpTrackWidth > width || _drawningDumpTrackHeight > height)
- {
- return false;
- }
-
- _pictureWidth = width;
- _pictureHeight = height;
- return true;
- }
-
- ///
- /// Установка позиции
- ///
- /// Координата X
- /// Координата Y
- public void SetPosition(int x, int y)
- {
- if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
- {
- return;
- }
- // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
- // то надо изменить координаты, чтобы он оставался в этих границах
- if (x + _drawningDumpTrackWidth > _pictureWidth )
- {
- x = (int)_pictureWidth-_drawningDumpTrackWidth;
- }
- if (y + _drawningDumpTrackHeight > _pictureHeight)
- {
- y = (int)_pictureHeight-_drawningDumpTrackHeight;
- }
- if (x < 0)
- {
- x = 0;
- }
- if (y < 0)
- {
- y = 0;
- }
-
- _startPosX = x;
- _startPosY = y;
-
-
- }
- ///
- /// Изменение направления перемещения
- ///
- /// Направление
- /// true - перемещение выполнено, false - перемещение невозможно
- public bool MoveTransport(DirectionType direction)
- {
- if (EntityDumpTruck == null || !_startPosX.HasValue || !_startPosY.HasValue)
- {
- return false;
- }
-
- switch (direction)
- {
- //влево
- case DirectionType.Left:
- if (_startPosX.Value - EntityDumpTruck.Step > 0)
- {
- _startPosX -= (int)EntityDumpTruck.Step;
- }
- return true;
-
- //вверх
- case DirectionType.Up:
- if (_startPosY.Value - EntityDumpTruck.Step > 0)
- {
- _startPosY -= (int)EntityDumpTruck.Step;
- }
- return true;
-
- //вправо
- case DirectionType.Right:
- if (_startPosX.Value + EntityDumpTruck.Step + _drawningDumpTrackWidth < _pictureWidth)
- {
- _startPosX += (int)EntityDumpTruck.Step;
- }
- return true;
-
- //вниз
- case DirectionType.Down:
- if (_startPosY.Value + EntityDumpTruck.Step + _drawningDumpTrackHeight < _pictureHeight)
- {
- _startPosY += (int)EntityDumpTruck.Step;
- }
- return true;
- default:
- return false;
- }
-
- }
-
- public void DrawTransport(Graphics g)
- {
- if (EntityDumpTruck == null || !_startPosX.HasValue || !_startPosY.HasValue)
- {
- return;
- }
-
- Pen pen = new(Color.Black);
- Brush additionalBrush = new SolidBrush(EntityDumpTruck.AdditionalColor);
-
- //Отрисовка основы (кабины водителя и днища)
- Brush body = new SolidBrush(EntityDumpTruck.BodyColor);
- g.FillRectangle(body, _startPosX.Value+100, _startPosY.Value, 30, 35);
- g.FillRectangle(body, _startPosX.Value, _startPosY.Value + 40, 130, 20);
-
- //Отрисовка колёс
- Brush wheels = new SolidBrush(Color.Gray);
- g.FillEllipse(wheels, _startPosX.Value, _startPosY.Value + 60, 30, 30);
- g.FillEllipse(wheels, _startPosX.Value+30, _startPosY.Value + 60, 30, 30);
- g.FillEllipse(wheels, _startPosX.Value+100, _startPosY.Value + 60, 30, 30);
-
- //Отрисовка границ
- Brush border = new SolidBrush(Color.Black);
- g.DrawRectangle(pen, _startPosX.Value+100, _startPosY.Value, 30, 35);
- g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 40, 130, 20);
- g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 60, 30, 30);
- g.DrawEllipse(pen, _startPosX.Value+30, _startPosY.Value + 60, 30, 30);
- g.DrawEllipse(pen, _startPosX.Value+100, _startPosY.Value + 60, 30, 30);
-
- //Отрисовка кузова
- if (EntityDumpTruck.Bodywork)
- {
- g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, 90, 35);
- }
-
- //Отрисовка тента
- if (EntityDumpTruck.Bodywork & EntityDumpTruck.Awning)
- {
- g.FillRectangle(border, _startPosX.Value, _startPosY.Value, 95, 10);
- g.FillRectangle(border, _startPosX.Value, _startPosY.Value, 95, 3);
- g.FillRectangle(border, _startPosX.Value+30, _startPosY.Value, 3, 40);
- g.FillRectangle(border, _startPosX.Value+70, _startPosY.Value, 3, 40);
- }
- }
-
-}
-
diff --git a/ProjectDumpTruck/ProjectDumpTruck/EntityDumpTruck.cs b/ProjectDumpTruck/ProjectDumpTruck/EntityDumpTruck.cs
deleted file mode 100644
index e4370ac..0000000
--- a/ProjectDumpTruck/ProjectDumpTruck/EntityDumpTruck.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-namespace ProjectDumpTruck;
-
-///
-/// Класс-сущность "Самосвал"
-///
-public class EntityDumpTruck
-{
- ///
- /// Скорость
- ///
- 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 Bodywork { get; private set; }
-
- ///
- /// Признак (опция) наличия тента
- ///
- public bool Awning { get; private set; }
-
- ///
- /// Шаг перемещения самосвала
- ///
- public double Step => Speed * 100 / Weight;
-
- ///
- /// Инициализация полей объекта-класса самосвала
- ///
- /// Скорость
- /// Вес
- /// Основной цвет
- /// Дополнительный цвет
- /// Признак наличия кузова
- /// Признак наличия тента
-
- public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodywork, bool awning)
- {
- Speed = speed;
- Weight = weight;
- BodyColor = bodyColor;
- AdditionalColor = additionalColor;
- Bodywork = bodywork;
- Awning = awning;
- }
-
-
-}
-
-
-
-