Compare commits
No commits in common. "75a051074ff28e9bafb2a56a5564a75da068ad49" and "dc7b7be31e74a9f78ac02b1d369c052721f1354d" have entirely different histories.
75a051074f
...
dc7b7be31e
@ -1,13 +1,9 @@
|
|||||||
namespace ProjectWarmlyShip.Drawnings;
|
namespace ProjectWarmlyShip;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Направления при перемещении
|
/// Направления при перемещении
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum DirectionType
|
public enum DirectionType
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Неизвестное направление
|
|
||||||
/// </summary>
|
|
||||||
Unknow = -1,
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вверх
|
/// Вверх
|
||||||
/// </summary>
|
/// </summary>
|
@ -1,13 +1,11 @@
|
|||||||
using ProjectWarmlyShip.Entities;
|
namespace ProjectWarmlyShip;
|
||||||
|
|
||||||
namespace ProjectWarmlyShip.Drawnings;
|
public class DrawningWarmlyShip
|
||||||
|
|
||||||
public class DrawningShip
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность
|
/// Класс-сущность
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityShip? EntityShip { get; protected set; }
|
public EntityWarmlyShip? EntityWarmlyShip { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
@ -22,66 +20,40 @@ public class DrawningShip
|
|||||||
/// <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 _drawningShipWidth = 150;
|
private readonly int _drawningShipWidth = 150;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки
|
/// Высота прорисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int _drawningShipHeight = 80;
|
private int _drawningShipHeight = 140;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Координаты Х
|
/// Инициализация свойств
|
||||||
/// </summary>
|
|
||||||
public int? GetPosX => _startPosX;
|
|
||||||
/// <summary>
|
|
||||||
/// Координтаы У
|
|
||||||
/// </summary>
|
|
||||||
public int? GetPosY => _startPosY;
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetWidht => _drawningShipWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetHeight => _drawningShipHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Пустой конструктор
|
|
||||||
/// </summary>
|
|
||||||
private DrawningShip()
|
|
||||||
{
|
|
||||||
_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 DrawningShip(int speed, double weight, Color bodycolor) : this()
|
/// <param name="additionalcolor"></param>
|
||||||
|
/// <param name="shpipipes"></param>
|
||||||
|
/// <param name="fueltank"></param>
|
||||||
|
public void Init(int speed, double weight, Color bodycolor, Color additionalcolor, bool shpipipes, bool fueltank)
|
||||||
{
|
{
|
||||||
EntityShip = new EntityShip(speed, weight, bodycolor);
|
EntityWarmlyShip = new EntityWarmlyShip();
|
||||||
}
|
EntityWarmlyShip.Init(speed, weight, bodycolor, additionalcolor, shpipipes, fueltank);
|
||||||
/// <summary>
|
_pictureWidth = null;
|
||||||
/// Конструктор для наследования
|
_pictureHeight = null;
|
||||||
/// </summary>
|
_startPosX = null;
|
||||||
/// <param name="_drawningShipWidth"></param>
|
_startPosY = null;
|
||||||
/// <param name="_drawnShipHeight"></param>
|
|
||||||
protected DrawningShip(int _drawningShipWidth, int _drawnShipHeight) : this()
|
|
||||||
{
|
|
||||||
this._drawningShipWidth= _drawningShipWidth;
|
|
||||||
this._drawningShipHeight = _drawnShipHeight;
|
|
||||||
}
|
}
|
||||||
public bool SetPictureSize(int width, int height)
|
public bool SetPictureSize(int width, int height)
|
||||||
{
|
{
|
||||||
@ -133,7 +105,7 @@ public class DrawningShip
|
|||||||
}
|
}
|
||||||
public bool MoveTransport(DirectionType direction)
|
public bool MoveTransport(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityShip == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityWarmlyShip == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -141,32 +113,32 @@ public class DrawningShip
|
|||||||
{
|
{
|
||||||
//влево
|
//влево
|
||||||
case DirectionType.Left:
|
case DirectionType.Left:
|
||||||
if (_startPosX.Value - EntityShip.Step > 0)
|
if (_startPosX.Value - EntityWarmlyShip.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosX -= (int)EntityShip.Step;
|
_startPosX -= (int)EntityWarmlyShip.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
//вверх
|
//вверх
|
||||||
case DirectionType.Up:
|
case DirectionType.Up:
|
||||||
if (_startPosY.Value - EntityShip.Step > 0)
|
if (_startPosY.Value - EntityWarmlyShip.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosY -= (int)EntityShip.Step;
|
_startPosY -= (int)EntityWarmlyShip.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
// вправо
|
// вправо
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
if (_startPosX.Value + _drawningShipWidth + EntityShip.Step < _pictureWidth)
|
if (_startPosX.Value + _drawningShipWidth + EntityWarmlyShip.Step < _pictureWidth)
|
||||||
{
|
{
|
||||||
_startPosX += (int)EntityShip.Step;
|
_startPosX += (int)EntityWarmlyShip.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
//вниз
|
//вниз
|
||||||
case DirectionType.Down:
|
case DirectionType.Down:
|
||||||
if (_startPosY.Value + _drawningShipHeight + EntityShip.Step < _pictureHeight)
|
if (_startPosY.Value + _drawningShipHeight + EntityWarmlyShip.Step < _pictureHeight)
|
||||||
{
|
{
|
||||||
_startPosY += (int)EntityShip.Step;
|
_startPosY += (int)EntityWarmlyShip.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -175,24 +147,58 @@ public class DrawningShip
|
|||||||
/// Отрисовка объекта
|
/// Отрисовка объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
public virtual void DrawTransport(Graphics g)
|
public void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityShip == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityWarmlyShip == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black, 5);
|
Pen pen = new(Color.Black , 5);
|
||||||
//надстройка
|
|
||||||
Brush brush = new SolidBrush(EntityShip.BodyColor);
|
|
||||||
g.FillRectangle(brush, _startPosX.Value + 30, _startPosY.Value, 100, 30);
|
|
||||||
//корпус
|
|
||||||
g.FillPolygon(brush, new Point[]
|
|
||||||
{
|
|
||||||
new Point(_startPosX.Value,_startPosY.Value + 30), new Point(_startPosX.Value + 150, _startPosY.Value + 30),
|
|
||||||
new Point(_startPosX.Value + 150, _startPosY.Value + 30), new Point(_startPosX.Value + 120,_startPosY.Value + 80),
|
|
||||||
new Point(_startPosX.Value + 120,_startPosY.Value + 80), new Point(_startPosX.Value + 30,_startPosY.Value + 80),
|
|
||||||
new Point(_startPosX.Value + 30,_startPosY.Value + 80), new Point(_startPosX.Value,_startPosY.Value + 30),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//трубы
|
||||||
|
Brush brush = new SolidBrush(EntityWarmlyShip.AdditionalColor);
|
||||||
|
if (EntityWarmlyShip.ShipPipes)
|
||||||
|
{
|
||||||
|
g.FillRectangle(brush, _startPosX.Value + 70, _startPosY.Value, 12, 60);
|
||||||
|
g.FillRectangle(brush, _startPosX.Value + 90, _startPosY.Value, 12, 60);
|
||||||
|
//надстройка
|
||||||
|
brush = new SolidBrush(EntityWarmlyShip.BodyColor);
|
||||||
|
g.FillRectangle(brush, _startPosX.Value + 30, _startPosY.Value + 60, 100, 30);
|
||||||
|
//корпус
|
||||||
|
g.FillPolygon(brush, new Point[]
|
||||||
|
{
|
||||||
|
new Point(_startPosX.Value,_startPosY.Value + 90), new Point(_startPosX.Value + 150, _startPosY.Value + 90),
|
||||||
|
new Point(_startPosX.Value + 150, _startPosY.Value + 90), new Point(_startPosX.Value + 120,_startPosY.Value + 140),
|
||||||
|
new Point(_startPosX.Value + 120,_startPosY.Value + 140), new Point(_startPosX.Value + 30,_startPosY.Value + 140),
|
||||||
|
new Point(_startPosX.Value + 30,_startPosY.Value + 140), new Point(_startPosX.Value,_startPosY.Value + 90),
|
||||||
|
});
|
||||||
|
_drawningShipHeight = 140;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//надстройка
|
||||||
|
brush = new SolidBrush(EntityWarmlyShip.BodyColor);
|
||||||
|
g.FillRectangle(brush, _startPosX.Value + 30, _startPosY.Value, 100, 30);
|
||||||
|
//корпус
|
||||||
|
g.FillPolygon(brush, new Point[]
|
||||||
|
{
|
||||||
|
new Point(_startPosX.Value,_startPosY.Value + 30), new Point(_startPosX.Value + 150, _startPosY.Value + 30),
|
||||||
|
new Point(_startPosX.Value + 150, _startPosY.Value + 30), new Point(_startPosX.Value + 120,_startPosY.Value + 80),
|
||||||
|
new Point(_startPosX.Value + 120,_startPosY.Value + 80), new Point(_startPosX.Value + 30,_startPosY.Value + 80),
|
||||||
|
new Point(_startPosX.Value + 30,_startPosY.Value + 80), new Point(_startPosX.Value,_startPosY.Value + 30),
|
||||||
|
});
|
||||||
|
_drawningShipHeight = 80;
|
||||||
|
}
|
||||||
|
//топливный бак
|
||||||
|
if (EntityWarmlyShip.FuelTank)
|
||||||
|
{
|
||||||
|
brush = new SolidBrush(EntityWarmlyShip.AdditionalColor);
|
||||||
|
if (EntityWarmlyShip.ShipPipes)
|
||||||
|
g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 120, 70, 10);
|
||||||
|
else
|
||||||
|
g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 60, 70, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,50 +0,0 @@
|
|||||||
using ProjectWarmlyShip.Entities;
|
|
||||||
|
|
||||||
namespace ProjectWarmlyShip.Drawnings;
|
|
||||||
|
|
||||||
public class DrawningWarmlyShip : DrawningShip
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность
|
|
||||||
/// </summary>
|
|
||||||
public EntityWarmlyShip? EntityWarmlyShip { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="additionalcolor"></param>
|
|
||||||
/// <param name="shpipipes"></param>
|
|
||||||
/// <param name="fueltank"></param>
|
|
||||||
public DrawningWarmlyShip(int speed, double weight, Color bodycolor, Color additionalcolor, bool shpipipes, bool fueltank) : base(150,80)
|
|
||||||
{
|
|
||||||
EntityShip = new EntityWarmlyShip(speed, weight, bodycolor, additionalcolor, shpipipes, fueltank); //дописать конструктор
|
|
||||||
}
|
|
||||||
public override void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
//оператор is совместимость объекта с заданным типом
|
|
||||||
if (EntityShip == null || EntityShip is not EntityWarmlyShip warmlyship || !_startPosX.HasValue || !_startPosY.HasValue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Brush brush = new SolidBrush(warmlyship.AdditionalColor);
|
|
||||||
if (warmlyship.ShipPipes)
|
|
||||||
{
|
|
||||||
_drawningShipHeight = 140;
|
|
||||||
g.FillRectangle(brush, _startPosX.Value + 70, _startPosY.Value, 12, 60);
|
|
||||||
g.FillRectangle(brush, _startPosX.Value + 90, _startPosY.Value, 12, 60);
|
|
||||||
_startPosY += 60;
|
|
||||||
}
|
|
||||||
base.DrawTransport(g);
|
|
||||||
if (warmlyship.FuelTank)
|
|
||||||
{
|
|
||||||
//if (EntityWarmlyShip.ShipPipes)
|
|
||||||
//{
|
|
||||||
// g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 120, 70, 10);
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
// g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 60, 70, 10);
|
|
||||||
g.FillRectangle(brush, _startPosX.Value + 40, _startPosY.Value + 60, 70, 10);
|
|
||||||
}
|
|
||||||
if (warmlyship.ShipPipes) _startPosY -= 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
namespace ProjectWarmlyShip.Entities;
|
|
||||||
|
|
||||||
public class EntityShip
|
|
||||||
{
|
|
||||||
/// <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 EntityShip(int speed, double weight, Color bodycolor)
|
|
||||||
{
|
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodycolor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
|||||||
namespace ProjectWarmlyShip.Entities;
|
|
||||||
|
|
||||||
public class EntityWarmlyShip : EntityShip
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Дополнительтный цвет
|
|
||||||
/// </summary>
|
|
||||||
public Color AdditionalColor { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Признак наличия труб
|
|
||||||
/// </summary>
|
|
||||||
public bool ShipPipes { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Признак наличия топливного бака
|
|
||||||
/// </summary>
|
|
||||||
public bool FuelTank { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Инициализация полей класса EntityWarmlyShip
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="additionalcolor"></param>
|
|
||||||
/// <param name="shpipipes"></param>
|
|
||||||
/// <param name="fueltank"></param>
|
|
||||||
public EntityWarmlyShip(int speed, double weight, Color bodycolor, Color additionalcolor, bool shpipipes, bool fueltank) : base(speed, weight, bodycolor)
|
|
||||||
{
|
|
||||||
AdditionalColor = additionalcolor;
|
|
||||||
ShipPipes = shpipipes;
|
|
||||||
FuelTank = fueltank;
|
|
||||||
}
|
|
||||||
}
|
|
51
ProjectWarmlyShip/ProjectWarmlyShip/EntityWarmlyShip.cs
Normal file
51
ProjectWarmlyShip/ProjectWarmlyShip/EntityWarmlyShip.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
namespace ProjectWarmlyShip;
|
||||||
|
|
||||||
|
public class EntityWarmlyShip
|
||||||
|
{
|
||||||
|
/// <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 ShipPipes { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Признак наличия топливного бака
|
||||||
|
/// </summary>
|
||||||
|
public bool FuelTank { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Шаг перемещения судна
|
||||||
|
/// </summary>
|
||||||
|
public double Step => Speed * 100 / Weight;
|
||||||
|
/// <summary>
|
||||||
|
/// Инициализация полей класса WarmlyShip
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed"></param>
|
||||||
|
/// <param name="weight"></param>
|
||||||
|
/// <param name="bodycolor"></param>
|
||||||
|
/// <param name="additionalcolor"></param>
|
||||||
|
/// <param name="shpipipes"></param>
|
||||||
|
/// <param name="fueltank"></param>
|
||||||
|
public void Init(int speed, double weight, Color bodycolor, Color additionalcolor, bool shpipipes, bool fueltank)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodycolor;
|
||||||
|
AdditionalColor = additionalcolor;
|
||||||
|
ShipPipes = shpipipes;
|
||||||
|
FuelTank = fueltank;
|
||||||
|
}
|
||||||
|
}
|
@ -34,9 +34,6 @@
|
|||||||
buttonRight = new Button();
|
buttonRight = new Button();
|
||||||
buttonLeft = new Button();
|
buttonLeft = new Button();
|
||||||
buttonDown = new Button();
|
buttonDown = new Button();
|
||||||
buttonСreateShip = new Button();
|
|
||||||
comboBoxStrategy = new ComboBox();
|
|
||||||
buttonStrategyStep = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxWarmlyShip).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxWarmlyShip).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -58,9 +55,9 @@
|
|||||||
buttonCreate.ForeColor = SystemColors.ControlText;
|
buttonCreate.ForeColor = SystemColors.ControlText;
|
||||||
buttonCreate.Location = new Point(12, 331);
|
buttonCreate.Location = new Point(12, 331);
|
||||||
buttonCreate.Name = "buttonCreate";
|
buttonCreate.Name = "buttonCreate";
|
||||||
buttonCreate.Size = new Size(118, 23);
|
buttonCreate.Size = new Size(75, 23);
|
||||||
buttonCreate.TabIndex = 1;
|
buttonCreate.TabIndex = 1;
|
||||||
buttonCreate.Text = "Создать теплоход";
|
buttonCreate.Text = "Создать";
|
||||||
buttonCreate.UseVisualStyleBackColor = false;
|
buttonCreate.UseVisualStyleBackColor = false;
|
||||||
buttonCreate.Click += ButtonCreate_Click;
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
//
|
//
|
||||||
@ -112,48 +109,11 @@
|
|||||||
buttonDown.UseVisualStyleBackColor = true;
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
buttonDown.Click += ButtonMove_Click;
|
buttonDown.Click += ButtonMove_Click;
|
||||||
//
|
//
|
||||||
// buttonСreateShip
|
|
||||||
//
|
|
||||||
buttonСreateShip.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonСreateShip.BackColor = SystemColors.ButtonHighlight;
|
|
||||||
buttonСreateShip.Cursor = Cursors.IBeam;
|
|
||||||
buttonСreateShip.ForeColor = SystemColors.ControlText;
|
|
||||||
buttonСreateShip.Location = new Point(146, 331);
|
|
||||||
buttonСreateShip.Name = "buttonСreateShip";
|
|
||||||
buttonСreateShip.Size = new Size(118, 23);
|
|
||||||
buttonСreateShip.TabIndex = 6;
|
|
||||||
buttonСreateShip.Text = "Создать судно";
|
|
||||||
buttonСreateShip.UseVisualStyleBackColor = false;
|
|
||||||
buttonСreateShip.Click += buttonСreateShip_Click;
|
|
||||||
//
|
|
||||||
// comboBoxStrategy
|
|
||||||
//
|
|
||||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxStrategy.FormattingEnabled = true;
|
|
||||||
comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
|
|
||||||
comboBoxStrategy.Location = new Point(685, 12);
|
|
||||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
|
||||||
comboBoxStrategy.Size = new Size(133, 23);
|
|
||||||
comboBoxStrategy.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonStrategyStep
|
|
||||||
//
|
|
||||||
buttonStrategyStep.Location = new Point(732, 41);
|
|
||||||
buttonStrategyStep.Name = "buttonStrategyStep";
|
|
||||||
buttonStrategyStep.Size = new Size(86, 23);
|
|
||||||
buttonStrategyStep.TabIndex = 8;
|
|
||||||
buttonStrategyStep.Text = "Шаг";
|
|
||||||
buttonStrategyStep.UseVisualStyleBackColor = true;
|
|
||||||
buttonStrategyStep.Click += buttonStrategyStep_Click;
|
|
||||||
//
|
|
||||||
// FormWarmlyShip
|
// FormWarmlyShip
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(830, 366);
|
ClientSize = new Size(830, 366);
|
||||||
Controls.Add(buttonStrategyStep);
|
|
||||||
Controls.Add(comboBoxStrategy);
|
|
||||||
Controls.Add(buttonСreateShip);
|
|
||||||
Controls.Add(buttonDown);
|
Controls.Add(buttonDown);
|
||||||
Controls.Add(buttonLeft);
|
Controls.Add(buttonLeft);
|
||||||
Controls.Add(buttonRight);
|
Controls.Add(buttonRight);
|
||||||
@ -175,8 +135,5 @@
|
|||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonСreateShip;
|
|
||||||
private ComboBox comboBoxStrategy;
|
|
||||||
private Button buttonStrategyStep;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,66 +1,31 @@
|
|||||||
using ProjectWarmlyShip.Drawnings;
|
namespace ProjectWarmlyShip
|
||||||
using ProjectWarmlyShip.MovementStrategy;
|
|
||||||
|
|
||||||
namespace ProjectWarmlyShip
|
|
||||||
{
|
{
|
||||||
public partial class FormWarmlyShip : Form
|
public partial class FormWarmlyShip : Form
|
||||||
{
|
{
|
||||||
private DrawningShip? _drawningShip;
|
private DrawningWarmlyShip? _drawningWarmlyShip;
|
||||||
private AbstractStrategy? _strategy;
|
|
||||||
public FormWarmlyShip()
|
public FormWarmlyShip()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_strategy = null;
|
|
||||||
}
|
}
|
||||||
private void CreateObject(string type)
|
|
||||||
{
|
|
||||||
Random random = new Random();
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case nameof(DrawningShip):
|
|
||||||
_drawningShip = new DrawningShip(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(DrawningWarmlyShip):
|
|
||||||
_drawningShip = new DrawningWarmlyShip(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)));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_drawningShip.SetPictureSize(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
|
|
||||||
_drawningShip.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
_strategy = null;
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_drawningShip.DrawTransport(gr);
|
|
||||||
pictureBoxWarmlyShip.Image = bmp;
|
|
||||||
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Кнопка создания теплохода
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CreateObject(nameof(DrawningWarmlyShip));
|
Random random = new();
|
||||||
}
|
_drawningWarmlyShip = new DrawningWarmlyShip();
|
||||||
/// <summary>
|
_drawningWarmlyShip.Init(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
/// Кнопка создания судна
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
/// </summary>
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
/// <param name="sender"></param>
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||||
/// <param name="e"></param>
|
_drawningWarmlyShip.SetPictureSize(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
|
||||||
private void buttonСreateShip_Click(object sender, EventArgs e)
|
_drawningWarmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
{
|
|
||||||
CreateObject(nameof(DrawningShip));
|
Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_drawningWarmlyShip.DrawTransport(gr);
|
||||||
|
pictureBoxWarmlyShip.Image = bmp;
|
||||||
}
|
}
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawningShip == null)
|
if (_drawningWarmlyShip == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -69,63 +34,27 @@ namespace ProjectWarmlyShip
|
|||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case "buttonUp":
|
case "buttonUp":
|
||||||
result = _drawningShip.MoveTransport(DirectionType.Up);
|
result = _drawningWarmlyShip.MoveTransport(DirectionType.Up);
|
||||||
break;
|
break;
|
||||||
case "buttonDown":
|
case "buttonDown":
|
||||||
result = _drawningShip.MoveTransport(DirectionType.Down);
|
result = _drawningWarmlyShip.MoveTransport(DirectionType.Down);
|
||||||
break;
|
break;
|
||||||
case "buttonLeft":
|
case "buttonLeft":
|
||||||
result = _drawningShip.MoveTransport(DirectionType.Left);
|
result = _drawningWarmlyShip.MoveTransport(DirectionType.Left);
|
||||||
break;
|
break;
|
||||||
case "buttonRight":
|
case "buttonRight":
|
||||||
result = _drawningShip.MoveTransport(DirectionType.Right);
|
result = _drawningWarmlyShip.MoveTransport(DirectionType.Right);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
|
Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
_drawningShip.DrawTransport(gr);
|
_drawningWarmlyShip.DrawTransport(gr);
|
||||||
pictureBoxWarmlyShip.Image = bmp;
|
pictureBoxWarmlyShip.Image = bmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void buttonStrategyStep_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningShip == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxStrategy.Enabled)
|
|
||||||
{
|
|
||||||
_strategy = comboBoxStrategy.SelectedIndex switch
|
|
||||||
{
|
|
||||||
0 => new MoveToCenter(),
|
|
||||||
1 => new MoveToBorder(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_strategy.SetData(new MoveableShip(_drawningShip),
|
|
||||||
pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
|
|
||||||
}
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
_strategy.MakeStep();
|
|
||||||
Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_drawningShip.DrawTransport(gr);
|
|
||||||
pictureBoxWarmlyShip.Image = bmp;
|
|
||||||
if (_strategy.GetStatus == StrategyStatus.Finish)
|
|
||||||
{
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
_strategy = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
namespace ProjectWarmlyShip.MovementStrategy;
|
|
||||||
|
|
||||||
public abstract class AbstractStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещаемый объект
|
|
||||||
/// </summary>
|
|
||||||
private IMoveableObjects? _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 {get { return _state; }}
|
|
||||||
/// <summary>
|
|
||||||
/// Установка данных
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="moveableObjects"></param>
|
|
||||||
/// <param name="width"></param>
|
|
||||||
/// <param name="height"></param>
|
|
||||||
public void SetData(IMoveableObjects moveableObjects, int width, int height)
|
|
||||||
{
|
|
||||||
if (moveableObjects == null)
|
|
||||||
{
|
|
||||||
_state = StrategyStatus.NotInit;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_state = StrategyStatus.InProgress;
|
|
||||||
_moveableObject = moveableObjects;
|
|
||||||
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,17 +0,0 @@
|
|||||||
namespace ProjectWarmlyShip.MovementStrategy;
|
|
||||||
|
|
||||||
public interface IMoveableObjects
|
|
||||||
{
|
|
||||||
//Получение координаты обхекта
|
|
||||||
ObjectParameters? GetObjectPosition { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
int GetStep { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Попытка переместить объект в указанном направлении
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
bool TryMoveObject(MovementDirection direction);
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
namespace ProjectWarmlyShip.MovementStrategy;
|
|
||||||
|
|
||||||
public class MoveToBorder : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
ObjectParameters? objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return objParams.LeftBorder - GetStep() <= 0 ||
|
|
||||||
objParams.RightBorder + GetStep() >= FieldWidth ||
|
|
||||||
objParams.TopBorder - GetStep() <= 0
|
|
||||||
|| objParams.ObjectMiddleVertical + GetStep() >= FieldHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void MoveToTarget()
|
|
||||||
{
|
|
||||||
ObjectParameters? objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//реализация в правый нижний угол
|
|
||||||
int x = objParams.RightBorder;
|
|
||||||
if (x + GetStep() < FieldWidth) MoveRight();
|
|
||||||
int y = objParams.DownBorder;
|
|
||||||
if (y + GetStep() < FieldHeight) MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
namespace ProjectWarmlyShip.MovementStrategy;
|
|
||||||
|
|
||||||
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,49 +0,0 @@
|
|||||||
using ProjectWarmlyShip.Drawnings;
|
|
||||||
|
|
||||||
namespace ProjectWarmlyShip.MovementStrategy;
|
|
||||||
|
|
||||||
public class MoveableShip : IMoveableObjects
|
|
||||||
{
|
|
||||||
private DrawningShip? _drawningship;
|
|
||||||
public MoveableShip(DrawningShip? drawningship)
|
|
||||||
{
|
|
||||||
_drawningship = drawningship;
|
|
||||||
}
|
|
||||||
public ObjectParameters? GetObjectPosition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_drawningship == null || _drawningship.EntityShip == null || !_drawningship.GetPosX.HasValue || !_drawningship.GetPosY.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ObjectParameters(_drawningship.GetPosX.Value, _drawningship.GetPosY.Value, _drawningship.GetWidht, _drawningship.GetHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int GetStep => (int)(_drawningship?.EntityShip?.Step ?? 0);
|
|
||||||
public bool TryMoveObject(MovementDirection direction)
|
|
||||||
{
|
|
||||||
if (_drawningship == null || _drawningship.EntityShip == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return _drawningship.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,21 +0,0 @@
|
|||||||
namespace ProjectWarmlyShip.MovementStrategy;
|
|
||||||
|
|
||||||
public enum MovementDirection
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Вверх
|
|
||||||
/// </summary>
|
|
||||||
Up = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// Вниз
|
|
||||||
/// </summary>
|
|
||||||
Down = 2,
|
|
||||||
/// <summary>
|
|
||||||
/// Влево
|
|
||||||
/// </summary>
|
|
||||||
Left = 3,
|
|
||||||
/// <summary>
|
|
||||||
/// Вправо
|
|
||||||
/// </summary>
|
|
||||||
Right = 4
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
namespace ProjectWarmlyShip.MovementStrategy;
|
|
||||||
|
|
||||||
public class ObjectParameters
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Координата х
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _x;
|
|
||||||
/// <summary>
|
|
||||||
/// Координата у
|
|
||||||
/// </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"></param>
|
|
||||||
/// <param name="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,15 +0,0 @@
|
|||||||
namespace ProjectWarmlyShip.MovementStrategy;
|
|
||||||
|
|
||||||
public enum StrategyStatus
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Все готово к началу
|
|
||||||
/// </summary>
|
|
||||||
NotInit,
|
|
||||||
/// <summary>
|
|
||||||
/// Выполняется
|
|
||||||
/// </summary>
|
|
||||||
InProgress,
|
|
||||||
// Завершена
|
|
||||||
Finish
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user