Compare commits
No commits in common. "6bc2e6f5829091da09e4b8488cc02e5a4adb35be" and "ff7a87438e3994194089c7d49750cd3de82ea01f" have entirely different histories.
6bc2e6f582
...
ff7a87438e
24
LocomativeProject/LocomativeProject/DirectionType.cs
Normal file
24
LocomativeProject/LocomativeProject/DirectionType.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
namespace LocomotiveProject;
|
||||||
|
/// <summary>
|
||||||
|
/// Направление перемещения
|
||||||
|
/// </summary>
|
||||||
|
public enum DirectionType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Вверх
|
||||||
|
/// </summary>
|
||||||
|
Up = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Вниз
|
||||||
|
/// </summary>
|
||||||
|
Down = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// Влево
|
||||||
|
/// </summary>
|
||||||
|
Left = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// Вправо
|
||||||
|
/// </summary>
|
||||||
|
Right = 4
|
||||||
|
}
|
||||||
|
|
@ -1,95 +1,62 @@
|
|||||||
using LocomativeProject.Entities;
|
namespace LocomotiveProject
|
||||||
|
|
||||||
namespace LocomativeProject.Drawnings
|
|
||||||
{
|
{
|
||||||
public class DrawningBaseLocomotive
|
public class DrawningLocomotive
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность
|
/// Класс-сущность
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityBaseLocomotive? _EntityLocomotive { get; protected set; }
|
public EntityLocomotive? EntityLocomotive { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int? _pictureWidth;
|
private int? _pictureWidth;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота окна
|
/// Высота окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int? _pictureHeight;
|
private int? _pictureHeight;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Левая координата прорисовки тепловоза
|
/// Левая координата прорисовки тепловоза
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int? _startPosX;
|
private int? _startPosX;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Верхняя кооридната прорисовки тепловоза
|
/// Верхняя кооридната прорисовки тепловоза
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int? _startPosY;
|
private int? _startPosY;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки тепловоза
|
/// Ширина прорисовки тепловоза
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningBaseLocomotiveWidth = 120;
|
private readonly int _drawningLocomotiveWidth = 120;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки тепловоза
|
/// Высота прорисовки тепловоза
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningBaseLocomotiveHeight = 60;
|
private readonly int _drawningLocomotiveHeight = 60;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Координата X объекта
|
/// Инициализация свойств
|
||||||
/// </summary>
|
|
||||||
public int? GetPosX => _startPosX;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Координата Y объекта
|
|
||||||
/// </summary>
|
|
||||||
public int? GetPosY => _startPosY;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetWidth => _drawningBaseLocomotiveWidth;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetHeight => _drawningBaseLocomotiveHeight;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Пустой конструктор
|
|
||||||
/// </summary>
|
|
||||||
private DrawningBaseLocomotive()
|
|
||||||
{
|
|
||||||
_pictureWidth = null;
|
|
||||||
_pictureHeight = null;
|
|
||||||
_startPosX = null;
|
|
||||||
_startPosY = null;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор базового поезда
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес</param>
|
/// <param name="weight">Вес</param>
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
public DrawningBaseLocomotive(int speed, double weight, Color bodyColor) : this()
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
|
/// <param name="exehaustPipe">Признак наличия трубы</param>
|
||||||
|
/// <param name="fuelCompartment">Признак наличия отсека для топлива</param>
|
||||||
|
/// <param name="wheelCount">Признак количества колес</param>
|
||||||
|
public void Init(int speed, double weight, Color bodyColor, Color
|
||||||
|
additionalColor, bool exehaustPipe, bool fuelCompartment, int wheelCount)
|
||||||
{
|
{
|
||||||
_EntityLocomotive = new EntityBaseLocomotive(speed, weight, bodyColor);
|
EntityLocomotive = new EntityLocomotive();
|
||||||
}
|
EntityLocomotive.Init(speed, weight, bodyColor, additionalColor,
|
||||||
/// <summary>
|
exehaustPipe, fuelCompartment, wheelCount);
|
||||||
/// Конструктор для наследников
|
_pictureWidth = null;
|
||||||
/// </summary>
|
_pictureHeight = null;
|
||||||
/// <param name="drawningLocomotiveWidth">ширина</param>
|
_startPosX = null;
|
||||||
/// <param name="drawningLocomotiveHeight">высота</param>
|
_startPosY = null;
|
||||||
protected DrawningBaseLocomotive(int Width, int Height) : this()
|
|
||||||
{
|
|
||||||
_drawningBaseLocomotiveWidth = Width;
|
|
||||||
_drawningBaseLocomotiveHeight = Height;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка границ поля
|
/// Установка границ поля
|
||||||
@ -100,15 +67,15 @@ namespace LocomativeProject.Drawnings
|
|||||||
///разместить объект в этих размерах</returns>
|
///разместить объект в этих размерах</returns>
|
||||||
public bool SetPictureSize(int width, int height)
|
public bool SetPictureSize(int width, int height)
|
||||||
{
|
{
|
||||||
if (width > _drawningBaseLocomotiveWidth || height > _drawningBaseLocomotiveHeight) // если ширина и высота окна больше чем объект
|
if (width > _drawningLocomotiveWidth || height > _drawningLocomotiveHeight) // если ширина и высота окна больше чем объект
|
||||||
{
|
{
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
if (_startPosX + _drawningBaseLocomotiveWidth > width || _startPosX < 0) // если координаты выходят за пределы, корректируем
|
if (_startPosX + _drawningLocomotiveWidth > width || _startPosX < 0) // если координаты выходят за пределы, корректируем
|
||||||
{
|
{
|
||||||
_startPosX = 0;
|
_startPosX = 0;
|
||||||
}
|
}
|
||||||
if (_startPosY + _drawningBaseLocomotiveHeight > height || _startPosY < 0)
|
if (_startPosY + _drawningLocomotiveHeight > height || _startPosY < 0)
|
||||||
{
|
{
|
||||||
_startPosY = 0;
|
_startPosY = 0;
|
||||||
}
|
}
|
||||||
@ -129,20 +96,20 @@ namespace LocomativeProject.Drawnings
|
|||||||
}
|
}
|
||||||
|
|
||||||
// если все нормально
|
// если все нормально
|
||||||
if (x > 0 || x + _drawningBaseLocomotiveWidth < _pictureWidth)
|
if (x > 0 || x + _drawningLocomotiveWidth < _pictureWidth)
|
||||||
{
|
{
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
}
|
}
|
||||||
if (y > 0 || y + _drawningBaseLocomotiveHeight < _pictureHeight)
|
if (y > 0 || y + _drawningLocomotiveHeight < _pictureHeight)
|
||||||
{
|
{
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
}
|
}
|
||||||
// если не лезет, но мог бы влезть
|
// если не лезет, но мог бы влезть
|
||||||
if (x < 0 || x + _drawningBaseLocomotiveWidth > _pictureWidth)
|
if (x < 0 || x + _drawningLocomotiveWidth > _pictureWidth)
|
||||||
{
|
{
|
||||||
_startPosX = 0;
|
_startPosX = 0;
|
||||||
}
|
}
|
||||||
if (y < 0 || y + _drawningBaseLocomotiveHeight > _pictureHeight)
|
if (y < 0 || y + _drawningLocomotiveHeight > _pictureHeight)
|
||||||
{
|
{
|
||||||
_startPosY = 0;
|
_startPosY = 0;
|
||||||
}
|
}
|
||||||
@ -156,7 +123,7 @@ namespace LocomativeProject.Drawnings
|
|||||||
/// невозможно</returns>
|
/// невозможно</returns>
|
||||||
public bool MoveTransport(DirectionType direction)
|
public bool MoveTransport(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (_EntityLocomotive == null || !_startPosX.HasValue ||
|
if (EntityLocomotive == null || !_startPosX.HasValue ||
|
||||||
!_startPosY.HasValue)
|
!_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -165,30 +132,30 @@ namespace LocomativeProject.Drawnings
|
|||||||
{
|
{
|
||||||
//влево
|
//влево
|
||||||
case DirectionType.Left:
|
case DirectionType.Left:
|
||||||
if (_startPosX.Value - _EntityLocomotive.Step > 0)
|
if (_startPosX.Value - EntityLocomotive.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosX -= (int)_EntityLocomotive.Step;
|
_startPosX -= (int)EntityLocomotive.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
//вверх
|
//вверх
|
||||||
case DirectionType.Up:
|
case DirectionType.Up:
|
||||||
if (_startPosY.Value - _EntityLocomotive.Step > 0)
|
if (_startPosY.Value - EntityLocomotive.Step > 0) // 10 – высота трубы
|
||||||
{
|
{
|
||||||
_startPosY -= (int)_EntityLocomotive.Step;
|
_startPosY -= (int)EntityLocomotive.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
// вправо
|
// вправо
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
if (_startPosX.Value + _drawningBaseLocomotiveWidth + _EntityLocomotive.Step < _pictureWidth)
|
if (_startPosX.Value + _drawningLocomotiveWidth + EntityLocomotive.Step < _pictureWidth)
|
||||||
{
|
{
|
||||||
_startPosX += (int)_EntityLocomotive.Step;
|
_startPosX += (int)EntityLocomotive.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
//вниз
|
//вниз
|
||||||
case DirectionType.Down:
|
case DirectionType.Down:
|
||||||
if (_startPosY.Value + _drawningBaseLocomotiveHeight + _EntityLocomotive.Step < _pictureHeight)
|
if (_startPosY.Value + _drawningLocomotiveHeight + EntityLocomotive.Step < _pictureHeight)
|
||||||
{
|
{
|
||||||
_startPosY += (int)_EntityLocomotive.Step;
|
_startPosY += (int)EntityLocomotive.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
@ -222,14 +189,15 @@ namespace LocomativeProject.Drawnings
|
|||||||
/// Прорисовка объекта
|
/// Прорисовка объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
public virtual void DrawTransport(Graphics g)
|
public void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (_EntityLocomotive == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityLocomotive == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush bodyBrush = new SolidBrush(_EntityLocomotive.BodyColor);
|
Brush additionalBrush = new SolidBrush(EntityLocomotive.AdditionalColor);
|
||||||
|
Brush bodyBrush = new SolidBrush(EntityLocomotive.BodyColor);
|
||||||
Brush blackBrush = new SolidBrush(Color.Black);
|
Brush blackBrush = new SolidBrush(Color.Black);
|
||||||
Brush whiteBrush = new SolidBrush(Color.White);
|
Brush whiteBrush = new SolidBrush(Color.White);
|
||||||
//границы тепловоза
|
//границы тепловоза
|
||||||
@ -239,6 +207,7 @@ namespace LocomativeProject.Drawnings
|
|||||||
_startPosX.Value + 115, _startPosY.Value + 20 + 10,
|
_startPosX.Value + 115, _startPosY.Value + 20 + 10,
|
||||||
_startPosX.Value + 5, _startPosY.Value + 20 + 10
|
_startPosX.Value + 5, _startPosY.Value + 20 + 10
|
||||||
);
|
);
|
||||||
|
g.FillRectangle(additionalBrush, _startPosX.Value + 5, _startPosY.Value + +10 + 20, 110, 20);
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 20 + 10, 110, 20);
|
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 20 + 10, 110, 20);
|
||||||
g.FillRectangle(blackBrush, _startPosX.Value, _startPosY.Value + 5 + 10, 5, 30);
|
g.FillRectangle(blackBrush, _startPosX.Value, _startPosY.Value + 5 + 10, 5, 30);
|
||||||
//шасси
|
//шасси
|
||||||
@ -271,6 +240,20 @@ namespace LocomativeProject.Drawnings
|
|||||||
g.DrawRectangle(pen, _startPosX.Value + 85, _startPosY.Value + 5 + 10, 10, 10);
|
g.DrawRectangle(pen, _startPosX.Value + 85, _startPosY.Value + 5 + 10, 10, 10);
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value + 5 + 10, 10, 10);
|
g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value + 5 + 10, 10, 10);
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 5 + 10, 10, 10);
|
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 5 + 10, 10, 10);
|
||||||
|
//труба
|
||||||
|
if (EntityLocomotive.ExehaustPipe)
|
||||||
|
{
|
||||||
|
Brush greyBrush = new SolidBrush(Color.Gray);
|
||||||
|
g.FillRectangle(greyBrush, _startPosX.Value + 80, _startPosY.Value, 5, 10);
|
||||||
|
g.DrawRectangle(pen, _startPosX.Value + 80, _startPosY.Value, 5, 10);
|
||||||
}
|
}
|
||||||
|
// отсек для топлива
|
||||||
|
if (EntityLocomotive.FuelCompartment)
|
||||||
|
{
|
||||||
|
g.FillRectangle(bodyBrush, _startPosX.Value + 25, _startPosY.Value + 10 + 10, 10, 20);
|
||||||
|
g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value + 10 + 10, 10, 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,29 +0,0 @@
|
|||||||
namespace LocomativeProject.Drawnings
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Направление перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum DirectionType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Неизвестное направление
|
|
||||||
/// </summary>
|
|
||||||
Unknow = -1,
|
|
||||||
/// <summary>
|
|
||||||
/// Вверх
|
|
||||||
/// </summary>
|
|
||||||
Up = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// Вниз
|
|
||||||
/// </summary>
|
|
||||||
Down,
|
|
||||||
/// <summary>
|
|
||||||
/// Влево
|
|
||||||
/// </summary>
|
|
||||||
Left,
|
|
||||||
/// <summary>
|
|
||||||
/// Вправо
|
|
||||||
/// </summary>
|
|
||||||
Right
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
using LocomativeProject.Drawnings;
|
|
||||||
using LocomotiveProject.Entities;
|
|
||||||
|
|
||||||
namespace LocomotiveProject.Drawnings
|
|
||||||
{
|
|
||||||
public class DrawningLocomotive : DrawningBaseLocomotive
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес тепловоза</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="exehaustPipe">Признак наличия трубы</param>
|
|
||||||
/// <param name="fuelCompartment">Признак наличия топливного отсека</param>
|
|
||||||
public DrawningLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool exehaustPipe, bool fuelCompartment) : base(120, 60)
|
|
||||||
{
|
|
||||||
_EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor, additionalColor, exehaustPipe, fuelCompartment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (_EntityLocomotive == null || _EntityLocomotive is not EntityLocomotive entityLocomotive || !_startPosX.HasValue || !_startPosY.HasValue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Brush additionalBrush = new SolidBrush(entityLocomotive.AdditionalColor);
|
|
||||||
Brush bodyBrush = new SolidBrush(entityLocomotive.BodyColor);
|
|
||||||
//Brush blackBrush = new SolidBrush(Color.Black);
|
|
||||||
//Brush whiteBrush = new SolidBrush(Color.White);
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX.Value + 5, _startPosY.Value + +10 + 20, 110, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 20 + 10, 110, 20);
|
|
||||||
base.DrawTransport(g);
|
|
||||||
if (entityLocomotive.ExehaustPipe)
|
|
||||||
{
|
|
||||||
Brush greyBrush = new SolidBrush(Color.Gray);
|
|
||||||
g.FillRectangle(greyBrush, _startPosX.Value + 80, _startPosY.Value, 5, 10);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 80, _startPosY.Value, 5, 10);
|
|
||||||
}
|
|
||||||
// отсек для топлива
|
|
||||||
if (entityLocomotive.FuelCompartment)
|
|
||||||
{
|
|
||||||
g.FillRectangle(bodyBrush, _startPosX.Value + 25, _startPosY.Value + 10 + 10, 10, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value + 10 + 10, 10, 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
namespace LocomativeProject.Entities
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность базовый тепловоз
|
|
||||||
/// </summary>
|
|
||||||
public class EntityBaseLocomotive
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Скорость
|
|
||||||
/// </summary>
|
|
||||||
public int Speed { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Вес
|
|
||||||
/// </summary>
|
|
||||||
public double Weight { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Основной цвет
|
|
||||||
/// </summary>
|
|
||||||
public Color BodyColor { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения тепловоза
|
|
||||||
/// </summary>
|
|
||||||
public double Step => Speed * 100 / Weight;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес тепловоза</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
public EntityBaseLocomotive(int speed, double weight, Color bodyColor)
|
|
||||||
{
|
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
using LocomativeProject.Entities;
|
|
||||||
|
|
||||||
namespace LocomotiveProject.Entities
|
|
||||||
{
|
|
||||||
public class EntityLocomotive : EntityBaseLocomotive
|
|
||||||
{
|
|
||||||
public Color AdditionalColor { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Признак (опция) наличие трубы
|
|
||||||
/// </summary>
|
|
||||||
public bool ExehaustPipe { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Признак (опция) наличие топливного отсека
|
|
||||||
/// </summary>
|
|
||||||
public bool FuelCompartment { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор сущности
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес тепловоза</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="exehaustPipe">Признак наличия трубы</param>
|
|
||||||
/// <param name="fuelCompartment">Признак наличия топливного отсека</param>
|
|
||||||
public EntityLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool exehaustPipe, bool fuelCompartment) : base(speed, weight, bodyColor)
|
|
||||||
{
|
|
||||||
AdditionalColor = additionalColor;
|
|
||||||
ExehaustPipe = exehaustPipe;
|
|
||||||
FuelCompartment = fuelCompartment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
60
LocomativeProject/LocomativeProject/EntityLocomotive.cs
Normal file
60
LocomativeProject/LocomativeProject/EntityLocomotive.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
namespace LocomotiveProject
|
||||||
|
{
|
||||||
|
public class EntityLocomotive
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Скорость
|
||||||
|
/// </summary>
|
||||||
|
public int Speed { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Вес
|
||||||
|
/// </summary>
|
||||||
|
public double Weight { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Основной цвет
|
||||||
|
/// </summary>
|
||||||
|
public Color BodyColor { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Дополнительный цвет (для опциональных элементов)
|
||||||
|
/// </summary>
|
||||||
|
public Color AdditionalColor { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Признак (опция) наличие трубы
|
||||||
|
/// </summary>
|
||||||
|
public bool ExehaustPipe { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Признак (опция) наличие топливного отсека
|
||||||
|
/// </summary>
|
||||||
|
public bool FuelCompartment { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Признак количество колес
|
||||||
|
/// </summary>
|
||||||
|
public int WheelCount { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Шаг перемещения тепловоза
|
||||||
|
/// </summary>
|
||||||
|
public double Step => Speed * 100 / Weight;
|
||||||
|
/// <summary>
|
||||||
|
/// Инициализация полей объекта-класса тепловоз
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес тепловоза</param>
|
||||||
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
|
/// <param name="exehaustPipe">Признак наличия трубы</param>
|
||||||
|
/// <param name="fuelCompartment">Признак наличия топливного отсека</param>
|
||||||
|
/// <param name="wheelCount">Признак количества колес</param>
|
||||||
|
public void Init(int speed, double weight, Color bodyColor, Color
|
||||||
|
additionalColor, bool exehaustPipe, bool fuelCompartment, int wheelCount)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
|
ExehaustPipe = exehaustPipe;
|
||||||
|
FuelCompartment = fuelCompartment;
|
||||||
|
WheelCount = wheelCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -29,164 +29,120 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LocomotiveProject));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LocomotiveProject));
|
||||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
pictureBox1 = new PictureBox();
|
||||||
this.pictureBoxLocomotive = new System.Windows.Forms.PictureBox();
|
pictureBoxLocomotive = new PictureBox();
|
||||||
this.buttonCreateBaseLocomotive = new System.Windows.Forms.Button();
|
create = new Button();
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
buttonUp = new Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
buttonDown = new Button();
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
buttonLeft = new Button();
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
buttonRight = new Button();
|
||||||
this.buttonCreateLocomotive = new System.Windows.Forms.Button();
|
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||||
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).BeginInit();
|
||||||
this.buttonStrategyStep = new System.Windows.Forms.Button();
|
SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
//
|
||||||
// pictureBox1
|
// pictureBox1
|
||||||
//
|
//
|
||||||
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
|
pictureBox1.Location = new Point(0, 0);
|
||||||
this.pictureBox1.Name = "pictureBox1";
|
pictureBox1.Name = "pictureBox1";
|
||||||
this.pictureBox1.Size = new System.Drawing.Size(100, 50);
|
pictureBox1.Size = new Size(100, 50);
|
||||||
this.pictureBox1.TabIndex = 0;
|
pictureBox1.TabIndex = 0;
|
||||||
this.pictureBox1.TabStop = false;
|
pictureBox1.TabStop = false;
|
||||||
//
|
//
|
||||||
// pictureBoxLocomotive
|
// pictureBoxLocomotive
|
||||||
//
|
//
|
||||||
this.pictureBoxLocomotive.Dock = System.Windows.Forms.DockStyle.Fill;
|
pictureBoxLocomotive.Dock = DockStyle.Fill;
|
||||||
this.pictureBoxLocomotive.Location = new System.Drawing.Point(0, 0);
|
pictureBoxLocomotive.Location = new Point(0, 0);
|
||||||
this.pictureBoxLocomotive.Name = "pictureBoxLocomotive";
|
pictureBoxLocomotive.Name = "pictureBoxLocomotive";
|
||||||
this.pictureBoxLocomotive.Size = new System.Drawing.Size(800, 450);
|
pictureBoxLocomotive.Size = new Size(800, 450);
|
||||||
this.pictureBoxLocomotive.TabIndex = 1;
|
pictureBoxLocomotive.TabIndex = 1;
|
||||||
this.pictureBoxLocomotive.TabStop = false;
|
pictureBoxLocomotive.TabStop = false;
|
||||||
//
|
//
|
||||||
// buttonCreateBaseLocomotive
|
// create
|
||||||
//
|
//
|
||||||
this.buttonCreateBaseLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
create.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
this.buttonCreateBaseLocomotive.Location = new System.Drawing.Point(12, 415);
|
create.Location = new Point(12, 415);
|
||||||
this.buttonCreateBaseLocomotive.Name = "buttonCreateBaseLocomotive";
|
create.Name = "create";
|
||||||
this.buttonCreateBaseLocomotive.Size = new System.Drawing.Size(171, 23);
|
create.Size = new Size(75, 23);
|
||||||
this.buttonCreateBaseLocomotive.TabIndex = 2;
|
create.TabIndex = 2;
|
||||||
this.buttonCreateBaseLocomotive.Text = "создать обычный поезд";
|
create.Text = "создать";
|
||||||
this.buttonCreateBaseLocomotive.UseVisualStyleBackColor = true;
|
create.UseVisualStyleBackColor = true;
|
||||||
this.buttonCreateBaseLocomotive.Click += new System.EventHandler(this.ButtonCreateBaseLocomotive_Click);
|
create.Click += create_Click;
|
||||||
//
|
//
|
||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
this.buttonUp.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonUp.BackgroundImage")));
|
buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
this.buttonUp.Location = new System.Drawing.Point(691, 362);
|
buttonUp.Location = new Point(691, 362);
|
||||||
this.buttonUp.Name = "buttonUp";
|
buttonUp.Name = "buttonUp";
|
||||||
this.buttonUp.Size = new System.Drawing.Size(35, 35);
|
buttonUp.Size = new Size(35, 35);
|
||||||
this.buttonUp.TabIndex = 3;
|
buttonUp.TabIndex = 3;
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
buttonUp.UseVisualStyleBackColor = true;
|
||||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
buttonUp.Click += ButtonMove_Click;
|
||||||
//
|
//
|
||||||
// buttonDown
|
// buttonDown
|
||||||
//
|
//
|
||||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
this.buttonDown.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonDown.BackgroundImage")));
|
buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
this.buttonDown.Location = new System.Drawing.Point(691, 403);
|
buttonDown.Location = new Point(691, 403);
|
||||||
this.buttonDown.Name = "buttonDown";
|
buttonDown.Name = "buttonDown";
|
||||||
this.buttonDown.Size = new System.Drawing.Size(35, 35);
|
buttonDown.Size = new Size(35, 35);
|
||||||
this.buttonDown.TabIndex = 4;
|
buttonDown.TabIndex = 4;
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
buttonDown.Click += ButtonMove_Click;
|
||||||
//
|
//
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
this.buttonLeft.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonLeft.BackgroundImage")));
|
buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage");
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(650, 403);
|
buttonLeft.Location = new Point(650, 403);
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
buttonLeft.Name = "buttonLeft";
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(35, 35);
|
buttonLeft.Size = new Size(35, 35);
|
||||||
this.buttonLeft.TabIndex = 5;
|
buttonLeft.TabIndex = 5;
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
buttonLeft.UseVisualStyleBackColor = true;
|
||||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
buttonLeft.Click += ButtonMove_Click;
|
||||||
//
|
//
|
||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
this.buttonRight.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonRight.BackgroundImage")));
|
buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
this.buttonRight.Location = new System.Drawing.Point(732, 403);
|
buttonRight.Location = new Point(732, 403);
|
||||||
this.buttonRight.Name = "buttonRight";
|
buttonRight.Name = "buttonRight";
|
||||||
this.buttonRight.Size = new System.Drawing.Size(35, 35);
|
buttonRight.Size = new Size(35, 35);
|
||||||
this.buttonRight.TabIndex = 6;
|
buttonRight.TabIndex = 6;
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
buttonRight.UseVisualStyleBackColor = true;
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
buttonRight.Click += ButtonMove_Click;
|
||||||
//
|
|
||||||
// buttonCreateLocomotive
|
|
||||||
//
|
|
||||||
this.buttonCreateLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
|
||||||
this.buttonCreateLocomotive.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
|
||||||
this.buttonCreateLocomotive.Location = new System.Drawing.Point(189, 415);
|
|
||||||
this.buttonCreateLocomotive.Name = "buttonCreateLocomotive";
|
|
||||||
this.buttonCreateLocomotive.Size = new System.Drawing.Size(173, 23);
|
|
||||||
this.buttonCreateLocomotive.TabIndex = 7;
|
|
||||||
this.buttonCreateLocomotive.Text = "создать продвинутый поезд";
|
|
||||||
this.buttonCreateLocomotive.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateLocomotive.Click += new System.EventHandler(this.ButtonCreateLocomotive_Click);
|
|
||||||
//
|
|
||||||
// comboBox1
|
|
||||||
//
|
|
||||||
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.comboBox1.FormattingEnabled = true;
|
|
||||||
this.comboBox1.Items.AddRange(new object[] {
|
|
||||||
"К центру",
|
|
||||||
"К краю"});
|
|
||||||
this.comboBox1.Location = new System.Drawing.Point(667, 12);
|
|
||||||
this.comboBox1.Name = "comboBox1";
|
|
||||||
this.comboBox1.Size = new System.Drawing.Size(121, 23);
|
|
||||||
this.comboBox1.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// buttonStrategyStep
|
|
||||||
//
|
|
||||||
this.buttonStrategyStep.Location = new System.Drawing.Point(713, 41);
|
|
||||||
this.buttonStrategyStep.Name = "buttonStrategyStep";
|
|
||||||
this.buttonStrategyStep.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.buttonStrategyStep.TabIndex = 9;
|
|
||||||
this.buttonStrategyStep.Text = "Шаг";
|
|
||||||
this.buttonStrategyStep.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonStrategyStep.Click += new System.EventHandler(this.buttonStrategyStep_Click);
|
|
||||||
//
|
//
|
||||||
// LocomotiveProject
|
// LocomotiveProject
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
this.Controls.Add(this.buttonStrategyStep);
|
Controls.Add(buttonRight);
|
||||||
this.Controls.Add(this.comboBox1);
|
Controls.Add(buttonLeft);
|
||||||
this.Controls.Add(this.buttonCreateLocomotive);
|
Controls.Add(buttonDown);
|
||||||
this.Controls.Add(this.buttonRight);
|
Controls.Add(buttonUp);
|
||||||
this.Controls.Add(this.buttonLeft);
|
Controls.Add(create);
|
||||||
this.Controls.Add(this.buttonDown);
|
Controls.Add(pictureBoxLocomotive);
|
||||||
this.Controls.Add(this.buttonUp);
|
Controls.Add(pictureBox1);
|
||||||
this.Controls.Add(this.buttonCreateBaseLocomotive);
|
Name = "LocomotiveProject";
|
||||||
this.Controls.Add(this.pictureBoxLocomotive);
|
Text = "Тепловоз";
|
||||||
this.Controls.Add(this.pictureBox1);
|
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||||
this.Name = "LocomotiveProject";
|
((System.ComponentModel.ISupportInitialize)pictureBoxLocomotive).EndInit();
|
||||||
this.Text = "Тепловоз";
|
ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private PictureBox pictureBox1;
|
private PictureBox pictureBox1;
|
||||||
private PictureBox pictureBoxLocomotive;
|
private PictureBox pictureBoxLocomotive;
|
||||||
private Button buttonCreateBaseLocomotive;
|
private Button create;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonCreateLocomotive;
|
|
||||||
private ComboBox comboBox1;
|
|
||||||
private Button buttonStrategyStep;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,23 +8,16 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using LocomotiveProject.Entities;
|
|
||||||
using LocomativeProject.Drawnings;
|
|
||||||
using LocomotiveProject.Drawnings;
|
|
||||||
using LocomativeProject.MovementStrategy;
|
|
||||||
|
|
||||||
namespace LocomativeProject
|
namespace LocomativeProject
|
||||||
{
|
{
|
||||||
public partial class LocomotiveProject : Form
|
public partial class LocomotiveProject : Form
|
||||||
{
|
{
|
||||||
private DrawningBaseLocomotive? _drawningLocomotive;
|
private DrawningLocomotive? _drawningLocomotive;
|
||||||
|
|
||||||
private AbstractStrategy? _strategy;
|
|
||||||
|
|
||||||
public LocomotiveProject()
|
public LocomotiveProject()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_strategy = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Draw()
|
private void Draw()
|
||||||
@ -39,52 +32,30 @@ namespace LocomativeProject
|
|||||||
pictureBoxLocomotive.Image = bmp;
|
pictureBoxLocomotive.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание объекта класса-перемещения
|
/// Обработка нажатия кнопки "Создать"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type">Тип создаваемого объекта</param>
|
/// <param name="sender"></param>
|
||||||
private void CreateObject(string type)
|
/// <param name="e"></param>
|
||||||
|
private void create_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new();
|
Random random = new();
|
||||||
switch (type)
|
_drawningLocomotive = new DrawningLocomotive();
|
||||||
{
|
_drawningLocomotive.Init
|
||||||
case nameof(DrawningBaseLocomotive):
|
(
|
||||||
_drawningLocomotive = new DrawningBaseLocomotive(random.Next(100, 300), random.Next(1000, 3000),
|
random.Next(100, 300),
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
random.Next(1000, 3000),
|
||||||
break;
|
|
||||||
case nameof(DrawningLocomotive):
|
|
||||||
_drawningLocomotive = new DrawningLocomotive(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)),
|
||||||
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;
|
Convert.ToBoolean(random.Next(0, 2)),
|
||||||
default:
|
random.Next(2, 6)
|
||||||
return;
|
);
|
||||||
}
|
|
||||||
|
|
||||||
_drawningLocomotive.SetPictureSize(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
_drawningLocomotive.SetPictureSize(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
||||||
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
_strategy = null;
|
|
||||||
comboBox1.Enabled = true;
|
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Создать базовый поезд"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreateBaseLocomotive_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBaseLocomotive));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Создать продвинутый поезд"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreateLocomotive_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLocomotive));
|
|
||||||
|
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawningLocomotive == null)
|
if (_drawningLocomotive == null)
|
||||||
@ -114,47 +85,5 @@ namespace LocomativeProject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void buttonStrategyStep_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningLocomotive == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (comboBox1.Enabled)
|
|
||||||
{
|
|
||||||
_strategy = comboBox1.SelectedIndex switch
|
|
||||||
{
|
|
||||||
0 => new MoveToCenter(),
|
|
||||||
1 => new MoveToBorder(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_strategy.SetData(new MoveableLocomotive(_drawningLocomotive), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
comboBox1.Enabled = false;
|
|
||||||
_strategy.MakeStep();
|
|
||||||
Draw();
|
|
||||||
|
|
||||||
if (_strategy.GetStatus() == StrategyStatus.Finish)
|
|
||||||
{
|
|
||||||
comboBox1.Enabled = true;
|
|
||||||
_strategy = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,64 @@
|
|||||||
<root>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
@ -468,7 +528,7 @@
|
|||||||
<data name="buttonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="buttonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||||
vAAADrwBlbxySQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAABq4SURBVHhe7d1X
|
vQAADr0BR/uQrQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAABq4SURBVHhe7d1X
|
||||||
0F1lvcfxAOMMioCAQbBhL9jBgqKCXcCC0WgsGFSMElIgBEgU4+g4OuOV114w44W3inKBBSxYsEdFRQWj
|
0F1lvcfxAOMMioCAQbBhL9jBgqKCXcCC0WgsGFSMElIgBEgU4+g4OuOV114w44W3inKBBSxYsEdFRQWj
|
||||||
YAkaFYMFQcjyeZKlIcmTt+z3v/deaz2fz8z3cI5Jdlkvx/9vHI9nUQMAVMcAAIAKGQAAUCEDAAAqZAAA
|
YAkaFYMFQcjyeZKlIcmTt+z3v/deaz2fz8z3cI5Jdlkvx/9vHI9nUQMAVMcAAIAKGQAAUCEDAAAqZAAA
|
||||||
QIUMAACokAEAABUyAACgQgYAAFTIAACAChkAAFAhAwAAKmQAAECFDAAAqJABAAAVMgAAoEIGAABUyAAA
|
QIUMAACokAEAABUyAACgQgYAAFTIAACAChkAAFAhAwAAKmQAAECFDAAAqJABAAAVMgAAoEIGAABUyAAA
|
||||||
|
@ -1,140 +0,0 @@
|
|||||||
namespace LocomativeProject.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-стратегия перемещения объекта
|
|
||||||
/// </summary>
|
|
||||||
public abstract class AbstractStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещаемый объект
|
|
||||||
/// </summary>
|
|
||||||
private IMoveableObject? _moveableObject;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Статус перемещения
|
|
||||||
/// </summary>
|
|
||||||
private StrategyStatus _state = StrategyStatus.NotInit;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина поля
|
|
||||||
/// </summary>
|
|
||||||
protected int FieldWidth { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота поля
|
|
||||||
/// </summary>
|
|
||||||
protected int FieldHeight { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение статуса перемещения
|
|
||||||
/// </summary
|
|
||||||
public StrategyStatus GetStatus() { return _state; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Установка данных
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="moveableObject">Перемещаемый объект</param>
|
|
||||||
/// <param name="width">Ширина поля</param>
|
|
||||||
/// <param name="height">Высота поля</param>
|
|
||||||
public void SetData(IMoveableObject moveableObject, int width, int height)
|
|
||||||
{
|
|
||||||
if (moveableObject == null)
|
|
||||||
{
|
|
||||||
_state = StrategyStatus.NotInit;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_state = StrategyStatus.InProgress;
|
|
||||||
_moveableObject = moveableObject;
|
|
||||||
FieldWidth = width;
|
|
||||||
FieldHeight = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения
|
|
||||||
/// </summary>
|
|
||||||
public void MakeStep()
|
|
||||||
{
|
|
||||||
if (_state != StrategyStatus.InProgress)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsTargetDestinaion())
|
|
||||||
{
|
|
||||||
_state = StrategyStatus.Finish;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MoveToTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение влево
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveLeft() => MoveTo(MovementDirection.Left);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вправо
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveRight() => MoveTo(MovementDirection.Right);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вверх
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveUp() => MoveTo(MovementDirection.Up);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вниз
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveDown() => MoveTo(MovementDirection.Down);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Параметры объекта
|
|
||||||
/// </summary>
|
|
||||||
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected int? GetStep()
|
|
||||||
{
|
|
||||||
if (_state != StrategyStatus.InProgress)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return _moveableObject?.GetStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение к цели
|
|
||||||
/// </summary>
|
|
||||||
protected abstract void MoveToTarget();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Достигнута ли цель
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected abstract bool IsTargetDestinaion();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Попытка перемещения в требуемом направлении
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="movementDirection">Направление</param>
|
|
||||||
/// <returns>Результат попытки (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
private bool MoveTo(MovementDirection movementDirection)
|
|
||||||
{
|
|
||||||
if (_state != StrategyStatus.InProgress)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _moveableObject?.TryMoveObject(movementDirection) ?? false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
namespace LocomativeProject.MovementStrategy;
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс для работы с перемещаемым объектом
|
|
||||||
/// </summary>
|
|
||||||
public interface IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Получение координаты объекта
|
|
||||||
/// </summary>
|
|
||||||
ObjectParameters? GetObjectPosition { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
int GetStep { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Попытка переместить объект в указанном направлении
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
/// <returns>true - объект перемещен, false - перемещение невозможно</returns>
|
|
||||||
bool TryMoveObject(MovementDirection direction);
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LocomativeProject.MovementStrategy;
|
|
||||||
|
|
||||||
public class MoveToBorder : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
ObjectParameters? objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return objParams.RightBorder - GetStep() <= FieldWidth && objParams.DownBorder - GetStep() < FieldHeight &&
|
|
||||||
objParams.RightBorder + GetStep() >= FieldWidth && objParams.DownBorder + GetStep() >= FieldHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void MoveToTarget()
|
|
||||||
{
|
|
||||||
ObjectParameters? objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (objParams.RightBorder + GetStep() <= FieldWidth)
|
|
||||||
{
|
|
||||||
MoveRight();
|
|
||||||
}
|
|
||||||
if (objParams.DownBorder + GetStep() <= FieldHeight)
|
|
||||||
{
|
|
||||||
MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
|||||||
namespace LocomativeProject.MovementStrategy;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Стратегия перемещения объекта в центр экрана
|
|
||||||
/// </summary>
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
using LocomativeProject.Drawnings;
|
|
||||||
namespace LocomativeProject.MovementStrategy;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-реализация IMoveableObject с использованием DrawningLocomotive
|
|
||||||
/// </summary>
|
|
||||||
public class MoveableLocomotive : IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Поле-объект класса DrawningBaseLocomotive или его наследника
|
|
||||||
/// </summary>
|
|
||||||
private readonly DrawningBaseLocomotive? _locomotive = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="_locomotive">Объект класса DrawningBaseLocomotive</param>
|
|
||||||
public MoveableLocomotive(DrawningBaseLocomotive locomotive)
|
|
||||||
{
|
|
||||||
_locomotive = locomotive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObjectParameters? GetObjectPosition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_locomotive == null || _locomotive._EntityLocomotive == null || !_locomotive.GetPosX.HasValue || !_locomotive.GetPosY.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ObjectParameters(_locomotive.GetPosX.Value, _locomotive.GetPosY.Value, _locomotive.GetWidth, _locomotive.GetHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetStep => (int)(_locomotive?._EntityLocomotive?.Step ?? 0);
|
|
||||||
|
|
||||||
public bool TryMoveObject(MovementDirection direction)
|
|
||||||
{
|
|
||||||
if (_locomotive == null || _locomotive._EntityLocomotive == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _locomotive.MoveTransport(GetDirectionType(direction));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конвертация из MovementDirection в DirectionType
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">MovementDirection</param>
|
|
||||||
/// <returns>DirectionType</returns>
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
namespace LocomativeProject.MovementStrategy;
|
|
||||||
/// <summary>
|
|
||||||
/// Направление перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum MovementDirection : byte
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Вверх
|
|
||||||
/// </summary>
|
|
||||||
Up = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вниз
|
|
||||||
/// </summary>
|
|
||||||
Down,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Влево
|
|
||||||
/// </summary>
|
|
||||||
Left,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вправо
|
|
||||||
/// </summary>
|
|
||||||
Right
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
namespace LocomativeProject.MovementStrategy;
|
|
||||||
/// <summary>
|
|
||||||
/// Параметры-координаты объекта
|
|
||||||
/// </summary>
|
|
||||||
public class ObjectParameters
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Координата X
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _x;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Координата Y
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _y;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина объекта
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _width;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота объекта
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _height;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Левая граница
|
|
||||||
/// </summary>
|
|
||||||
public int LeftBorder => _x;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Верхняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int TopBorder => _y;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Правая граница
|
|
||||||
/// </summary>
|
|
||||||
public int RightBorder => _x + _width;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Нижняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int DownBorder => _y + _height;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleVertical => _y + _height / 2;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
/// <param name="width">Ширина объекта</param>
|
|
||||||
/// <param name="height">Высота объекта</param>
|
|
||||||
public ObjectParameters(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
_x = x;
|
|
||||||
_y = y;
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
namespace LocomativeProject.MovementStrategy;
|
|
||||||
/// <summary>
|
|
||||||
/// Статус выполнения операции перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum StrategyStatus
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Все готово к началу
|
|
||||||
/// </summary>
|
|
||||||
NotInit,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Выполняется
|
|
||||||
/// </summary>
|
|
||||||
InProgress,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Завершено
|
|
||||||
/// </summary>
|
|
||||||
Finish
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user