Pibd-14 SkobelevN.N. LabWork02 Base #2
@ -1,180 +0,0 @@
|
||||
using ProjectCatamaran;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran;
|
||||
/// <summary>
|
||||
/// класс отвечающиай за перемещение и отрисовку
|
||||
/// </summary>
|
||||
public class DrawningCatamaran
|
||||
{
|
||||
/// <summary>
|
||||
/// класс-сущность
|
||||
/// </summary>
|
||||
public EntityCatamaran? EntityCatamaran { get; private set; }
|
||||
/// <summary>
|
||||
/// ширина окна
|
||||
/// </summary>
|
||||
private int? _pictureWidth;
|
||||
/// <summary>
|
||||
/// высота окна
|
||||
/// </summary>
|
||||
private int? _pictureHeight;
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки автопоезда
|
||||
/// </summary>
|
||||
private int? _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя координата прорисовки автопоезда
|
||||
/// </summary>
|
||||
private int? _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина прорисовки катамарана
|
||||
/// </summary>
|
||||
private readonly int _drawningCatamaranWidth = 65;
|
||||
/// <summary>
|
||||
/// Высота прорисовки катамарана
|
||||
/// </summary>
|
||||
private readonly int _drawningCatamaranHeight = 40;
|
||||
/// <summary>
|
||||
/// Инициализация полей обьекта-класса спортивного автомобиля
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес катера</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет(для опциональных элементов)</param>
|
||||
/// <param name="floats">Признак (опция) наличие плавников</param>
|
||||
/// <param name="sail">Признак (опция) наличие парус</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail)
|
||||
{
|
||||
EntityCatamaran = new EntityCatamaran();
|
||||
EntityCatamaran.Init(speed, weight, bodyColor, additionalColor, floats, sail);
|
||||
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// установка границ поля
|
||||
/// </summary>
|
||||
/// <param name="width">ширина</param>
|
||||
/// <param name="height">высота</param>
|
||||
/// <returns></returns>
|
||||
public bool SetPictureSize(int width, int height)
|
||||
{
|
||||
if (_drawningCatamaranHeight < height && _drawningCatamaranWidth < width)
|
||||
{
|
||||
_pictureHeight = height;
|
||||
_pictureWidth = width;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// установка позиции
|
||||
/// </summary>
|
||||
/// <param name="x">координата x</param>
|
||||
/// <param name="y">координата y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (x > _pictureWidth - _drawningCatamaranWidth || x < 0)
|
||||
_startPosX = x < 0 ? 0 : _pictureWidth - _drawningCatamaranWidth;
|
||||
else
|
||||
_startPosX = x;
|
||||
if (y > _pictureHeight - _drawningCatamaranHeight || y < 0)
|
||||
_startPosY = y < 0 ? 0 : _pictureHeight - _drawningCatamaranHeight;
|
||||
else
|
||||
_startPosY = y;
|
||||
}
|
||||
/// <summary>
|
||||
/// изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">направление</param>
|
||||
/// <returns>true - перемещение выполнено , false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityCatamaran == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntityCatamaran.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityCatamaran.Step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntityCatamaran.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityCatamaran.Step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + (int)EntityCatamaran.Step + _drawningCatamaranWidth <= _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityCatamaran.Step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + (int)EntityCatamaran.Step + _drawningCatamaranHeight <= _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityCatamaran.Step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// отрисовка
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityCatamaran == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Brush brBody = new SolidBrush(EntityCatamaran.BodyColor);
|
||||
Brush brFloatsAndSail = new SolidBrush(EntityCatamaran.AdditionalColor);
|
||||
g.FillRectangle(brBody, _startPosX.Value + 5, _startPosY.Value + 15, 40, 20);
|
||||
Point[] triangle =
|
||||
{
|
||||
new Point(_startPosX.Value + 45,_startPosY.Value + 15),
|
||||
new Point(_startPosX.Value + 65,_startPosY.Value + 25),
|
||||
new Point(_startPosX.Value + 45,_startPosY.Value + 35),
|
||||
};
|
||||
g.FillPolygon(brBody, triangle);
|
||||
g.FillEllipse(new SolidBrush(Color.Black), _startPosX.Value + 12, _startPosY.Value + 19, 23, 10);
|
||||
//плавники
|
||||
if (EntityCatamaran.Floats)
|
||||
{
|
||||
g.FillRectangle(brFloatsAndSail, _startPosX.Value, _startPosY.Value + 10, 45, 5);
|
||||
g.FillRectangle(brFloatsAndSail, _startPosX.Value, _startPosY.Value + 35, 45, 5);
|
||||
}
|
||||
// парус
|
||||
if (EntityCatamaran.Sail)
|
||||
{
|
||||
Point[] sailFigure =
|
||||
{
|
||||
new Point(_startPosX.Value + 25,_startPosY.Value + 25),
|
||||
new Point(_startPosX.Value + 35 ,_startPosY.Value + 25),
|
||||
new Point(_startPosX.Value + 25,_startPosY.Value),
|
||||
};
|
||||
g.FillPolygon(brFloatsAndSail, sailFigure);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
31
ProjectCatamaran/ProjectCatamaran/Drawnings/DirectionType.cs
Normal file
31
ProjectCatamaran/ProjectCatamaran/Drawnings/DirectionType.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran.Drawnings;
|
||||
|
||||
public enum DirectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// неизвестное направление
|
||||
/// </summary>
|
||||
Unknown = -1,
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
192
ProjectCatamaran/ProjectCatamaran/Drawnings/DrawningBoat.cs
Normal file
192
ProjectCatamaran/ProjectCatamaran/Drawnings/DrawningBoat.cs
Normal file
@ -0,0 +1,192 @@
|
||||
using ProjectCatamaran.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran.Drawnings;
|
||||
public class DrawningBoat
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// класс-сущность
|
||||
/// </summary>
|
||||
public EntityBoat? EntityBoat { get; protected set; }
|
||||
/// <summary>
|
||||
/// ширина окна
|
||||
/// </summary>
|
||||
private int? _pictureWidth;
|
||||
/// <summary>
|
||||
/// высота окна
|
||||
/// </summary>
|
||||
private int? _pictureHeight;
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки автопоезда
|
||||
/// </summary>
|
||||
protected int? _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя координата прорисовки автопоезда
|
||||
/// </summary>
|
||||
protected int? _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина прорисовки лодки
|
||||
/// </summary>
|
||||
private readonly int _drawningBoatWidth = 60;
|
||||
/// <summary>
|
||||
/// Высота прорисовки лодки
|
||||
/// </summary>
|
||||
private readonly int _drawningBoatHeight = 22;
|
||||
/// <summary>
|
||||
/// координата х обьекта
|
||||
/// </summary>
|
||||
public int? GetPosX => _startPosX;
|
||||
/// <summary>
|
||||
/// координата Y обьекта
|
||||
/// </summary>
|
||||
public int? GetPosY => _startPosY;
|
||||
/// <summary>
|
||||
/// ширина обьекта
|
||||
/// </summary>
|
||||
public int GetWidth => _drawningBoatWidth;
|
||||
/// <summary>
|
||||
/// высота обьекта
|
||||
/// </summary>
|
||||
public int GetHeight => _drawningBoatHeight;
|
||||
|
||||
/// <summary>
|
||||
/// пустой конструктор
|
||||
/// </summary>
|
||||
private DrawningBoat()
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес катера</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
public DrawningBoat(int speed, double weight, Color bodyColor) : this()
|
||||
{
|
||||
EntityBoat = new EntityBoat(speed, weight, bodyColor);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="drawningCatamaranWidth">Ширина катера</param>
|
||||
/// <param name="drawningCatamaranHeight">высота катера</param>
|
||||
public DrawningBoat(int drawningBoatWidth, int drawningBoatHeight) : this()
|
||||
{
|
||||
_drawningBoatWidth = drawningBoatWidth;
|
||||
_drawningBoatHeight = drawningBoatHeight;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// установка границ поля
|
||||
/// </summary>
|
||||
/// <param name="width">ширина</param>
|
||||
/// <param name="height">высота</param>
|
||||
/// <returns></returns>
|
||||
public bool SetPictureSize(int width, int height)
|
||||
{
|
||||
if (_drawningBoatHeight < height && _drawningBoatWidth < width)
|
||||
{
|
||||
_pictureHeight = height;
|
||||
_pictureWidth = width;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// установка позиции
|
||||
/// </summary>
|
||||
/// <param name="x">координата x</param>
|
||||
/// <param name="y">координата y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (x > _pictureWidth - _drawningBoatWidth || x < 0)
|
||||
_startPosX = x < 0 ? 0 : _pictureWidth - _drawningBoatWidth;
|
||||
else
|
||||
_startPosX = x;
|
||||
if (y > _pictureHeight - _drawningBoatHeight || y < 0)
|
||||
_startPosY = y < 0 ? 0 : _pictureHeight - _drawningBoatHeight;
|
||||
else
|
||||
_startPosY = y;
|
||||
}
|
||||
/// <summary>
|
||||
/// изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">направление</param>
|
||||
/// <returns>true - перемещение выполнено , false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityBoat == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntityBoat.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityBoat.Step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntityBoat.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityBoat.Step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + (int)EntityBoat.Step + _drawningBoatWidth <= _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityBoat.Step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + (int)EntityBoat.Step + _drawningBoatHeight <= _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityBoat.Step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// отрисовка
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityBoat == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Brush brBody = new SolidBrush(EntityBoat.BodyColor);
|
||||
|
||||
g.FillRectangle(brBody, _startPosX.Value, _startPosY.Value, 40, 20);
|
||||
Point[] triangle =
|
||||
{
|
||||
new Point(_startPosX.Value + 40,_startPosY.Value),
|
||||
new Point(_startPosX.Value + 60,_startPosY.Value + 10),
|
||||
new Point(_startPosX.Value + 40,_startPosY.Value + 20),
|
||||
};
|
||||
g.FillPolygon(brBody, triangle);
|
||||
g.FillEllipse(new SolidBrush(Color.Black), _startPosX.Value + 7, _startPosY.Value + 4, 23, 10);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
using ProjectCatamaran.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran.Drawnings;
|
||||
/// <summary>
|
||||
/// класс отвечающиай за перемещение и отрисовку
|
||||
/// </summary>
|
||||
public class DrawningCatamaran : DrawningBoat
|
||||
{
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес катера</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет(для опциональных элементов)</param>
|
||||
/// <param name="floats">Признак (опция) наличие плавников</param>
|
||||
/// <param name="sail">Признак (опция) наличие парус</param>
|
||||
public DrawningCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail) :
|
||||
base(65,40)
|
||||
{
|
||||
EntityBoat = new EntityCatamaran(speed, weight, bodyColor, additionalColor, floats, sail);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityBoat == null || EntityBoat is not EntityCatamaran catamaran || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_startPosX += 5;
|
||||
_startPosY += 15;
|
||||
base.DrawTransport(g);
|
||||
_startPosX -= 5;
|
||||
_startPosY -= 15;
|
||||
Brush brFloatsAndSail = new SolidBrush(catamaran.AdditionalColor);
|
||||
//плавники
|
||||
if (catamaran.Floats)
|
||||
{
|
||||
g.FillRectangle(brFloatsAndSail, _startPosX.Value, _startPosY.Value + 10, 45, 5);
|
||||
g.FillRectangle(brFloatsAndSail, _startPosX.Value, _startPosY.Value + 35, 45, 5);
|
||||
}
|
||||
// парус
|
||||
if (catamaran.Sail)
|
||||
{
|
||||
Point[] sailFigure =
|
||||
{
|
||||
new Point(_startPosX.Value + 25,_startPosY.Value + 25),
|
||||
new Point(_startPosX.Value + 35 ,_startPosY.Value + 25),
|
||||
new Point(_startPosX.Value + 25,_startPosY.Value),
|
||||
};
|
||||
g.FillPolygon(brFloatsAndSail, sailFigure);
|
||||
}
|
||||
}
|
||||
}
|
44
ProjectCatamaran/ProjectCatamaran/Entities/EntityBoat.cs
Normal file
44
ProjectCatamaran/ProjectCatamaran/Entities/EntityBoat.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran.Entities;
|
||||
/// <summary>
|
||||
/// класс-сущность "лодка"
|
||||
/// </summary>
|
||||
public class EntityBoat
|
||||
{
|
||||
/// <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 EntityBoat(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
|
||||
}
|
||||
}
|
@ -1,21 +1,9 @@
|
||||
namespace ProjectCatamaran;
|
||||
namespace ProjectCatamaran.Entities;
|
||||
/// <summary>
|
||||
/// Класс-сущность "Катамаран"
|
||||
/// Класс-сущность "Катамарана"
|
||||
/// </summary>
|
||||
public class EntityCatamaran
|
||||
public class EntityCatamaran : EntityBoat
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; set; }
|
||||
/// <summary>
|
||||
/// Вес авто
|
||||
/// </summary>
|
||||
public double Weight { get; set; }
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Дополнительный цвет(для опциональных элементов)
|
||||
/// </summary>
|
||||
@ -29,10 +17,6 @@ public class EntityCatamaran
|
||||
/// </summary>
|
||||
public bool Sail { get; private set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения
|
||||
/// </summary>
|
||||
public double Step => Speed * 100 / Weight;
|
||||
/// <summary>
|
||||
/// Инициализация полей обьекта-класса спортивного автомобиля
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
@ -41,11 +25,9 @@ public class EntityCatamaran
|
||||
/// <param name="additionalColor">Дополнительный цвет(для опциональных элементов)</param>
|
||||
/// <param name="floats">Признак (опция) наличие плавников</param>
|
||||
/// <param name="sail">Признак (опция) наличие паруса</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail)
|
||||
public EntityCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail)
|
||||
: base(speed,weight,bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Floats = floats;
|
||||
Sail = sail;
|
@ -34,6 +34,9 @@
|
||||
buttonRight = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonCreateBoat = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonStrategyStep = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -42,18 +45,18 @@
|
||||
pictureBoxCatamaran.Dock = DockStyle.Fill;
|
||||
pictureBoxCatamaran.Location = new Point(0, 0);
|
||||
pictureBoxCatamaran.Name = "pictureBoxCatamaran";
|
||||
pictureBoxCatamaran.Size = new Size(800, 450);
|
||||
pictureBoxCatamaran.Size = new Size(801, 450);
|
||||
pictureBoxCatamaran.TabIndex = 0;
|
||||
pictureBoxCatamaran.TabStop = false;
|
||||
//
|
||||
// buttonCreateCatamaran
|
||||
//
|
||||
buttonCreateCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCreateCatamaran.Location = new Point(12, 406);
|
||||
buttonCreateCatamaran.Location = new Point(12, 402);
|
||||
buttonCreateCatamaran.Name = "buttonCreateCatamaran";
|
||||
buttonCreateCatamaran.Size = new Size(75, 23);
|
||||
buttonCreateCatamaran.Size = new Size(166, 40);
|
||||
buttonCreateCatamaran.TabIndex = 1;
|
||||
buttonCreateCatamaran.Text = "Создать";
|
||||
buttonCreateCatamaran.Text = "Создать катамаран";
|
||||
buttonCreateCatamaran.UseVisualStyleBackColor = true;
|
||||
buttonCreateCatamaran.Click += ButtonCreateCatamaran_Click;
|
||||
//
|
||||
@ -105,11 +108,46 @@
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonCreateBoat
|
||||
//
|
||||
buttonCreateBoat.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCreateBoat.Location = new Point(184, 402);
|
||||
buttonCreateBoat.Name = "buttonCreateBoat";
|
||||
buttonCreateBoat.Size = new Size(166, 40);
|
||||
buttonCreateBoat.TabIndex = 6;
|
||||
buttonCreateBoat.Text = "Создать лодку";
|
||||
buttonCreateBoat.UseVisualStyleBackColor = true;
|
||||
buttonCreateBoat.Click += ButtonCreateBoat_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
|
||||
comboBoxStrategy.Location = new Point(668, 12);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(121, 23);
|
||||
comboBoxStrategy.TabIndex = 7;
|
||||
//
|
||||
// buttonStrategyStep
|
||||
//
|
||||
buttonStrategyStep.Location = new Point(709, 41);
|
||||
buttonStrategyStep.Name = "buttonStrategyStep";
|
||||
buttonStrategyStep.RightToLeft = RightToLeft.Yes;
|
||||
buttonStrategyStep.Size = new Size(75, 23);
|
||||
buttonStrategyStep.TabIndex = 8;
|
||||
buttonStrategyStep.Text = "Шаг";
|
||||
buttonStrategyStep.UseVisualStyleBackColor = true;
|
||||
buttonStrategyStep.Click += ButtonStrategyStep_Click;
|
||||
//
|
||||
// FormCatamaran
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonStrategyStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonCreateBoat);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonRight);
|
||||
@ -130,5 +168,8 @@
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonCreateBoat;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStrategyStep;
|
||||
}
|
||||
}
|
@ -1,39 +1,43 @@
|
||||
using ProjectCatamaran;
|
||||
using ProjectCatamaran.Drawnings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ProjectCatamaran.MovementStrategy;
|
||||
|
||||
namespace ProjectCatamaran
|
||||
{
|
||||
public partial class FormCatamaran : Form
|
||||
{
|
||||
private DrawningCatamaran? _drawningCatamaran;
|
||||
private DrawningBoat? _drawningBoat;
|
||||
private AbstractStrategy? _strategy;
|
||||
public FormCatamaran()
|
||||
{
|
||||
InitializeComponent();
|
||||
_strategy = null;
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningCatamaran == null)
|
||||
if (_drawningBoat == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningCatamaran.DrawTransport(gr);
|
||||
_drawningBoat.DrawTransport(gr);
|
||||
pictureBoxCatamaran.Image = bmp;
|
||||
}
|
||||
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningCatamaran == null)
|
||||
if (_drawningBoat == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -42,16 +46,16 @@ namespace ProjectCatamaran
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result = _drawningCatamaran.MoveTransport(DirectionType.Up);
|
||||
result = _drawningBoat.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result = _drawningCatamaran.MoveTransport(DirectionType.Down);
|
||||
result = _drawningBoat.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result = _drawningCatamaran.MoveTransport(DirectionType.Left);
|
||||
result = _drawningBoat.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result = _drawningCatamaran.MoveTransport(DirectionType.Right);
|
||||
result = _drawningBoat.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
if (result)
|
||||
@ -60,18 +64,77 @@ namespace ProjectCatamaran
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateObject(string type)
|
||||
{
|
||||
Random random = new();
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawningBoat):
|
||||
_drawningBoat = new DrawningBoat(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(DrawningCatamaran):
|
||||
_drawningBoat = new DrawningCatamaran(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;
|
||||
}
|
||||
_drawningBoat.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||
_drawningBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
_strategy = null;
|
||||
comboBoxStrategy.Enabled = true;
|
||||
Draw();
|
||||
}
|
||||
private void ButtonCreateCatamaran_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new Random();
|
||||
_drawningCatamaran = new DrawningCatamaran();
|
||||
_drawningCatamaran.Init(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)));
|
||||
CreateObject(nameof(DrawningCatamaran));
|
||||
}
|
||||
|
||||
_drawningCatamaran.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||
_drawningCatamaran.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
private void ButtonCreateBoat_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateObject(nameof(DrawningBoat));
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Шаг"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonStrategyStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningBoat == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_strategy = comboBoxStrategy.SelectedIndex switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_strategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_strategy.SetData(new MoveableBoat(_drawningBoat),
|
||||
pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||
}
|
||||
if (_strategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
comboBoxStrategy.Enabled = false;
|
||||
_strategy.MakeStep();
|
||||
Draw();
|
||||
if (_strategy.GetStatus() == StrategyStatus.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_strategy = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran.MovementStrategy;
|
||||
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 (IsTargetDestination())
|
||||
{
|
||||
_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 IsTargetDestination();
|
||||
/// <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;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran.MovementStrategy;
|
||||
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);
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran.MovementStrategy;
|
||||
public class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// движение до правого края
|
||||
/// </summary>
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
return;
|
||||
if (objParams.RightBorder + GetStep() <= FieldWidth)
|
||||
MoveRight();
|
||||
if (objParams.DownBorder + GetStep() <= FieldHeight)
|
||||
MoveDown();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// проверка достижения цели
|
||||
/// </summary>
|
||||
/// <returns>true - достиг , false - нет </returns>
|
||||
protected override bool IsTargetDestination()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
return false;
|
||||
return objParams.RightBorder + GetStep() > FieldWidth &&
|
||||
objParams.DownBorder + GetStep() > FieldHeight ;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran.MovementStrategy;
|
||||
/// <summary>
|
||||
/// стратегия перемещения обьекта в центр экрана
|
||||
/// </summary>
|
||||
public class MoveToCenter : AbstractStrategy
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool IsTargetDestination()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectCatamaran.Drawnings;
|
||||
|
||||
namespace ProjectCatamaran.MovementStrategy
|
||||
{
|
||||
internal class MoveableBoat : IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Поле-объект класса DrawningBoat или его наследника
|
||||
/// </summary>
|
||||
private readonly DrawningBoat? _boat = null;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="car">Объект класса DrawningBoat</param>
|
||||
public MoveableBoat(DrawningBoat boat)
|
||||
{
|
||||
_boat = boat;
|
||||
}
|
||||
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_boat == null || _boat.EntityBoat == null || !_boat.GetPosX.HasValue
|
||||
|| !_boat.GetPosY.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ObjectParameters(_boat.GetPosX.Value, _boat.GetPosY.Value,
|
||||
_boat.GetWidth, _boat.GetHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetStep => (int)(_boat?.EntityBoat?.Step ?? 0);
|
||||
public bool TryMoveObject(MovementDirection direction)
|
||||
{
|
||||
if (_boat == null || _boat.EntityBoat == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _boat.MoveTransport(GetDirectionType(direction));
|
||||
}
|
||||
/// <summary>
|
||||
/// Конвертация из MovementDirection в DirectionType
|
||||
/// </summary>
|
||||
/// <param name="direction"></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.Unknown
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -4,11 +4,11 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran;
|
||||
|
||||
public enum DirectionType
|
||||
namespace ProjectCatamaran.MovementStrategy;
|
||||
public enum MovementDirection
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
@ -24,4 +24,4 @@ public enum DirectionType
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran.MovementStrategy;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCatamaran.MovementStrategy;
|
||||
public enum StrategyStatus
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user