diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavarorBodyKits.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavarorBodyKits.cs
new file mode 100644
index 0000000..7271fda
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/DrawningExcavarorBodyKits.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ProjectExcavator.Entities;
+
+namespace ProjectExcavator.DrawningObjects
+{
+ public class DrawningExcavarorBodyKits : DrawningExcavator
+ {
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия обвеса
+ /// Признак наличия антикрыла
+ /// Ширина картинки
+ /// Высота картинки
+ public DrawningExcavarorBodyKits(int speed, double weight,
+ Color bodyColor, Color additionalColor,
+ bool bodyKit, bool bucket,
+ int width, int height) :
+ base(speed, weight, bodyColor, width, height, 110, 60)
+ {
+ if(EntityExcavator != null)
+ {
+ EntityExcavator = new EntityExcavatorBodyKits(speed, weight,
+ bodyColor, additionalColor, bodyKit, bucket);
+ }
+ }
+ public override void DrawTransport(Graphics g)
+ {
+ if(EntityExcavator is not EntityExcavatorBodyKits excavator)
+ {
+ return;
+ }
+ Pen pen = new(Color.Black);
+ Brush additionalBrush = new SolidBrush(excavator.AdditionalColor);
+ //ыспомогательные опоры
+ if (excavator.BodyKit)
+ {
+
+ }
+ base.DrawTransport(g);
+ //ковш
+ if (excavator.Bucket)
+ {
+ Point[] pointsBacket = {
+ new Point(_startPosX + 150, _startPosY + 75),
+ new Point(_startPosX + 150, _startPosY + 135),
+ new Point(_startPosX + 195, _startPosY + 135),
+ };
+ g.FillPolygon(additionalBrush, pointsBacket);
+ g.DrawPolygon(pen, pointsBacket);
+ }
+ }
+ }
+}
diff --git a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs
index 6a25801..93f9f08 100644
--- a/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs
+++ b/ProjectExcavator/ProjectExcavator/DrawningExcavator.cs
@@ -1,17 +1,18 @@
-using System;
+using ProjectExcavator.Entities;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace ProjectExcavator
+namespace ProjectExcavator.DrawningObjects
{
- internal class DrawningExcavator
+ public class DrawningExcavator
{
///
/// Класс-сущность
///
- public EntityExcavator? EntityExcavator { get; private set; }
+ public EntityExcavator? EntityExcavator { get; protected set; }
///
/// Ширина окна
///
@@ -31,32 +32,48 @@ namespace ProjectExcavator
///
/// Ширина прорисовки автомобиля
///
- private readonly int _excavatorWidth = 190;
+ private readonly int _excavatorWidth = 100;
///
/// Высота прорисовки автомобиля
///
- private readonly int _excavatorHeight = 170;
+ private readonly int _excavatorHeight = 55;
///
- /// Инициализация свойств
+ /// Конструктор
///
/// Скорость
/// Вес
- /// Цвет кузова
- /// Дополнительный цвет
- /// Признак наличия вспомогательных опор
- /// Признак наличия ковша
+ /// Основной цвет
/// Ширина картинки
/// Высота картинки
- /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах
- public bool Init(int speed, double weight, Color bodyColor, Color
- additionalColor, bool bodyKit, bool backet, int width, int height)
+ public DrawningExcavator(int speed, double weight, Color bodyColor, int
+ width, int height)
{
// TODO: Продумать проверки
_pictureWidth = width;
_pictureHeight = height;
- EntityExcavator = new EntityExcavator();
- EntityExcavator.Init(speed, weight, bodyColor, additionalColor, bodyKit, backet);
- return true;
+ EntityExcavator = new EntityExcavator(speed, weight, bodyColor);
+ }
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Ширина картинки
+ /// Высота картинки
+ /// Ширина прорисовки автомобиля
+ /// Высота прорисовки автомобиля
+ protected DrawningExcavator(int speed, double weight,
+ Color bodyColor,
+ int width, int height,
+ int excavatorWidth, int excavatorHeight)
+ {
+ // TODO: Продумать проверки
+ _pictureWidth = width;
+ _pictureHeight = height;
+ _excavatorWidth = excavatorWidth;
+ _excavatorHeight = excavatorHeight;
+ EntityExcavator = new EntityExcavator(speed, weight, bodyColor);
}
///
/// Установка позиции
@@ -68,8 +85,6 @@ namespace ProjectExcavator
// TODO: Изменение x, y
_startPosX = x;
_startPosY = y;
-
-
}
///
/// Изменение направления перемещения
@@ -92,7 +107,7 @@ namespace ProjectExcavator
break;
//вверх
case DirectionType.Up:
- if (_startPosY - EntityExcavator.Step > -50)
+ if (_startPosY - EntityExcavator.Step > 0)
{
_startPosY -= (int)EntityExcavator.Step;
}
@@ -117,20 +132,13 @@ namespace ProjectExcavator
/// Прорисовка объекта
///
///
- public void DrawTransport(Graphics g)
+ public virtual void DrawTransport(Graphics g)
{
if (EntityExcavator == null)
{
return;
}
Pen pen = new(Color.Black);
-
- Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor);
- if (EntityExcavator.BodyKit)
- {
- g.FillRectangle(additionalBrush, _startPosX + 20, _startPosY + 120, 130, 10);
- g.DrawLine(pen, _startPosX + 20, _startPosY + 120, _startPosX + 150, _startPosY + 120);
- }
//корпус
Brush bodyBrush = new SolidBrush(Color.Red);
g.FillRectangle(bodyBrush, _startPosX + 20, _startPosY + 110, 130, 20);
@@ -156,17 +164,7 @@ namespace ProjectExcavator
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 130, 20, 20);
g.DrawEllipse(pen, _startPosX + 100, _startPosY + 130, 20, 20);
g.DrawEllipse(pen, _startPosX + 120, _startPosY + 130, 20, 20);
- //ковш
- if (EntityExcavator.Backet)
- {
- Point[] pointsBacket = {
- new Point(_startPosX + 150, _startPosY + 75),
- new Point(_startPosX + 150, _startPosY + 135),
- new Point(_startPosX + 195, _startPosY + 135),
- };
- g.FillPolygon(additionalBrush, pointsBacket);
- g.DrawPolygon(pen, pointsBacket);
- }
+
}
}
}
diff --git a/ProjectExcavator/ProjectExcavator/EntityExcavator.cs b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs
index 6189140..a6fa8de 100644
--- a/ProjectExcavator/ProjectExcavator/EntityExcavator.cs
+++ b/ProjectExcavator/ProjectExcavator/EntityExcavator.cs
@@ -4,11 +4,11 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace ProjectExcavator
+namespace ProjectExcavator.Entities
{
- internal class EntityExcavator
+ public class EntityExcavator
{
- //
+ ///
/// Скорость
///
public int Speed { get; private set; }
@@ -20,42 +20,21 @@ namespace ProjectExcavator
/// Основной цвет
///
public Color BodyColor { get; private set; }
- ///
- /// Дополнительный цвет (для опциональных элементов)
- ///
- public Color AdditionalColor { get; private set; }
- ///
- /// Признак (опция) наличия вспомогательных опор
- ///
- public bool BodyKit { get; private set; }
- ///
- /// Признак (опция) наличия ковша
- ///
- public bool Backet { get; private set; }
-
///
/// Шаг перемещения автомобиля
///
public double Step => (double)Speed * 100 / Weight;
///
- /// Инициализация полей объекта-класса спортивного автомобиля
+ /// Конструктор с параметрами
///
/// Скорость
/// Вес автомобиля
/// Основной цвет
- /// Дополнительный цвет
- /// Признак наличия обвеса
- /// Признак наличия антикрыла
-
- public void Init(int speed, double weight, Color bodyColor, Color
- additionalColor, bool bodyKit, bool backet)
+ public EntityExcavator(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
- AdditionalColor = additionalColor;
- BodyKit = bodyKit;
- Backet = backet;
}
}
}
diff --git a/ProjectExcavator/ProjectExcavator/EntityExcavatorBodyKits.cs b/ProjectExcavator/ProjectExcavator/EntityExcavatorBodyKits.cs
new file mode 100644
index 0000000..a93f8ba
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/EntityExcavatorBodyKits.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.NetworkInformation;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectExcavator.Entities
+{
+ ///
+ /// Класс-сущность "Спортивный автомобиль"
+ ///
+ public class EntityExcavatorBodyKits : EntityExcavator
+ {
+ ///
+ /// Дополнительный цвет (для опциональных элементов)
+ ///
+ public Color AdditionalColor { get; private set; }
+ ///
+ /// признак наличия вспомогательных опор
+ ///
+ public bool BodyKit { get; private set; }
+ ///
+ /// Признак (опция) наличия ковша
+ ///
+ public bool Bucket { get; private set; }
+ ///
+ /// Инициализация полей объекта-класса экскаватора
+ ///
+ /// Скорость
+ /// Вес экскаватора
+ /// Основной цвет
+ /// Дополнительный цвет
+ /// Признак наличия обвеса
+ /// Признак наличия ковша
+ public EntityExcavatorBodyKits(int speed, double weight,
+ Color bodyColor, Color additionalColor,
+ bool bodyKit, bool bucket)
+ {
+
+ AdditionalColor = additionalColor;
+ BodyKit = bodyKit;
+ Bucket = bucket;
+ }
+
+ }
+}