diff --git a/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/IMoveableObject.cs b/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/IMoveableObject.cs new file mode 100644 index 0000000..aede2a9 --- /dev/null +++ b/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/IMoveableObject.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAircraftCarrier.MovementStrategy; + +/// +/// Интерфейс для работы с перемещаемым объектом +/// +public interface IMoveableObject +{ + /// + /// Получение координаты объекта + /// + ObjectParameters? GetObjectPosition { get; } + + /// + /// Шаг объекта + /// + int GetStep { get; } + + /// + /// Попытка переместить объект в указанном направлении + /// + /// Направление + /// true - объект перемещён, false - перемещение невозможно + bool TryMoveObject(MovementDirection direction); +} diff --git a/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/MovementDirection.cs b/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/MovementDirection.cs new file mode 100644 index 0000000..920b974 --- /dev/null +++ b/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/MovementDirection.cs @@ -0,0 +1,27 @@ +namespace ProjectAircraftCarrier.MovementStrategy; + +/// +/// Направление перемещения +/// +public enum MovementDirection +{ + /// + /// Вверх + /// + Up = 1, + + /// + /// Вниз + /// + Down = 2, + + /// + /// Влево + /// + Left = 3, + + /// + /// Вправо + /// + Right = 4 +} diff --git a/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/ObjectParameters.cs b/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/ObjectParameters.cs new file mode 100644 index 0000000..d8f9339 --- /dev/null +++ b/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/ObjectParameters.cs @@ -0,0 +1,72 @@ +namespace ProjectAircraftCarrier.MovementStrategy; + +/// +/// Параметры-координаты объекта +/// +public class ObjectParameters +{ + /// + /// Координата X + /// + private readonly int _x; + + /// + /// Координата Y + /// + private readonly int _y; + + /// + /// Ширина объекта + /// + private readonly int _width; + + /// + /// Высота объекта + /// + private readonly int _height; + + /// + /// Левая граница + /// + public int LeftBorder => _x; + + /// + /// Верхняя граница + /// + public int TopBorder => _y; + + /// + /// Правая граница + /// + public int RightBorder => _x + _width; + + /// + /// Нижняя граница + /// + public int DownBorder => _y + _height; + + /// + /// Середина объекта + /// + public int ObjectMiddleHorizontal => _x + _width / 2; + + /// + /// Середина объекта + /// + public int ObjectMiddleVertical => _y + _height / 2; + + /// + /// Конструктор + /// + /// Координата X + /// Координата Y + /// Ширина объекта + /// Высота объекта + public ObjectParameters(int x, int y, int width, int height) + { + _x = x; + _y = y; + _width = width; + _height = height; + } +} diff --git a/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/StrategyStatus.cs b/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/StrategyStatus.cs new file mode 100644 index 0000000..87fe958 --- /dev/null +++ b/ProjectAircraftCarrier/ProjectAircraftCarrier/MovementStrategy/StrategyStatus.cs @@ -0,0 +1,22 @@ +namespace ProjectAircraftCarrier.MovementStrategy; + +/// +/// Статус выполнения операции перемещения +/// +public enum StrategyStatus +{ + /// + /// Всё готово к началу + /// + NotInit, + + /// + /// Выполняется + /// + InProgress, + + /// + /// Завершено + /// + Finish +}