Сделано до движения до границы
This commit is contained in:
parent
f8b0e3baa1
commit
8cbceb87b7
@ -8,5 +8,5 @@ namespace AccordionBus.Drawnings;
|
||||
|
||||
public enum DirectionType
|
||||
{
|
||||
Up = 1, Down = 2, Left = 3, Right = 4,
|
||||
Up = 1, Down = 2, Left = 3, Right = 4, Unknow = -1
|
||||
}
|
||||
|
@ -38,6 +38,23 @@ public class DrawningBus
|
||||
/// Высота прорисовки автомобиля
|
||||
/// </summary>
|
||||
private readonly int _drawningBusHeight = 40;
|
||||
/// <summary>
|
||||
/// Координата X
|
||||
/// </summary>
|
||||
public int? GetPosX=>_startPosX;
|
||||
/// <summary>
|
||||
/// Координата Y
|
||||
/// </summary>
|
||||
public int? GetPosY => _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина объекта
|
||||
/// </summary>
|
||||
public int GetWidth => _drawningBusWidth;
|
||||
/// <summary>
|
||||
/// Высота объекта
|
||||
/// </summary>
|
||||
public int GetHeight => _drawningBusHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Пустой конструктор
|
||||
/// </summary>
|
||||
|
@ -33,6 +33,8 @@
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonCreateBus = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonStrategyStep = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxAccordionBus).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -53,7 +55,7 @@
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(216, 23);
|
||||
buttonCreate.TabIndex = 6;
|
||||
buttonCreate.Text = "Создать\r\n автобус с гармошкой";
|
||||
buttonCreate.Text = "Создать автобус с гармошкой";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreateAccordionBus_Click;
|
||||
//
|
||||
@ -116,15 +118,37 @@
|
||||
buttonCreateBus.Name = "buttonCreateBus";
|
||||
buttonCreateBus.Size = new Size(216, 23);
|
||||
buttonCreateBus.TabIndex = 11;
|
||||
buttonCreateBus.Text = "Создать\r\n автобус без гармошки";
|
||||
buttonCreateBus.Text = "Создать автобус без гармошки";
|
||||
buttonCreateBus.UseVisualStyleBackColor = true;
|
||||
buttonCreateBus.Click += buttonCreateBus_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
|
||||
comboBoxStrategy.Location = new Point(667, 12);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(121, 23);
|
||||
comboBoxStrategy.TabIndex = 12;
|
||||
//
|
||||
// buttonStrategyStep
|
||||
//
|
||||
buttonStrategyStep.Location = new Point(713, 41);
|
||||
buttonStrategyStep.Name = "buttonStrategyStep";
|
||||
buttonStrategyStep.Size = new Size(75, 23);
|
||||
buttonStrategyStep.TabIndex = 13;
|
||||
buttonStrategyStep.Text = "Шаг";
|
||||
buttonStrategyStep.UseVisualStyleBackColor = true;
|
||||
buttonStrategyStep.Click += ButtonStrategyStep_Click;
|
||||
//
|
||||
// FormAccordionBus
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonStrategyStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonCreateBus);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
@ -146,5 +170,7 @@
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonCreateBus;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStrategyStep;
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AccordionBus.Drawnings;
|
||||
using AccordionBus.MovementStrategy;
|
||||
|
||||
namespace AccordionBus;
|
||||
public partial class FormAccordionBus : Form
|
||||
@ -17,11 +18,16 @@ public partial class FormAccordionBus : Form
|
||||
/// </summary>
|
||||
private DrawningBus? _drawningBus;
|
||||
/// <summary>
|
||||
/// Стратегия перемещения
|
||||
/// </summary>
|
||||
private AbstractStategy? _strategy;
|
||||
/// <summary>
|
||||
/// Конструктор формы
|
||||
/// </summary>
|
||||
public FormAccordionBus()
|
||||
{
|
||||
InitializeComponent();
|
||||
_strategy = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод прорисовки машины
|
||||
@ -50,23 +56,25 @@ public partial class FormAccordionBus : Form
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawningBus):
|
||||
_drawningBus = new DrawningBus(rnd.Next(100, 300), rnd.Next(1000, 3000),
|
||||
_drawningBus = new DrawningBus(rnd.Next(100, 300), rnd.Next(1000, 3000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
break;
|
||||
case nameof(DrawningAccordionBus):
|
||||
_drawningBus = new DrawningAccordionBus(rnd.Next(650, 700), rnd.Next(15760,16130),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),rnd.Next(0, 256)),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),rnd.Next(0, 256)),
|
||||
_drawningBus = new DrawningAccordionBus(rnd.Next(650, 700), rnd.Next(15760, 16130),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
_drawningBus.SetPictureSize(pictureBoxAccordionBus.Width,pictureBoxAccordionBus.Height);
|
||||
_drawningBus.SetPosition(rnd.Next(10,100), rnd.Next(10,100));
|
||||
_drawningBus.SetPictureSize(pictureBoxAccordionBus.Width, pictureBoxAccordionBus.Height);
|
||||
_drawningBus.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100));
|
||||
_strategy = null;
|
||||
|
||||
Draw();
|
||||
}
|
||||
|
||||
@ -75,7 +83,7 @@ public partial class FormAccordionBus : Form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreateAccordionBus_Click(object sender, EventArgs e) =>CreateObject(nameof(DrawningAccordionBus));
|
||||
private void ButtonCreateAccordionBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAccordionBus));
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать автобус"
|
||||
@ -83,7 +91,7 @@ public partial class FormAccordionBus : Form
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void buttonCreateBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBus));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
||||
/// </summary>
|
||||
@ -121,4 +129,45 @@ public partial class FormAccordionBus : Form
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Шаг"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonStrategyStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningBus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_strategy = comboBoxStrategy.SelectedIndex switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_strategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_strategy.SetData(new MoveableBus(_drawningBus),
|
||||
pictureBoxAccordionBus.Width, pictureBoxAccordionBus.Height);
|
||||
}
|
||||
if (_strategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
comboBoxStrategy.Enabled = false;
|
||||
_strategy.MakeStep();
|
||||
Draw();
|
||||
if (_strategy.GetStatus() == StrategyStatus.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_strategy = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
123
AccordionBus/AccordionBus/MovementStrategy/AbstractStategy.cs
Normal file
123
AccordionBus/AccordionBus/MovementStrategy/AbstractStategy.cs
Normal file
@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.MovementStrategy;
|
||||
public abstract class AbstractStategy
|
||||
{
|
||||
/// <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;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.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);
|
||||
}
|
56
AccordionBus/AccordionBus/MovementStrategy/MoveToBorder.cs
Normal file
56
AccordionBus/AccordionBus/MovementStrategy/MoveToBorder.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.MovementStrategy;
|
||||
|
||||
public class MoveToBorder : AbstractStategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth
|
||||
&& objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth &&
|
||||
objParams.ObjectMiddleVertical - GetStep() <= FieldHeight
|
||||
&& objParams.ObjectMiddleVertical + GetStep() >= FieldHeight;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int diffX = objParams.ObjectMiddleHorizontal - FieldWidth;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX < 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
int diffY = objParams.ObjectMiddleVertical - FieldHeight;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY < 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
56
AccordionBus/AccordionBus/MovementStrategy/MoveToCenter.cs
Normal file
56
AccordionBus/AccordionBus/MovementStrategy/MoveToCenter.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.MovementStrategy;
|
||||
|
||||
public class MoveToCenter : AbstractStategy
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
62
AccordionBus/AccordionBus/MovementStrategy/MoveableBus.cs
Normal file
62
AccordionBus/AccordionBus/MovementStrategy/MoveableBus.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using AccordionBus.Drawnings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.MovementStrategy;
|
||||
|
||||
public class MoveableBus:IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Поле-объект класса DrawningBus или его наследника
|
||||
/// </summary>
|
||||
private readonly DrawningBus? _bus = null;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="bus">Объект класса DrawningBus</param>
|
||||
public MoveableBus(DrawningBus bus)
|
||||
{
|
||||
_bus = bus;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_bus == null || _bus.EntityBus == null ||
|
||||
!_bus.GetPosX.HasValue || !_bus.GetPosY.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_bus.GetPosX.Value,
|
||||
_bus.GetPosY.Value, _bus.GetWidth, _bus.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_bus?.EntityBus?.Step ?? 0);
|
||||
public bool TryMoveObject(MovementDirection direction)
|
||||
{
|
||||
if (_bus == null || _bus.EntityBus == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _bus.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,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.MovementStrategy;
|
||||
|
||||
public enum MovementDirection
|
||||
{
|
||||
Up = 1, Down = 2, Left = 3, Right = 4
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.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;
|
||||
}
|
||||
|
||||
}
|
25
AccordionBus/AccordionBus/MovementStrategy/StrategyStatus.cs
Normal file
25
AccordionBus/AccordionBus/MovementStrategy/StrategyStatus.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.MovementStrategy;
|
||||
|
||||
public enum StrategyStatus
|
||||
{
|
||||
///<summary>
|
||||
///Всё готово к началу
|
||||
///</summary>
|
||||
NotInit,
|
||||
|
||||
///<summary>
|
||||
///Выполняется
|
||||
///</summary>
|
||||
InProgress,
|
||||
|
||||
///<summary>
|
||||
///Завершено
|
||||
///</summary>
|
||||
Finish
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user