Compare commits
No commits in common. "Lab4" and "main" have entirely different histories.
@ -1,131 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public abstract class AbstractStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещаемый объект
|
|
||||||
/// </summary>
|
|
||||||
private IMoveableObject? _moveableObject;
|
|
||||||
/// <summary>
|
|
||||||
/// Статус перемещения
|
|
||||||
/// </summary>
|
|
||||||
private Status _state = Status.NotInit;
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина поля
|
|
||||||
/// </summary>
|
|
||||||
protected int FieldWidth { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Высота поля
|
|
||||||
/// </summary>
|
|
||||||
protected int FieldHeight { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Статус перемещения
|
|
||||||
/// </summary>
|
|
||||||
public Status 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 = Status.NotInit;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_state = Status.InProgress;
|
|
||||||
_moveableObject = moveableObject;
|
|
||||||
FieldWidth = width;
|
|
||||||
FieldHeight = height;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения
|
|
||||||
/// </summary>
|
|
||||||
public void MakeStep()
|
|
||||||
{
|
|
||||||
if (_state != Status.InProgress)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (IsTargetDestinaion())
|
|
||||||
{
|
|
||||||
_state = Status.Finish;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MoveToTarget();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение влево
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вправо
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вверх
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вниз
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
|
||||||
/// <summary>
|
|
||||||
/// Параметры объекта
|
|
||||||
/// </summary>
|
|
||||||
protected ObjectParameters? GetObjectParameters =>_moveableObject?.GetObjectPosition;
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected int? GetStep()
|
|
||||||
{
|
|
||||||
if (_state != Status.InProgress)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return _moveableObject?.GetStep;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение к цели
|
|
||||||
/// </summary>
|
|
||||||
protected abstract void MoveToTarget();
|
|
||||||
/// <summary>
|
|
||||||
/// Достигнута ли цель
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected abstract bool IsTargetDestinaion();
|
|
||||||
/// <summary>
|
|
||||||
/// Попытка перемещения в требуемом направлении
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="directionType">Направление</param>
|
|
||||||
/// <returns>Результат попытки (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
private bool MoveTo(DirectionType directionType)
|
|
||||||
{
|
|
||||||
if (_state != Status.InProgress)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
|
||||||
{
|
|
||||||
_moveableObject.MoveObject(directionType);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,19 +8,4 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public enum DirectionType
|
|
||||||
{
|
|
||||||
Up = 1,
|
|
||||||
Down = 2,
|
|
||||||
Left = 3,
|
|
||||||
Right = 4
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AirBomber;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public class DrawningAirBomber : DrawningAirPlane
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="bombs">Признак наличия обвеса</param>
|
|
||||||
/// <param name="fuelTanks">Признак наличия антикрыла</param>
|
|
||||||
/// <param name="width">Ширина картинки</param>
|
|
||||||
/// <param name="height">Высота картинки</param>
|
|
||||||
public DrawningAirBomber(int speed, double weight, Color bodyColor, Color
|
|
||||||
additionalColor, bool bombs, bool fuelTanks, int width, int height) :
|
|
||||||
base(speed, weight, bodyColor, width, height, 160, 118)
|
|
||||||
{
|
|
||||||
if (EntityAirPlane != null)
|
|
||||||
{
|
|
||||||
EntityAirPlane = new EntityAirBomber(speed, weight, bodyColor, additionalColor, bombs, fuelTanks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public override void DrawPlane(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityAirPlane is not EntityAirBomber airBomber)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor);
|
|
||||||
base.DrawPlane(g);
|
|
||||||
// обвесы
|
|
||||||
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 20, 15, 29);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29);
|
|
||||||
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 70, 15, 29);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 70, 15, 29);
|
|
||||||
g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 50, 15, 15);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 50, 15, 15);
|
|
||||||
// fueltanks
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 63, _startPosY + 34, 20, 15);
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 70, 20, 15);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 63, _startPosY + 70, 20, 15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,278 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AirBomber;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public class DrawningAirPlane
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность
|
|
||||||
/// </summary>
|
|
||||||
public EntityAirPlane? EntityAirPlane { 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>
|
|
||||||
protected readonly int _airPlaneWidth = 150;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота прорисовки самолета
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _airPlaneHeight = 118;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="width">Ширина картинки</param>
|
|
||||||
/// <param name="height">Высота картинки</param>
|
|
||||||
public DrawningAirPlane(int speed, double weight, Color bodyColor, int
|
|
||||||
width, int height)
|
|
||||||
{
|
|
||||||
// TODO: Продумать проверки
|
|
||||||
if (width < _airPlaneWidth || height < _airPlaneHeight)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
EntityAirPlane = new EntityAirPlane(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="width">Ширина картинки</param>
|
|
||||||
/// <param name="height">Высота картинки</param>
|
|
||||||
/// <param name="airPlaneWidth">Ширина прорисовки самолета</param>
|
|
||||||
/// <param name="airPlaneHeight">Высота прорисовки самолета</param>
|
|
||||||
protected DrawningAirPlane(int speed, double weight, Color bodyColor, int
|
|
||||||
width, int height, int airPlaneWidth, int airPlaneHeight)
|
|
||||||
{
|
|
||||||
// TODO: Продумать проверки
|
|
||||||
if (width < _airPlaneWidth || height < _airPlaneHeight)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
_airPlaneWidth = airPlaneWidth;
|
|
||||||
_airPlaneHeight = airPlaneHeight;
|
|
||||||
EntityAirPlane = new EntityAirPlane(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Установка позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
public void SetPosition(int x, int y)
|
|
||||||
{
|
|
||||||
// TODO: Изменение x, y, если при установке объект выходит за границы
|
|
||||||
if (x < 0 || x + _airPlaneWidth > _pictureWidth)
|
|
||||||
{
|
|
||||||
x = _pictureWidth - _airPlaneWidth;
|
|
||||||
}
|
|
||||||
if (y < 0 || y + _airPlaneHeight > _pictureHeight)
|
|
||||||
{
|
|
||||||
y = _pictureHeight - _airPlaneHeight;
|
|
||||||
}
|
|
||||||
_startPosX = x;
|
|
||||||
_startPosY = y;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение направления перемещения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
/// <summary>
|
|
||||||
/// Прорисовка объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
public virtual void DrawPlane(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityAirPlane == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Brush bodyColor = new SolidBrush(EntityAirPlane.BodyColor);
|
|
||||||
Brush wingsColor = new SolidBrush(Color.DeepPink);
|
|
||||||
g.FillPolygon(bodyColor, new Point[] //nose
|
|
||||||
{
|
|
||||||
new Point(_startPosX + 19, _startPosY + 50),
|
|
||||||
new Point(_startPosX + 19, _startPosY + 69),
|
|
||||||
new Point(_startPosX + 1, _startPosY + 59),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
g.FillRectangle(bodyColor, _startPosX + 20, _startPosY + 50, 120, 20); //body
|
|
||||||
g.FillPolygon(bodyColor, new Point[] //up left wing
|
|
||||||
{
|
|
||||||
new Point(_startPosX + 36, _startPosY + 49),
|
|
||||||
new Point(_startPosX + 36, _startPosY + 1),
|
|
||||||
new Point(_startPosX + 45, _startPosY + 1),
|
|
||||||
new Point(_startPosX + 55, _startPosY + 49),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
g.FillPolygon(bodyColor, new Point[] //down left wing
|
|
||||||
{
|
|
||||||
new Point(_startPosX + 36, _startPosY + 71),
|
|
||||||
new Point(_startPosX + 36, _startPosY + 116),
|
|
||||||
new Point(_startPosX + 45, _startPosY + 116),
|
|
||||||
new Point(_startPosX + 54, _startPosY + 71),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
g.FillPolygon(wingsColor, new Point[] //up right wing
|
|
||||||
{
|
|
||||||
new Point(_startPosX + 120, _startPosY + 49),
|
|
||||||
new Point(_startPosX + 120, _startPosY + 42),
|
|
||||||
new Point(_startPosX + 140, _startPosY + 7),
|
|
||||||
new Point(_startPosX + 140, _startPosY + 49),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
g.FillPolygon(wingsColor, new Point[] //down right wing
|
|
||||||
{
|
|
||||||
new Point(_startPosX + 120, _startPosY + 70),
|
|
||||||
new Point(_startPosX + 120, _startPosY + 77),
|
|
||||||
new Point(_startPosX + 140, _startPosY + 112),
|
|
||||||
new Point(_startPosX + 140, _startPosY + 70),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
g.DrawPolygon(pen, new Point[] //nose
|
|
||||||
{
|
|
||||||
new Point(_startPosX + 20, _startPosY + 49),
|
|
||||||
new Point(_startPosX + 20, _startPosY + 70),
|
|
||||||
new Point(_startPosX, _startPosY + 59),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 19, _startPosY + 49, 121, 21); //body
|
|
||||||
g.DrawPolygon(pen, new Point[] //up left wing
|
|
||||||
{
|
|
||||||
new Point(_startPosX + 35, _startPosY + 49),
|
|
||||||
new Point(_startPosX + 35, _startPosY),
|
|
||||||
new Point(_startPosX + 45, _startPosY),
|
|
||||||
new Point(_startPosX + 55, _startPosY + 49),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
g.DrawPolygon(pen, new Point[] //down left wing
|
|
||||||
{
|
|
||||||
new Point(_startPosX + 36, _startPosY + 71),
|
|
||||||
new Point(_startPosX + 36, _startPosY + 116),
|
|
||||||
new Point(_startPosX + 45, _startPosY + 116),
|
|
||||||
new Point(_startPosX + 54, _startPosY + 71),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
g.DrawPolygon(pen, new Point[] //up right wing
|
|
||||||
{
|
|
||||||
new Point(_startPosX + 120, _startPosY + 49),
|
|
||||||
new Point(_startPosX + 120, _startPosY + 42),
|
|
||||||
new Point(_startPosX + 140, _startPosY + 7),
|
|
||||||
new Point(_startPosX + 140, _startPosY + 49),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
g.DrawPolygon(pen, new Point[] //down right wing
|
|
||||||
{
|
|
||||||
new Point(_startPosX + 120, _startPosY + 70),
|
|
||||||
new Point(_startPosX + 120, _startPosY + 77),
|
|
||||||
new Point(_startPosX + 140, _startPosY + 112),
|
|
||||||
new Point(_startPosX + 140, _startPosY + 70),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Координата X объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetPosX => _startPosX;
|
|
||||||
/// <summary>
|
|
||||||
/// Координата Y объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetPosY => _startPosY;
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetWidth => _airPlaneWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetHeight => _airPlaneHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка, что объект может переместится по указанному направлению
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
/// <returns>true - можно переместится по указанному направлению</returns>
|
|
||||||
public bool CanMove(DirectionType direction)
|
|
||||||
{
|
|
||||||
if (EntityAirPlane == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return direction switch
|
|
||||||
{
|
|
||||||
//влево
|
|
||||||
DirectionType.Left => _startPosX - EntityAirPlane.Step > 0,
|
|
||||||
//вверх
|
|
||||||
DirectionType.Up => _startPosY - EntityAirPlane.Step > 0,
|
|
||||||
// вправо
|
|
||||||
DirectionType.Right => _startPosX + EntityAirPlane.Step + _airPlaneWidth < _pictureWidth,
|
|
||||||
//вниз
|
|
||||||
DirectionType.Down => _startPosY + EntityAirPlane.Step + _airPlaneHeight < _pictureHeight,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение направления перемещения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
public void MovePlane(DirectionType direction)
|
|
||||||
{
|
|
||||||
if (!CanMove(direction) || EntityAirPlane == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
//влево
|
|
||||||
case DirectionType.Left:
|
|
||||||
_startPosX -= (int)EntityAirPlane.Step;
|
|
||||||
break;
|
|
||||||
//вверх
|
|
||||||
case DirectionType.Up:
|
|
||||||
_startPosY -= (int)EntityAirPlane.Step;
|
|
||||||
break;
|
|
||||||
// вправо
|
|
||||||
case DirectionType.Right:
|
|
||||||
_startPosX += (int)EntityAirPlane.Step;
|
|
||||||
break;
|
|
||||||
//вниз
|
|
||||||
case DirectionType.Down:
|
|
||||||
_startPosY += (int)EntityAirPlane.Step;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта IMoveableObject из объекта DrawningAirPlane
|
|
||||||
/// </summary>
|
|
||||||
public IMoveableObject GetMoveableObject => new
|
|
||||||
DrawningObjectAirPlane(this);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public class DrawningObjectAirPlane : IMoveableObject
|
|
||||||
{
|
|
||||||
private readonly DrawningAirPlane? _drawningAirPlane = null;
|
|
||||||
public DrawningObjectAirPlane(DrawningAirPlane drawningAirPlane)
|
|
||||||
{
|
|
||||||
_drawningAirPlane = drawningAirPlane;
|
|
||||||
}
|
|
||||||
public ObjectParameters? GetObjectPosition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_drawningAirPlane == null || _drawningAirPlane.EntityAirPlane ==
|
|
||||||
null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ObjectParameters(_drawningAirPlane.GetPosX,
|
|
||||||
_drawningAirPlane.GetPosY, _drawningAirPlane.GetWidth, _drawningAirPlane.GetHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int GetStep => (int)(_drawningAirPlane?.EntityAirPlane?.Step ?? 0);
|
|
||||||
public bool CheckCanMove(DirectionType direction) =>
|
|
||||||
_drawningAirPlane?.CanMove(direction) ?? false;
|
|
||||||
public void MoveObject(DirectionType direction) =>
|
|
||||||
_drawningAirPlane?.MovePlane(direction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AirBomber;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public class EntityAirBomber : EntityAirPlane
|
|
||||||
{
|
|
||||||
public Color AdditionalColor { get; private set; }
|
|
||||||
public bool Bombs { get; private set; }
|
|
||||||
public Color BombsColor { get; private set; }
|
|
||||||
public bool FuelTanks { get; private set; }
|
|
||||||
public EntityAirBomber(int speed, double weight, Color bodyColor, Color
|
|
||||||
additionalColor, bool bombs, bool fuelTanks) : base(speed, weight, bodyColor)
|
|
||||||
{
|
|
||||||
AdditionalColor = additionalColor;
|
|
||||||
Bombs = bombs;
|
|
||||||
FuelTanks = fuelTanks;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AirBomber;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public class EntityAirPlane
|
|
||||||
{
|
|
||||||
/// <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 => (double)Speed * 100 / Weight;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор с параметрами
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес самолета</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
public EntityAirPlane(int speed, double weight, Color bodyColor)
|
|
||||||
{
|
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
39
AirBomber/AirBomber/Form1.Designer.cs
generated
Normal file
39
AirBomber/AirBomber/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace AirBomber
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Text = "Form1";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
10
AirBomber/AirBomber/Form1.cs
Normal file
10
AirBomber/AirBomber/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace AirBomber
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -117,17 +117,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
|
||||||
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
</root>
|
190
AirBomber/AirBomber/FormAirBomber.Designer.cs
generated
190
AirBomber/AirBomber/FormAirBomber.Designer.cs
generated
@ -1,190 +0,0 @@
|
|||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
partial class FormAirBomber
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
buttonCreateAirBomber = new Button();
|
|
||||||
buttonDown = new Button();
|
|
||||||
buttonLeft = new Button();
|
|
||||||
buttonRight = new Button();
|
|
||||||
buttonUp = new Button();
|
|
||||||
pictureBoxAirBomber = new PictureBox();
|
|
||||||
comboBoxStrategy = new ComboBox();
|
|
||||||
buttonCreateAirPlane = new Button();
|
|
||||||
buttonStrategyStep = new Button();
|
|
||||||
buttonSelectPlane = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCreateAirBomber
|
|
||||||
//
|
|
||||||
buttonCreateAirBomber.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreateAirBomber.Location = new Point(29, 447);
|
|
||||||
buttonCreateAirBomber.Name = "buttonCreateAirBomber";
|
|
||||||
buttonCreateAirBomber.Size = new Size(191, 66);
|
|
||||||
buttonCreateAirBomber.TabIndex = 0;
|
|
||||||
buttonCreateAirBomber.Text = "Создать бомбардировщик";
|
|
||||||
buttonCreateAirBomber.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateAirBomber.Click += buttonCreateAirBomber_Click;
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
|
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonDown.Location = new Point(842, 483);
|
|
||||||
buttonDown.Name = "buttonDown";
|
|
||||||
buttonDown.Size = new Size(30, 30);
|
|
||||||
buttonDown.TabIndex = 1;
|
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
buttonDown.Click += buttonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
|
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonLeft.Location = new Point(806, 483);
|
|
||||||
buttonLeft.Name = "buttonLeft";
|
|
||||||
buttonLeft.Size = new Size(30, 30);
|
|
||||||
buttonLeft.TabIndex = 2;
|
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
buttonLeft.Click += buttonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
|
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonRight.Location = new Point(878, 483);
|
|
||||||
buttonRight.Name = "buttonRight";
|
|
||||||
buttonRight.Size = new Size(30, 30);
|
|
||||||
buttonRight.TabIndex = 3;
|
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
buttonRight.Click += buttonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
|
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonUp.Location = new Point(842, 447);
|
|
||||||
buttonUp.Name = "buttonUp";
|
|
||||||
buttonUp.Size = new Size(30, 30);
|
|
||||||
buttonUp.TabIndex = 4;
|
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
buttonUp.Click += buttonMove_Click;
|
|
||||||
//
|
|
||||||
// pictureBoxAirBomber
|
|
||||||
//
|
|
||||||
pictureBoxAirBomber.BackColor = SystemColors.Control;
|
|
||||||
pictureBoxAirBomber.Dock = DockStyle.Fill;
|
|
||||||
pictureBoxAirBomber.Location = new Point(0, 0);
|
|
||||||
pictureBoxAirBomber.Name = "pictureBoxAirBomber";
|
|
||||||
pictureBoxAirBomber.Size = new Size(986, 540);
|
|
||||||
pictureBoxAirBomber.TabIndex = 5;
|
|
||||||
pictureBoxAirBomber.TabStop = false;
|
|
||||||
//
|
|
||||||
// comboBoxStrategy
|
|
||||||
//
|
|
||||||
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
|
||||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxStrategy.FormattingEnabled = true;
|
|
||||||
comboBoxStrategy.Items.AddRange(new object[] { "MoveToCenter", "MoveToBorder" });
|
|
||||||
comboBoxStrategy.Location = new Point(755, 26);
|
|
||||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
|
||||||
comboBoxStrategy.Size = new Size(219, 33);
|
|
||||||
comboBoxStrategy.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// buttonCreateAirPlane
|
|
||||||
//
|
|
||||||
buttonCreateAirPlane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreateAirPlane.Location = new Point(249, 447);
|
|
||||||
buttonCreateAirPlane.Name = "buttonCreateAirPlane";
|
|
||||||
buttonCreateAirPlane.Size = new Size(191, 65);
|
|
||||||
buttonCreateAirPlane.TabIndex = 7;
|
|
||||||
buttonCreateAirPlane.Text = "Создать самолёт";
|
|
||||||
buttonCreateAirPlane.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateAirPlane.Click += buttonCreateAirPlane_Click;
|
|
||||||
//
|
|
||||||
// buttonStrategyStep
|
|
||||||
//
|
|
||||||
buttonStrategyStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
|
||||||
buttonStrategyStep.Location = new Point(862, 77);
|
|
||||||
buttonStrategyStep.Name = "buttonStrategyStep";
|
|
||||||
buttonStrategyStep.Size = new Size(112, 49);
|
|
||||||
buttonStrategyStep.TabIndex = 8;
|
|
||||||
buttonStrategyStep.Text = "Шаг";
|
|
||||||
buttonStrategyStep.UseVisualStyleBackColor = true;
|
|
||||||
buttonStrategyStep.Click += buttonStrategyStep_Click;
|
|
||||||
//
|
|
||||||
// buttonSelectPlane
|
|
||||||
//
|
|
||||||
buttonSelectPlane.Location = new Point(862, 178);
|
|
||||||
buttonSelectPlane.Name = "buttonSelectPlane";
|
|
||||||
buttonSelectPlane.Size = new Size(110, 91);
|
|
||||||
buttonSelectPlane.TabIndex = 9;
|
|
||||||
buttonSelectPlane.Text = "Выбрать самолет";
|
|
||||||
buttonSelectPlane.UseVisualStyleBackColor = true;
|
|
||||||
buttonSelectPlane.Click += buttonSelectPlane_Click;
|
|
||||||
//
|
|
||||||
// FormAirBomber
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(986, 540);
|
|
||||||
Controls.Add(buttonSelectPlane);
|
|
||||||
Controls.Add(buttonStrategyStep);
|
|
||||||
Controls.Add(buttonCreateAirPlane);
|
|
||||||
Controls.Add(comboBoxStrategy);
|
|
||||||
Controls.Add(buttonUp);
|
|
||||||
Controls.Add(buttonRight);
|
|
||||||
Controls.Add(buttonLeft);
|
|
||||||
Controls.Add(buttonDown);
|
|
||||||
Controls.Add(buttonCreateAirBomber);
|
|
||||||
Controls.Add(pictureBoxAirBomber);
|
|
||||||
Name = "FormAirBomber";
|
|
||||||
Text = "Бомбардировщик";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCreateAirBomber;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonRight;
|
|
||||||
private Button buttonUp;
|
|
||||||
private PictureBox pictureBoxAirBomber;
|
|
||||||
private ComboBox comboBoxStrategy;
|
|
||||||
private Button buttonCreateAirPlane;
|
|
||||||
private Button buttonStrategyStep;
|
|
||||||
private Button buttonSelectPlane;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public partial class FormAirBomber : Form
|
|
||||||
{
|
|
||||||
private DrawningAirPlane? _drawningAirPlane;
|
|
||||||
/// <summary>
|
|
||||||
/// Стратегия перемещения
|
|
||||||
/// </summary>
|
|
||||||
private AbstractStrategy? _strategy;
|
|
||||||
/// <summary>
|
|
||||||
/// Выбранный самолет
|
|
||||||
/// </summary>
|
|
||||||
public DrawningAirPlane? SelectedPlane { get; private set; }
|
|
||||||
|
|
||||||
public FormAirBomber()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_strategy = null;
|
|
||||||
SelectedPlane = null;
|
|
||||||
}
|
|
||||||
private void Draw()
|
|
||||||
{
|
|
||||||
if (_drawningAirPlane == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bitmap bmp = new(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_drawningAirPlane.DrawPlane(gr);
|
|
||||||
pictureBoxAirBomber.Image = bmp;
|
|
||||||
}
|
|
||||||
private void buttonCreateAirBomber_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
|
||||||
ColorDialog colorDialog = new ColorDialog();
|
|
||||||
//TODO выбор основного цвета DONE
|
|
||||||
if (colorDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = colorDialog.Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
|
||||||
//TODO выбор дополнительного цвета DONE
|
|
||||||
if (colorDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
dopColor = colorDialog.Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
_drawningAirPlane = new DrawningAirBomber(random.Next(100, 300), random.Next(1000, 3000), color, dopColor,
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
|
||||||
|
|
||||||
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
private void buttonCreateAirPlane_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
_drawningAirPlane = new DrawningAirPlane(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
|
||||||
|
|
||||||
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
Draw();
|
|
||||||
|
|
||||||
}
|
|
||||||
private void buttonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningAirPlane == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
_drawningAirPlane.MovePlane(DirectionType.Up);
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
_drawningAirPlane.MovePlane(DirectionType.Down);
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
_drawningAirPlane.MovePlane(DirectionType.Left);
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
_drawningAirPlane.MovePlane(DirectionType.Right);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
private void buttonStrategyStep_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningAirPlane == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxStrategy.Enabled)
|
|
||||||
{
|
|
||||||
_strategy = comboBoxStrategy.SelectedIndex switch
|
|
||||||
{
|
|
||||||
0 => new MoveToCenter(),
|
|
||||||
1 => new MoveToBorder(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_strategy.SetData(_drawningAirPlane.GetMoveableObject,
|
|
||||||
pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
|
||||||
}
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
_strategy.MakeStep();
|
|
||||||
Draw();
|
|
||||||
if (_strategy.GetStatus() == Status.Finish)
|
|
||||||
{
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
_strategy = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Выбор самолета
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void buttonSelectPlane_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
SelectedPlane = _drawningAirPlane;
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
191
AirBomber/AirBomber/FormPlaneCollection.Designer.cs
generated
191
AirBomber/AirBomber/FormPlaneCollection.Designer.cs
generated
@ -1,191 +0,0 @@
|
|||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
partial class FormPlaneCollection
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
pictureBoxCollection = new PictureBox();
|
|
||||||
buttonAddPlane = new Button();
|
|
||||||
buttonRemovePlane = new Button();
|
|
||||||
buttonRefreshCollection = new Button();
|
|
||||||
maskedTextBoxNumber = new MaskedTextBox();
|
|
||||||
groupBoxTools = new GroupBox();
|
|
||||||
groupBoxStorages = new GroupBox();
|
|
||||||
textBoxStorageName = new TextBox();
|
|
||||||
buttonDelObject = new Button();
|
|
||||||
buttonAddObject = new Button();
|
|
||||||
listBoxStorages = new ListBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
|
||||||
groupBoxTools.SuspendLayout();
|
|
||||||
groupBoxStorages.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// pictureBoxCollection
|
|
||||||
//
|
|
||||||
pictureBoxCollection.BackColor = SystemColors.Control;
|
|
||||||
pictureBoxCollection.Dock = DockStyle.Left;
|
|
||||||
pictureBoxCollection.Location = new Point(0, 0);
|
|
||||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
|
||||||
pictureBoxCollection.Size = new Size(708, 746);
|
|
||||||
pictureBoxCollection.TabIndex = 0;
|
|
||||||
pictureBoxCollection.TabStop = false;
|
|
||||||
//
|
|
||||||
// buttonAddPlane
|
|
||||||
//
|
|
||||||
buttonAddPlane.Location = new Point(76, 417);
|
|
||||||
buttonAddPlane.Name = "buttonAddPlane";
|
|
||||||
buttonAddPlane.Size = new Size(160, 64);
|
|
||||||
buttonAddPlane.TabIndex = 0;
|
|
||||||
buttonAddPlane.Text = "Добавить самолет";
|
|
||||||
buttonAddPlane.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddPlane.Click += buttonAddPlane_Click;
|
|
||||||
//
|
|
||||||
// buttonRemovePlane
|
|
||||||
//
|
|
||||||
buttonRemovePlane.Location = new Point(76, 549);
|
|
||||||
buttonRemovePlane.Name = "buttonRemovePlane";
|
|
||||||
buttonRemovePlane.Size = new Size(160, 60);
|
|
||||||
buttonRemovePlane.TabIndex = 1;
|
|
||||||
buttonRemovePlane.Text = "Удалить самолет";
|
|
||||||
buttonRemovePlane.UseVisualStyleBackColor = true;
|
|
||||||
buttonRemovePlane.Click += buttonRemovePlane_Click;
|
|
||||||
//
|
|
||||||
// buttonRefreshCollection
|
|
||||||
//
|
|
||||||
buttonRefreshCollection.Location = new Point(76, 648);
|
|
||||||
buttonRefreshCollection.Name = "buttonRefreshCollection";
|
|
||||||
buttonRefreshCollection.Size = new Size(160, 86);
|
|
||||||
buttonRefreshCollection.TabIndex = 2;
|
|
||||||
buttonRefreshCollection.Text = "Обновить коллекцию";
|
|
||||||
buttonRefreshCollection.UseVisualStyleBackColor = true;
|
|
||||||
buttonRefreshCollection.Click += buttonRefreshCollection_Click;
|
|
||||||
//
|
|
||||||
// maskedTextBoxNumber
|
|
||||||
//
|
|
||||||
maskedTextBoxNumber.Location = new Point(76, 501);
|
|
||||||
maskedTextBoxNumber.Mask = "00";
|
|
||||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
|
||||||
maskedTextBoxNumber.Size = new Size(160, 31);
|
|
||||||
maskedTextBoxNumber.TabIndex = 3;
|
|
||||||
maskedTextBoxNumber.ValidatingType = typeof(int);
|
|
||||||
//
|
|
||||||
// groupBoxTools
|
|
||||||
//
|
|
||||||
groupBoxTools.Controls.Add(groupBoxStorages);
|
|
||||||
groupBoxTools.Controls.Add(buttonAddPlane);
|
|
||||||
groupBoxTools.Controls.Add(buttonRefreshCollection);
|
|
||||||
groupBoxTools.Controls.Add(buttonRemovePlane);
|
|
||||||
groupBoxTools.Controls.Add(maskedTextBoxNumber);
|
|
||||||
groupBoxTools.Location = new Point(714, 0);
|
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
|
||||||
groupBoxTools.Size = new Size(305, 746);
|
|
||||||
groupBoxTools.TabIndex = 4;
|
|
||||||
groupBoxTools.TabStop = false;
|
|
||||||
groupBoxTools.Text = "Инструменты";
|
|
||||||
//
|
|
||||||
// groupBoxStorages
|
|
||||||
//
|
|
||||||
groupBoxStorages.Controls.Add(textBoxStorageName);
|
|
||||||
groupBoxStorages.Controls.Add(buttonDelObject);
|
|
||||||
groupBoxStorages.Controls.Add(buttonAddObject);
|
|
||||||
groupBoxStorages.Controls.Add(listBoxStorages);
|
|
||||||
groupBoxStorages.Location = new Point(5, 30);
|
|
||||||
groupBoxStorages.Name = "groupBoxStorages";
|
|
||||||
groupBoxStorages.Size = new Size(294, 368);
|
|
||||||
groupBoxStorages.TabIndex = 4;
|
|
||||||
groupBoxStorages.TabStop = false;
|
|
||||||
groupBoxStorages.Text = "Наборы";
|
|
||||||
//
|
|
||||||
// textBoxStorageName
|
|
||||||
//
|
|
||||||
textBoxStorageName.Location = new Point(6, 54);
|
|
||||||
textBoxStorageName.Name = "textBoxStorageName";
|
|
||||||
textBoxStorageName.Size = new Size(281, 31);
|
|
||||||
textBoxStorageName.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// buttonDelObject
|
|
||||||
//
|
|
||||||
buttonDelObject.Location = new Point(44, 305);
|
|
||||||
buttonDelObject.Name = "buttonDelObject";
|
|
||||||
buttonDelObject.Size = new Size(209, 34);
|
|
||||||
buttonDelObject.TabIndex = 2;
|
|
||||||
buttonDelObject.Text = "Удалить набор";
|
|
||||||
buttonDelObject.UseVisualStyleBackColor = true;
|
|
||||||
buttonDelObject.Click += buttonDelObject_Click;
|
|
||||||
//
|
|
||||||
// buttonAddObject
|
|
||||||
//
|
|
||||||
buttonAddObject.Location = new Point(44, 106);
|
|
||||||
buttonAddObject.Name = "buttonAddObject";
|
|
||||||
buttonAddObject.Size = new Size(209, 34);
|
|
||||||
buttonAddObject.TabIndex = 1;
|
|
||||||
buttonAddObject.Text = "Добавить набор";
|
|
||||||
buttonAddObject.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddObject.Click += buttonAddObject_Click;
|
|
||||||
//
|
|
||||||
// listBoxStorages
|
|
||||||
//
|
|
||||||
listBoxStorages.FormattingEnabled = true;
|
|
||||||
listBoxStorages.ItemHeight = 25;
|
|
||||||
listBoxStorages.Location = new Point(6, 160);
|
|
||||||
listBoxStorages.Name = "listBoxStorages";
|
|
||||||
listBoxStorages.Size = new Size(281, 129);
|
|
||||||
listBoxStorages.TabIndex = 0;
|
|
||||||
listBoxStorages.SelectedIndexChanged += listBoxStorages_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// FormPlaneCollection
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(1030, 746);
|
|
||||||
Controls.Add(groupBoxTools);
|
|
||||||
Controls.Add(pictureBoxCollection);
|
|
||||||
Name = "FormPlaneCollection";
|
|
||||||
Text = "Набор самолетов";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
|
||||||
groupBoxTools.ResumeLayout(false);
|
|
||||||
groupBoxTools.PerformLayout();
|
|
||||||
groupBoxStorages.ResumeLayout(false);
|
|
||||||
groupBoxStorages.PerformLayout();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private PictureBox pictureBoxCollection;
|
|
||||||
private Button buttonAddPlane;
|
|
||||||
private Button buttonRemovePlane;
|
|
||||||
private Button buttonRefreshCollection;
|
|
||||||
private MaskedTextBox maskedTextBoxNumber;
|
|
||||||
private GroupBox groupBoxTools;
|
|
||||||
private GroupBox groupBoxStorages;
|
|
||||||
private TextBox textBoxStorageName;
|
|
||||||
private Button buttonDelObject;
|
|
||||||
private Button buttonAddObject;
|
|
||||||
private ListBox listBoxStorages;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,162 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public partial class FormPlaneCollection : Form
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Набор объектов
|
|
||||||
/// </summary>
|
|
||||||
private readonly PlanesGenericStorage _storage;
|
|
||||||
public FormPlaneCollection()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_storage = new PlanesGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Заполнение listBoxObjects
|
|
||||||
/// </summary>
|
|
||||||
private void ReloadObjects()
|
|
||||||
{
|
|
||||||
int index = listBoxStorages.SelectedIndex;
|
|
||||||
|
|
||||||
listBoxStorages.Items.Clear();
|
|
||||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
|
||||||
{
|
|
||||||
listBoxStorages.Items.Add(_storage.Keys[i]);
|
|
||||||
}
|
|
||||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
|
||||||
{
|
|
||||||
listBoxStorages.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
|
|
||||||
{
|
|
||||||
listBoxStorages.SelectedIndex = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Выбор набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString()?? string.Empty]?.ShowPlanes();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в набор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void buttonAddPlane_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString()?? string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FormAirBomber form = new();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (obj + form.SelectedPlane > -1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление объекта из набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void buttonRemovePlane_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
|
||||||
if (obj - pos != null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект удален");
|
|
||||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Обновление рисунка по набору
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void buttonRefreshCollection_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление набора в коллекцию
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void buttonAddObject_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_storage.AddSet(textBoxStorageName.Text);
|
|
||||||
ReloadObjects();
|
|
||||||
}
|
|
||||||
private void buttonDelObject_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show($"Удалить объект{listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
_storage.DelSet(listBoxStorages.SelectedItem.ToString()?? string.Empty);
|
|
||||||
ReloadObjects();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public interface IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Получение координаты X объекта
|
|
||||||
/// </summary>
|
|
||||||
ObjectParameters? GetObjectPosition { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
int GetStep { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка, можно ли переместиться по нужному направлению
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
bool CheckCanMove(DirectionType direction);
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение направления пермещения объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
void MoveObject(DirectionType direction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public class MoveToBorder : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null) return false;
|
|
||||||
|
|
||||||
return objParams.RightBorder >= FieldWidth - GetStep() && objParams.DownBorder >= FieldHeight - GetStep();
|
|
||||||
}
|
|
||||||
protected override void MoveToTarget()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null) return;
|
|
||||||
if (objParams.RightBorder < FieldWidth - GetStep()) MoveRight();
|
|
||||||
if (objParams.DownBorder < FieldHeight - GetStep()) MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public class MoveToCenter : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
|
|
||||||
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
|
||||||
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
|
|
||||||
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
|
||||||
}
|
|
||||||
protected override void MoveToTarget()
|
|
||||||
{
|
|
||||||
var objParams = GetObjectParameters;
|
|
||||||
if (objParams == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
|
||||||
if (Math.Abs(diffX) > GetStep())
|
|
||||||
{
|
|
||||||
if (diffX > 0)
|
|
||||||
{
|
|
||||||
MoveLeft();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveRight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
|
||||||
if (Math.Abs(diffY) > GetStep())
|
|
||||||
{
|
|
||||||
if (diffY > 0)
|
|
||||||
{
|
|
||||||
MoveUp();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public class ObjectParameters
|
|
||||||
{
|
|
||||||
private readonly int _x;
|
|
||||||
private readonly int _y;
|
|
||||||
private readonly int _width;
|
|
||||||
private readonly int _height;
|
|
||||||
/// <summary>
|
|
||||||
/// Левая граница
|
|
||||||
/// </summary>
|
|
||||||
public int LeftBorder => _x;
|
|
||||||
/// <summary>
|
|
||||||
/// Верхняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int TopBorder => _y;
|
|
||||||
/// <summary>
|
|
||||||
/// Правая граница
|
|
||||||
/// </summary>
|
|
||||||
public int RightBorder => _x + _width;
|
|
||||||
/// <summary>
|
|
||||||
/// Нижняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int DownBorder => _y + _height;
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleVertical => _y + _height / 2;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
/// <param name="width">Ширина</param>
|
|
||||||
/// <param name="height">Высота</param>
|
|
||||||
public ObjectParameters(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
_x = x;
|
|
||||||
_y = y;
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
internal class PlanesGenericCollection<T, U>
|
|
||||||
where T : DrawningAirPlane
|
|
||||||
where U : IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна прорисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна прорисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Размер занимаемого объектом места (ширина)
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _placeSizeWidth = 170;
|
|
||||||
/// <summary>
|
|
||||||
/// Размер занимаемого объектом места (высота)
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _placeSizeHeight = 120;
|
|
||||||
/// <summary>
|
|
||||||
/// Набор объектов
|
|
||||||
/// </summary>
|
|
||||||
private readonly SetGeneric<T> _collection;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="picWidth"></param>
|
|
||||||
/// <param name="picHeight"></param>
|
|
||||||
public PlanesGenericCollection(int picWidth, int picHeight)
|
|
||||||
{
|
|
||||||
int width = picWidth / _placeSizeWidth;
|
|
||||||
int height = picHeight / _placeSizeHeight;
|
|
||||||
_pictureWidth = picWidth;
|
|
||||||
_pictureHeight = picHeight;
|
|
||||||
_collection = new SetGeneric<T>(width * height);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора сложения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="collect"></param>
|
|
||||||
/// <param name="obj"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static int operator +(PlanesGenericCollection<T, U> collect, T? obj)
|
|
||||||
{
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return collect?._collection.Insert(obj) ?? -1;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора вычитания
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="collect"></param>
|
|
||||||
/// <param name="pos"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool operator -(PlanesGenericCollection<T, U> collect, int pos)
|
|
||||||
{
|
|
||||||
T? obj = collect._collection[pos];
|
|
||||||
if (obj != null)
|
|
||||||
{
|
|
||||||
collect._collection.Remove(pos);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта IMoveableObject
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pos"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public U? GetU(int pos)
|
|
||||||
{
|
|
||||||
return (U?)_collection[pos]?.GetMoveableObject;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод всего набора объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public Bitmap ShowPlanes()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
DrawBackground(gr);
|
|
||||||
DrawObjects(gr);
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Метод отрисовки фона
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
private void DrawBackground(Graphics g)
|
|
||||||
{
|
|
||||||
Pen pen = new(Color.Black, 3);
|
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
|
||||||
{
|
|
||||||
//линия рамзетки места
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
|
||||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
|
||||||
}
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Метод прорисовки объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
private void DrawObjects(Graphics g)
|
|
||||||
{
|
|
||||||
int widthObjCount = _pictureWidth / _placeSizeWidth;
|
|
||||||
for (int i = 0; i < _collection.Count; i++)
|
|
||||||
{
|
|
||||||
T? type = _collection[i];
|
|
||||||
if (type != null)
|
|
||||||
{
|
|
||||||
int row = i / widthObjCount;
|
|
||||||
int col = widthObjCount - 1 - (i % widthObjCount);
|
|
||||||
|
|
||||||
type.SetPosition(col * _placeSizeWidth, row * _placeSizeHeight);
|
|
||||||
type?.DrawPlane(g);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
internal class PlanesGenericStorage
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Словарь (хранилище)
|
|
||||||
/// </summary>
|
|
||||||
readonly Dictionary<string, PlanesGenericCollection<DrawningAirPlane, DrawningObjectAirPlane>> _planeStorages;
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращение списка названий наборов
|
|
||||||
/// </summary>
|
|
||||||
public List<string> Keys => _planeStorages.Keys.ToList();
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна отрисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна отрисовки
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pictureWidth"></param>
|
|
||||||
/// <param name="pictureHeight"></param>
|
|
||||||
public PlanesGenericStorage(int pictureWidth, int pictureHeight)
|
|
||||||
{
|
|
||||||
_planeStorages = new Dictionary<string, PlanesGenericCollection<DrawningAirPlane, DrawningObjectAirPlane>>();
|
|
||||||
_pictureWidth = pictureWidth;
|
|
||||||
_pictureHeight = pictureHeight;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название набора</param>
|
|
||||||
public void AddSet(string name)
|
|
||||||
{
|
|
||||||
// TODO Прописать логику для добавления DONE
|
|
||||||
if (!_planeStorages.ContainsKey(name))
|
|
||||||
{
|
|
||||||
_planeStorages.Add(name, new PlanesGenericCollection<DrawningAirPlane, DrawningObjectAirPlane>(_pictureWidth, _pictureHeight));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление набора
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название набора</param>
|
|
||||||
public void DelSet(string name)
|
|
||||||
{
|
|
||||||
// TODO Прописать логику для удаления DONE
|
|
||||||
if (_planeStorages.ContainsKey(name))
|
|
||||||
{
|
|
||||||
_planeStorages.Remove(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Доступ к набору
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ind"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public PlanesGenericCollection<DrawningAirPlane, DrawningObjectAirPlane>?
|
|
||||||
this[string ind]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// TODO Продумать логику получения набора DONE
|
|
||||||
if (_planeStorages.ContainsKey(ind))
|
|
||||||
{
|
|
||||||
return _planeStorages[ind];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ namespace AirBomber
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormPlaneCollection());
|
Application.Run(new Form1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
103
AirBomber/AirBomber/Properties/Resources.Designer.cs
generated
103
AirBomber/AirBomber/Properties/Resources.Designer.cs
generated
@ -1,103 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace AirBomber.Properties {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
|
||||||
/// </summary>
|
|
||||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
|
||||||
// с помощью такого средства, как ResGen или Visual Studio.
|
|
||||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
|
||||||
// с параметром /str или перестройте свой проект VS.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AirBomber.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
|
||||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap arrowDown {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap arrowLeft {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap arrowRight {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap arrowUp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB |
@ -1,117 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
internal class SetGeneric<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Массив объектов, которые храним
|
|
||||||
/// </summary>
|
|
||||||
private readonly List<T?> _places;
|
|
||||||
/// <summary>
|
|
||||||
/// Количество объектов в массиве
|
|
||||||
/// </summary>
|
|
||||||
public int Count => _places.Count;
|
|
||||||
/// <summary>
|
|
||||||
/// Максимальное количество объектов в списке
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _maxCount;
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="count"></param>
|
|
||||||
public SetGeneric(int count)
|
|
||||||
{
|
|
||||||
_maxCount = count;
|
|
||||||
_places = new List<T?>(count);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в набор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="plane">Добавляемый самолет</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public int Insert(T plane)
|
|
||||||
{
|
|
||||||
//was TODO
|
|
||||||
return Insert(plane, 0);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в набор на конкретную позицию
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="plane">Добавляемый самолет</param>
|
|
||||||
/// <param name="position">Позиция</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public int Insert(T plane, int position)
|
|
||||||
{
|
|
||||||
// TODO проверка позиции DONE
|
|
||||||
// TODO проверка, что элемент массива по этой позиции пустой,если нет, то
|
|
||||||
// проверка, что после вставляемого элемента в массиве есть пустой элемент
|
|
||||||
// сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
|
|
||||||
// TODO вставка по позиции
|
|
||||||
if (position < 0 || position >= _maxCount) return -1;
|
|
||||||
_places.Insert(position, plane);
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление объекта из набора с конкретной позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool Remove(int position)
|
|
||||||
{
|
|
||||||
// TODO проверка позиции DONE
|
|
||||||
// TODO удаление объекта из массива, присвоив элементу массива значение null
|
|
||||||
if (!(position >= 0 && position < Count) || _places[position] == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_places[position] = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта из набора по позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public T? this[int position]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// TODO проверка позиции DONE
|
|
||||||
if (position < 0 || position >= Count)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return _places[position];
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// TODO проверка позиции DONE
|
|
||||||
// TODO проверка свободных мест в списке DONE
|
|
||||||
// TODO вставка в список по позиции DONE
|
|
||||||
if (position < 0 || position >= Count || Count == _maxCount) return;
|
|
||||||
_places.Insert(position, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Проход по списку
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public IEnumerable<T?> GetPlanes(int? maxPlanes = null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _places.Count; ++i)
|
|
||||||
{
|
|
||||||
yield return _places[i];
|
|
||||||
if (maxPlanes.HasValue && i == maxPlanes.Value)
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace AirBomber
|
|
||||||
{
|
|
||||||
public enum Status
|
|
||||||
{
|
|
||||||
NotInit,
|
|
||||||
InProgress,
|
|
||||||
Finish
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user