Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
4de997dcb5 | |||
ce8e5ace33 | |||
e40ae5a4ee | |||
80c26c1b12 |
76
AirFighter/AirFighter/AbstractStrategy.cs
Normal file
76
AirFighter/AirFighter/AbstractStrategy.cs
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using AirFighter.Drawnings;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
|
namespace AirFighter.MovementStrategy
|
||||||
|
{
|
||||||
|
public abstract class AbstractStrategy
|
||||||
|
{
|
||||||
|
private IMoveableObject? _moveableObject;
|
||||||
|
|
||||||
|
private Status _state = Status.NotInit;
|
||||||
|
protected int FieldWidth { get; private set; }
|
||||||
|
protected int FieldHeight { get; private set; }
|
||||||
|
public Status GetStatus() { return _state; }
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
public void MakeStep()
|
||||||
|
{
|
||||||
|
if (_state != Status.InProgress)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (IsTargetDestinaion())
|
||||||
|
{
|
||||||
|
_state = Status.Finish;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MoveToTarget();
|
||||||
|
}
|
||||||
|
protected bool MoveLeft() => MoveTo(DirectionAirFighter.Left);
|
||||||
|
protected bool MoveRight() => MoveTo(DirectionAirFighter.Right);
|
||||||
|
protected bool MoveUp() => MoveTo(DirectionAirFighter.Up);
|
||||||
|
protected bool MoveDown() => MoveTo(DirectionAirFighter.Down);
|
||||||
|
protected ObjectParameters? GetObjectParameters =>
|
||||||
|
_moveableObject?.GetObjectPosition;
|
||||||
|
protected int? GetStep()
|
||||||
|
{
|
||||||
|
if (_state != Status.InProgress)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return _moveableObject?.GetStep;
|
||||||
|
}
|
||||||
|
protected abstract void MoveToTarget();
|
||||||
|
protected abstract bool IsTargetDestinaion();
|
||||||
|
private bool MoveTo(DirectionAirFighter directionType)
|
||||||
|
{
|
||||||
|
if (_state != Status.InProgress)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
||||||
|
{
|
||||||
|
_moveableObject.MoveObject(directionType);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
95
AirFighter/AirFighter/AirFighterGenericCollection.cs
Normal file
95
AirFighter/AirFighter/AirFighterGenericCollection.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
using AirFighter.Drawnings;
|
||||||
|
using AirFighter.MovementStrategy;
|
||||||
|
using AirFighter.DrawningObjects;
|
||||||
|
using AirFighter.Generics;
|
||||||
|
using AirFighter.MovementStrategy;
|
||||||
|
|
||||||
|
namespace AirFighter.Generics
|
||||||
|
{
|
||||||
|
internal class AirFighterGenericCollection<T, U>
|
||||||
|
where T : DrawningAirFighter
|
||||||
|
where U : IMoveableObject
|
||||||
|
{
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
|
||||||
|
private readonly int _placeSizeWidth = 210;
|
||||||
|
|
||||||
|
private readonly int _placeSizeHeight = 180;
|
||||||
|
|
||||||
|
private readonly SetGeneric<T> _collection;
|
||||||
|
public AirFighterGenericCollection(int picWidth, int picHeight)
|
||||||
|
{
|
||||||
|
int width = picWidth / _placeSizeWidth;
|
||||||
|
int height = picHeight / _placeSizeHeight;
|
||||||
|
_pictureWidth = picWidth;
|
||||||
|
_pictureHeight = picHeight;
|
||||||
|
_collection = new SetGeneric<T>(width * height);
|
||||||
|
}
|
||||||
|
public static int? operator +(AirFighterGenericCollection<T, U> collect, T? obj)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return collect?._collection.Insert(obj);
|
||||||
|
}
|
||||||
|
public static bool operator -(AirFighterGenericCollection<T, U> collect, int pos)
|
||||||
|
{
|
||||||
|
T? obj = collect._collection[pos];
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
return collect._collection.Remove(pos);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public U? GetU(int pos)
|
||||||
|
{
|
||||||
|
return (U?)_collection[pos]?.GetMoveableObject;
|
||||||
|
}
|
||||||
|
public Bitmap ShowAirFighter()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
DrawBackground(gr);
|
||||||
|
DrawObjects(gr);
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
private void DrawBackground(Graphics g)
|
||||||
|
{
|
||||||
|
Pen pen = new(Color.Black, 2);
|
||||||
|
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, j *
|
||||||
|
_placeSizeHeight);
|
||||||
|
}
|
||||||
|
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
||||||
|
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void DrawObjects(Graphics g)
|
||||||
|
{
|
||||||
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
|
|
||||||
|
foreach (var fighter in _collection.GetAirFighter())
|
||||||
|
{
|
||||||
|
if (fighter != null)
|
||||||
|
{
|
||||||
|
int index = _collection.GetAirFighter().ToList().IndexOf(fighter);
|
||||||
|
int row = height - 1 - (index / width);
|
||||||
|
int col = width - 1 - (index % width);
|
||||||
|
|
||||||
|
fighter.SetPosition(col * _placeSizeWidth + 10, row * _placeSizeHeight + 5);
|
||||||
|
}
|
||||||
|
fighter.DrawTransport(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
55
AirFighter/AirFighter/AirFighterGenericStorage.cs
Normal file
55
AirFighter/AirFighter/AirFighterGenericStorage.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using AirFighter.Drawnings;
|
||||||
|
using AirFighter.MovementStrategy;
|
||||||
|
using AirFighter.DrawningObjects;
|
||||||
|
|
||||||
|
namespace AirFighter.Generics
|
||||||
|
{
|
||||||
|
internal class AirFighterGenericStorage
|
||||||
|
{
|
||||||
|
readonly Dictionary<string, AirFighterGenericCollection<DrawningAirFighter, DrawningObjectAirFighter>> _AirFighterStorages;
|
||||||
|
public List<string> Keys => _AirFighterStorages.Keys.ToList();
|
||||||
|
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
public AirFighterGenericStorage(int pictureWidth, int pictureHeight)
|
||||||
|
{
|
||||||
|
_AirFighterStorages = new Dictionary<string, AirFighterGenericCollection<DrawningAirFighter, DrawningObjectAirFighter>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
public void AddSet(string name)
|
||||||
|
{
|
||||||
|
if (!_AirFighterStorages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
var fighterCollection = new AirFighterGenericCollection<DrawningAirFighter, DrawningObjectAirFighter>(_pictureWidth, _pictureHeight);
|
||||||
|
_AirFighterStorages.Add(name, fighterCollection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DelSet(string name)
|
||||||
|
{
|
||||||
|
if (_AirFighterStorages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
_AirFighterStorages.Remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public AirFighterGenericCollection<DrawningAirFighter, DrawningObjectAirFighter>? this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_AirFighterStorages.ContainsKey(ind))
|
||||||
|
{
|
||||||
|
return _AirFighterStorages[ind];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
19
AirFighter/AirFighter/DirectionAirFighter.cs
Normal file
19
AirFighter/AirFighter/DirectionAirFighter.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter.Drawnings
|
||||||
|
{
|
||||||
|
public enum DirectionAirFighter
|
||||||
|
{
|
||||||
|
Up = 1,
|
||||||
|
|
||||||
|
Down = 2,
|
||||||
|
|
||||||
|
Left = 3,
|
||||||
|
|
||||||
|
Right = 4
|
||||||
|
}
|
||||||
|
}
|
173
AirFighter/AirFighter/DrawningAirFighter.cs
Normal file
173
AirFighter/AirFighter/DrawningAirFighter.cs
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using AirFighter.Entities;
|
||||||
|
using AirFighter.Drawnings;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using AirFighter.MovementStrategy;
|
||||||
|
|
||||||
|
namespace AirFighter.DrawningObjects
|
||||||
|
{
|
||||||
|
public class DrawningAirFighter
|
||||||
|
{
|
||||||
|
public EntityAirFighter? EntityAirFighter { get; protected set; }
|
||||||
|
|
||||||
|
private int _pictureWidth;
|
||||||
|
|
||||||
|
private int _pictureHeight;
|
||||||
|
|
||||||
|
protected int _startPosX;
|
||||||
|
|
||||||
|
protected int _startPosY;
|
||||||
|
|
||||||
|
protected readonly int _fighterWidth = 195;
|
||||||
|
|
||||||
|
protected readonly int _fighterHeight = 166;
|
||||||
|
|
||||||
|
public DrawningAirFighter(int speed, double weight, Color bodyColor, int width, int height)
|
||||||
|
{
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
EntityAirFighter = new EntityAirFighter(speed, weight, bodyColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DrawningAirFighter(int speed, double weight, Color bodyColor, int
|
||||||
|
width, int height, int fighterWidth, int fighterHeight)
|
||||||
|
{
|
||||||
|
if (width <= _pictureWidth || height <= _pictureHeight)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
_fighterWidth = fighterWidth;
|
||||||
|
_fighterHeight = fighterHeight;
|
||||||
|
EntityAirFighter = new EntityAirFighter(speed, weight, bodyColor);
|
||||||
|
}
|
||||||
|
public void SetPosition(int x, int y)
|
||||||
|
{
|
||||||
|
if (x < 0)
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
else if (x > _pictureWidth - _fighterWidth)
|
||||||
|
{
|
||||||
|
x = _pictureWidth - _fighterWidth;
|
||||||
|
}
|
||||||
|
if (y < 0)
|
||||||
|
{
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
else if (y > _pictureHeight - _fighterHeight)
|
||||||
|
{
|
||||||
|
y = _pictureHeight - _fighterHeight;
|
||||||
|
}
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
}
|
||||||
|
public IMoveableObject GetMoveableObject => new DrawningObjectAirFighter(this);
|
||||||
|
public int GetPosX => _startPosX;
|
||||||
|
public int GetPosY => _startPosY;
|
||||||
|
public int GetWidth => _fighterWidth;
|
||||||
|
public int GetHeight => _fighterHeight;
|
||||||
|
public virtual bool CanMove(DirectionAirFighter direction)
|
||||||
|
{
|
||||||
|
if (EntityAirFighter == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return direction switch
|
||||||
|
{
|
||||||
|
DirectionAirFighter.Left => _startPosX - EntityAirFighter.Step > 0,
|
||||||
|
|
||||||
|
DirectionAirFighter.Up => _startPosY - EntityAirFighter.Step > 7,
|
||||||
|
|
||||||
|
DirectionAirFighter.Right => _startPosX + EntityAirFighter.Step + _fighterWidth < _pictureWidth,// TODO: Продумать логику
|
||||||
|
|
||||||
|
DirectionAirFighter.Down => _startPosY + EntityAirFighter.Step + _fighterHeight < _pictureHeight,// TODO: Продумать логику
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public virtual void MoveTransport(DirectionAirFighter direction)
|
||||||
|
{
|
||||||
|
if (!CanMove(direction) || EntityAirFighter == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case DirectionAirFighter.Left:
|
||||||
|
_startPosX -= (int)EntityAirFighter.Step;
|
||||||
|
break;
|
||||||
|
case DirectionAirFighter.Up:
|
||||||
|
_startPosY -= (int)EntityAirFighter.Step;
|
||||||
|
break;
|
||||||
|
case DirectionAirFighter.Right:
|
||||||
|
_startPosX += (int)EntityAirFighter.Step;
|
||||||
|
break;
|
||||||
|
case DirectionAirFighter.Down:
|
||||||
|
_startPosY += (int)EntityAirFighter.Step;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public virtual void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (EntityAirFighter == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pen pen = new(EntityAirFighter.BodyColor, 2);
|
||||||
|
Brush brushBlack = new SolidBrush(EntityAirFighter.BodyColor);
|
||||||
|
|
||||||
|
PointF[] front = {
|
||||||
|
new(_startPosX + 160, _startPosY + 69),
|
||||||
|
new(_startPosX + 195, _startPosY + 83),
|
||||||
|
new(_startPosX + 160, _startPosY + 97)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] tailTop = {
|
||||||
|
new(_startPosX, _startPosY + 30),
|
||||||
|
new(_startPosX, _startPosY + 70),
|
||||||
|
new(_startPosX + 25, _startPosY + 70),
|
||||||
|
new(_startPosX + 25, _startPosY + 55)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] tailBottom = {
|
||||||
|
new(_startPosX, _startPosY + 96),
|
||||||
|
new(_startPosX, _startPosY + 136),
|
||||||
|
new(_startPosX + 25, _startPosY + 111),
|
||||||
|
new(_startPosX + 25, _startPosY + 96)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] wingTop =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY),
|
||||||
|
new(_startPosX + 100, _startPosY + 70),
|
||||||
|
new(_startPosX + 75, _startPosY + 70),
|
||||||
|
new(_startPosX + 90, _startPosY),
|
||||||
|
};
|
||||||
|
PointF[] wingBottom =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY + 96),
|
||||||
|
new(_startPosX + 100, _startPosY + 166),
|
||||||
|
new(_startPosX + 90, _startPosY + 166),
|
||||||
|
new(_startPosX + 75, _startPosY + 96),
|
||||||
|
};
|
||||||
|
|
||||||
|
g.DrawPolygon(pen, tailTop);
|
||||||
|
g.DrawPolygon(pen, tailBottom);
|
||||||
|
g.DrawPolygon(pen, wingTop);
|
||||||
|
g.DrawPolygon(pen, wingBottom);
|
||||||
|
g.DrawRectangle(pen, _startPosX, _startPosY + 70, 160, 26);
|
||||||
|
g.FillPolygon(brushBlack, front);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
104
AirFighter/AirFighter/DrawningAirFighterMilitary.cs
Normal file
104
AirFighter/AirFighter/DrawningAirFighterMilitary.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using AirFighter.Drawnings;
|
||||||
|
using AirFighter.Entities;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace AirFighter.DrawningObjects
|
||||||
|
{
|
||||||
|
public class DrawningAirFighterMilitary : DrawningAirFighter
|
||||||
|
{
|
||||||
|
public DrawningAirFighterMilitary(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool wing, int width, int height) :
|
||||||
|
base(speed, weight, bodyColor, width, height, 195, 166)
|
||||||
|
{
|
||||||
|
if (EntityAirFighter != null)
|
||||||
|
{
|
||||||
|
EntityAirFighter = new EntityAirFighterMilitary(speed, weight, bodyColor,
|
||||||
|
additionalColor, rocket, wing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (EntityAirFighter is not EntityAirFighterMilitary fighterMilitary)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Brush additionalBrush = new SolidBrush(fighterMilitary.AdditionalColor);
|
||||||
|
|
||||||
|
if (fighterMilitary.Wing)
|
||||||
|
{
|
||||||
|
PointF[] topDopWing =
|
||||||
|
{
|
||||||
|
new(_startPosX + 78, _startPosY + 56),
|
||||||
|
new(_startPosX + 75, _startPosY + 70),
|
||||||
|
new(_startPosX + 55, _startPosY + 50),
|
||||||
|
new(_startPosX + 60, _startPosY + 45),
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] bottomDopWing =
|
||||||
|
{
|
||||||
|
new(_startPosX + 78, _startPosY + 110),
|
||||||
|
new(_startPosX + 75, _startPosY + 96),
|
||||||
|
new(_startPosX + 55, _startPosY + 116),
|
||||||
|
new(_startPosX + 60, _startPosY + 121),
|
||||||
|
};
|
||||||
|
|
||||||
|
g.FillPolygon(additionalBrush, topDopWing);
|
||||||
|
g.FillPolygon(additionalBrush, bottomDopWing);
|
||||||
|
|
||||||
|
}
|
||||||
|
base.DrawTransport(g);
|
||||||
|
|
||||||
|
if (fighterMilitary.Rocket)
|
||||||
|
{
|
||||||
|
PointF[] topRocket1 =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY + 20),
|
||||||
|
new(_startPosX + 100, _startPosY + 30),
|
||||||
|
new(_startPosX + 112, _startPosY + 30),
|
||||||
|
new(_startPosX + 120, _startPosY + 25),
|
||||||
|
new(_startPosX + 112, _startPosY + 20)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] topRocket2 =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY + 35),
|
||||||
|
new(_startPosX + 100, _startPosY + 45),
|
||||||
|
new(_startPosX + 112, _startPosY + 45),
|
||||||
|
new(_startPosX + 120, _startPosY + 40),
|
||||||
|
new(_startPosX + 112, _startPosY + 35)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] bottomRocket1 =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY + 146),
|
||||||
|
new(_startPosX + 100, _startPosY + 136),
|
||||||
|
new(_startPosX + 112, _startPosY + 136),
|
||||||
|
new(_startPosX + 120, _startPosY + 141),
|
||||||
|
new(_startPosX + 112, _startPosY + 146)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] bottomRocket2 =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY + 131),
|
||||||
|
new(_startPosX + 100, _startPosY + 121),
|
||||||
|
new(_startPosX + 112, _startPosY + 121),
|
||||||
|
new(_startPosX + 120, _startPosY + 126),
|
||||||
|
new(_startPosX + 112, _startPosY + 131)
|
||||||
|
};
|
||||||
|
|
||||||
|
g.FillPolygon(additionalBrush, topRocket1);
|
||||||
|
g.FillPolygon(additionalBrush, topRocket2);
|
||||||
|
g.FillPolygon(additionalBrush, bottomRocket1);
|
||||||
|
g.FillPolygon(additionalBrush, bottomRocket2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
AirFighter/AirFighter/EntityAirFighter.cs
Normal file
23
AirFighter/AirFighter/EntityAirFighter.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter.Entities
|
||||||
|
{
|
||||||
|
public class EntityAirFighter
|
||||||
|
{
|
||||||
|
public int Speed { get; private set; }
|
||||||
|
public double Weight { get; private set; }
|
||||||
|
public Color BodyColor { get; private set; }
|
||||||
|
public double Step => (double)Speed * 100 / Weight;
|
||||||
|
public EntityAirFighter(int speed, double weight, Color bodyColor)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
AirFighter/AirFighter/EntityAirFighterMilitary.cs
Normal file
22
AirFighter/AirFighter/EntityAirFighterMilitary.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter.Entities
|
||||||
|
{
|
||||||
|
public class EntityAirFighterMilitary : EntityAirFighter
|
||||||
|
{
|
||||||
|
public Color AdditionalColor { get; private set; }
|
||||||
|
public bool Rocket { get; private set; }
|
||||||
|
public bool Wing { get; private set; }
|
||||||
|
public EntityAirFighterMilitary(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool wing)
|
||||||
|
: base(speed, weight, bodyColor)
|
||||||
|
{
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
|
Rocket = rocket;
|
||||||
|
Wing = wing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
AirFighter/AirFighter/Form1.Designer.cs
generated
39
AirFighter/AirFighter/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
|||||||
namespace AirFighter
|
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace AirFighter
|
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
193
AirFighter/AirFighter/FormAirFighter.Designer.cs
generated
Normal file
193
AirFighter/AirFighter/FormAirFighter.Designer.cs
generated
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
partial class FormAirFighter
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
pictureBoxAirFighter = new PictureBox();
|
||||||
|
buttonLeft = new Button();
|
||||||
|
buttonDown = new Button();
|
||||||
|
buttonRight = new Button();
|
||||||
|
buttonUp = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
ButtonStep = new Button();
|
||||||
|
comboBoxStrategy = new ComboBox();
|
||||||
|
ButtonCreateFighter = new Button();
|
||||||
|
buttonSelectFighter = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureBoxAirFighter
|
||||||
|
//
|
||||||
|
pictureBoxAirFighter.Dock = DockStyle.Fill;
|
||||||
|
pictureBoxAirFighter.Location = new Point(0, 0);
|
||||||
|
pictureBoxAirFighter.Name = "pictureBoxAirFighter";
|
||||||
|
pictureBoxAirFighter.Size = new Size(800, 450);
|
||||||
|
pictureBoxAirFighter.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||||
|
pictureBoxAirFighter.TabIndex = 0;
|
||||||
|
pictureBoxAirFighter.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonLeft.BackgroundImage = Properties.Resources.__png_3;
|
||||||
|
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonLeft.Location = new Point(686, 370);
|
||||||
|
buttonLeft.Name = "buttonLeft";
|
||||||
|
buttonLeft.Size = new Size(30, 30);
|
||||||
|
buttonLeft.TabIndex = 1;
|
||||||
|
buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
buttonLeft.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonDown.BackgroundImage = Properties.Resources.__png_2;
|
||||||
|
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonDown.Location = new Point(722, 407);
|
||||||
|
buttonDown.Name = "buttonDown";
|
||||||
|
buttonDown.Size = new Size(30, 30);
|
||||||
|
buttonDown.TabIndex = 2;
|
||||||
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
buttonDown.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonRight.BackgroundImage = Properties.Resources.__png_1;
|
||||||
|
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonRight.Location = new Point(758, 370);
|
||||||
|
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.__png_4;
|
||||||
|
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonUp.Location = new Point(722, 370);
|
||||||
|
buttonUp.Name = "buttonUp";
|
||||||
|
buttonUp.Size = new Size(30, 30);
|
||||||
|
buttonUp.TabIndex = 4;
|
||||||
|
buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
buttonUp.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.BackColor = SystemColors.Control;
|
||||||
|
buttonCreate.Font = new Font("Times New Roman", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
buttonCreate.Location = new Point(12, 390);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(164, 48);
|
||||||
|
buttonCreate.TabIndex = 1;
|
||||||
|
buttonCreate.Text = "Создать истребитель с ракетами\r\n\r\n";
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += buttonCreateAirFighterMilitary_Click;
|
||||||
|
//
|
||||||
|
// ButtonStep
|
||||||
|
//
|
||||||
|
ButtonStep.BackColor = Color.Azure;
|
||||||
|
ButtonStep.Font = new Font("Times New Roman", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
|
ButtonStep.Location = new Point(713, 57);
|
||||||
|
ButtonStep.Name = "ButtonStep";
|
||||||
|
ButtonStep.Size = new Size(75, 23);
|
||||||
|
ButtonStep.TabIndex = 3;
|
||||||
|
ButtonStep.Text = "Шаг";
|
||||||
|
ButtonStep.UseVisualStyleBackColor = true;
|
||||||
|
ButtonStep.Click += ButtonStep_Click;
|
||||||
|
//
|
||||||
|
// comboBoxStrategy
|
||||||
|
//
|
||||||
|
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxStrategy.FormattingEnabled = true;
|
||||||
|
comboBoxStrategy.Items.AddRange(new object[] { "MoveToCenter", "MoveToBorder", "-" });
|
||||||
|
comboBoxStrategy.Location = new Point(667, 12);
|
||||||
|
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||||
|
comboBoxStrategy.Size = new Size(121, 23);
|
||||||
|
comboBoxStrategy.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// ButtonCreateFighter
|
||||||
|
//
|
||||||
|
ButtonCreateFighter.Font = new Font("Times New Roman", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
ButtonCreateFighter.Location = new Point(182, 390);
|
||||||
|
ButtonCreateFighter.Name = "ButtonCreateFighter";
|
||||||
|
ButtonCreateFighter.Size = new Size(164, 47);
|
||||||
|
ButtonCreateFighter.TabIndex = 2;
|
||||||
|
ButtonCreateFighter.Text = "Создаать истребитель";
|
||||||
|
ButtonCreateFighter.UseVisualStyleBackColor = true;
|
||||||
|
ButtonCreateFighter.Click += ButtonCreateFighter_Click;
|
||||||
|
//
|
||||||
|
// buttonSelectFighter
|
||||||
|
//
|
||||||
|
buttonSelectFighter.Font = new Font("Times New Roman", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
buttonSelectFighter.Location = new Point(352, 390);
|
||||||
|
buttonSelectFighter.Name = "buttonSelectFighter";
|
||||||
|
buttonSelectFighter.Size = new Size(164, 47);
|
||||||
|
buttonSelectFighter.TabIndex = 7;
|
||||||
|
buttonSelectFighter.Text = "Выбор";
|
||||||
|
buttonSelectFighter.UseVisualStyleBackColor = true;
|
||||||
|
buttonSelectFighter.Click += ButtonSelectAirFighter_Click;
|
||||||
|
//
|
||||||
|
// FormAirFighter
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(buttonSelectFighter);
|
||||||
|
Controls.Add(ButtonCreateFighter);
|
||||||
|
Controls.Add(comboBoxStrategy);
|
||||||
|
Controls.Add(ButtonStep);
|
||||||
|
Controls.Add(buttonCreate);
|
||||||
|
Controls.Add(buttonUp);
|
||||||
|
Controls.Add(buttonRight);
|
||||||
|
Controls.Add(buttonDown);
|
||||||
|
Controls.Add(buttonLeft);
|
||||||
|
Controls.Add(pictureBoxAirFighter);
|
||||||
|
Name = "FormAirFighter";
|
||||||
|
Text = "AirFighter";
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private PictureBox pictureBoxAirFighter;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private Button ButtonStep;
|
||||||
|
private ComboBox comboBoxStrategy;
|
||||||
|
private Button ButtonCreateFighter;
|
||||||
|
private Button buttonSelectFighter;
|
||||||
|
}
|
||||||
|
}
|
148
AirFighter/AirFighter/FormAirFighter.cs
Normal file
148
AirFighter/AirFighter/FormAirFighter.cs
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
using AirFighter.DrawningObjects;
|
||||||
|
using AirFighter.Drawnings;
|
||||||
|
using AirFighter.MovementStrategy;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
public partial class FormAirFighter : Form
|
||||||
|
{
|
||||||
|
private DrawningAirFighter? _drawningAirFighter;
|
||||||
|
private AbstractStrategy? _abstractStrategy;
|
||||||
|
public DrawningAirFighter? SelectedAirFighter { get; private set; }
|
||||||
|
public FormAirFighter()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_abstractStrategy = null;
|
||||||
|
SelectedAirFighter = null;
|
||||||
|
}
|
||||||
|
private void Draw()
|
||||||
|
{
|
||||||
|
if (_drawningAirFighter == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bitmap bmp = new(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_drawningAirFighter.DrawTransport(gr);
|
||||||
|
pictureBoxAirFighter.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCreateAirFighterMilitary_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random random = new();
|
||||||
|
|
||||||
|
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
//TODO âûáîð îñíîâíîãî öâåòà
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
//TODO âûáîð äîïîëíèòåëüíîãî öâåòà
|
||||||
|
ColorDialog dialog_dop = new();
|
||||||
|
if (dialog_dop.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
dopColor = dialog_dop.Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
_drawningAirFighter = new DrawningAirFighterMilitary(random.Next(100, 300),
|
||||||
|
random.Next(1000, 3000),
|
||||||
|
color,
|
||||||
|
dopColor,
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||||
|
pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
|
_drawningAirFighter.SetPosition(random.Next(10, 100), random.Next(10,
|
||||||
|
100));
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
private void ButtonCreateFighter_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
_drawningAirFighter = new DrawningAirFighter(random.Next(100, 300),
|
||||||
|
random.Next(1000, 3000),
|
||||||
|
color,
|
||||||
|
pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
|
_drawningAirFighter.SetPosition(random.Next(10, 100), random.Next(10,
|
||||||
|
100));
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
private void buttonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_drawningAirFighter == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
_drawningAirFighter.MoveTransport(DirectionAirFighter.Up);
|
||||||
|
break;
|
||||||
|
case "buttonDown":
|
||||||
|
_drawningAirFighter.MoveTransport(DirectionAirFighter.Down);
|
||||||
|
break;
|
||||||
|
case "buttonLeft":
|
||||||
|
_drawningAirFighter.MoveTransport(DirectionAirFighter.Left);
|
||||||
|
break;
|
||||||
|
case "buttonRight":
|
||||||
|
_drawningAirFighter.MoveTransport(DirectionAirFighter.Right);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonStep_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_drawningAirFighter == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxStrategy.Enabled)
|
||||||
|
{
|
||||||
|
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
||||||
|
switch
|
||||||
|
{
|
||||||
|
0 => new MoveToCenter(),
|
||||||
|
1 => new MoveToBorder(),
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
if (_abstractStrategy == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_abstractStrategy.SetData(new
|
||||||
|
DrawningObjectAirFighter(_drawningAirFighter), pictureBoxAirFighter.Width,
|
||||||
|
pictureBoxAirFighter.Height);
|
||||||
|
comboBoxStrategy.Enabled = false;
|
||||||
|
}
|
||||||
|
if (_abstractStrategy != null)
|
||||||
|
{
|
||||||
|
_abstractStrategy.MakeStep();
|
||||||
|
Draw();
|
||||||
|
|
||||||
|
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||||
|
{
|
||||||
|
comboBoxStrategy.Enabled = true;
|
||||||
|
_abstractStrategy = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSelectAirFighter_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedAirFighter = _drawningAirFighter;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
|
|
||||||
Version 2.0
|
Version 2.0
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
The primary goals of this format is to allow a simple XML format
|
||||||
that is mostly human readable. The generation and parsing of the
|
that is mostly human readable. The generation and parsing of the
|
||||||
various data types are done through the TypeConverter classes
|
various data types are done through the TypeConverter classes
|
||||||
associated with the data types.
|
associated with the data types.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
... ado.net/XML headers & schema ...
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
<resheader name="version">2.0</resheader>
|
<resheader name="version">2.0</resheader>
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
</data>
|
</data>
|
||||||
@ -26,36 +26,36 @@
|
|||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
<comment>This is a comment</comment>
|
<comment>This is a comment</comment>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
There are any number of "resheader" rows that contain simple
|
||||||
name/value pairs.
|
name/value pairs.
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
Each data row contains a name, and value. The row also contains a
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
text/value conversion through the TypeConverter architecture.
|
text/value conversion through the TypeConverter architecture.
|
||||||
Classes that don't support this are serialized and stored with the
|
Classes that don't support this are serialized and stored with the
|
||||||
mimetype set.
|
mimetype set.
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
The mimetype is used for serialized objects, and tells the
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
read any of the formats listed below.
|
read any of the formats listed below.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
value : The object must be serialized into a byte array
|
value : The object must be serialized into a byte array
|
||||||
: using a System.ComponentModel.TypeConverter
|
: using a System.ComponentModel.TypeConverter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
-->
|
-->
|
191
AirFighter/AirFighter/FormAirFighterCollection.Designer.cs
generated
Normal file
191
AirFighter/AirFighter/FormAirFighterCollection.Designer.cs
generated
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
partial class FormAirFighterCollection
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
groupBox2 = new GroupBox();
|
||||||
|
buttonDelObject = new Button();
|
||||||
|
listBoxStorage = new ListBox();
|
||||||
|
buttonAddObject = new Button();
|
||||||
|
textBoxStorageName = new TextBox();
|
||||||
|
maskedTextBoxNumber = new MaskedTextBox();
|
||||||
|
buttonRemoveFighter = new Button();
|
||||||
|
buttonRefreshCollection = new Button();
|
||||||
|
buttonAddFighter = new Button();
|
||||||
|
pictureBoxCollection = new PictureBox();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
groupBox2.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(groupBox2);
|
||||||
|
groupBox1.Controls.Add(maskedTextBoxNumber);
|
||||||
|
groupBox1.Controls.Add(buttonRemoveFighter);
|
||||||
|
groupBox1.Controls.Add(buttonRefreshCollection);
|
||||||
|
groupBox1.Controls.Add(buttonAddFighter);
|
||||||
|
groupBox1.Location = new Point(740, 0);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(213, 448);
|
||||||
|
groupBox1.TabIndex = 0;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Инструменты";
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
groupBox2.Controls.Add(buttonDelObject);
|
||||||
|
groupBox2.Controls.Add(listBoxStorage);
|
||||||
|
groupBox2.Controls.Add(buttonAddObject);
|
||||||
|
groupBox2.Controls.Add(textBoxStorageName);
|
||||||
|
groupBox2.Location = new Point(3, 19);
|
||||||
|
groupBox2.Name = "groupBox2";
|
||||||
|
groupBox2.Size = new Size(200, 284);
|
||||||
|
groupBox2.TabIndex = 6;
|
||||||
|
groupBox2.TabStop = false;
|
||||||
|
groupBox2.Text = "Наборы";
|
||||||
|
//
|
||||||
|
// buttonDelObject
|
||||||
|
//
|
||||||
|
buttonDelObject.Location = new Point(18, 244);
|
||||||
|
buttonDelObject.Name = "buttonDelObject";
|
||||||
|
buttonDelObject.Size = new Size(159, 34);
|
||||||
|
buttonDelObject.TabIndex = 2;
|
||||||
|
buttonDelObject.Text = "Удалить набор";
|
||||||
|
buttonDelObject.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelObject.Click += ButtonDelObject_Click;
|
||||||
|
//
|
||||||
|
// listBoxStorage
|
||||||
|
//
|
||||||
|
listBoxStorage.FormattingEnabled = true;
|
||||||
|
listBoxStorage.ItemHeight = 15;
|
||||||
|
listBoxStorage.Location = new Point(15, 88);
|
||||||
|
listBoxStorage.Name = "listBoxStorage";
|
||||||
|
listBoxStorage.Size = new Size(162, 139);
|
||||||
|
listBoxStorage.TabIndex = 2;
|
||||||
|
listBoxStorage.SelectedIndexChanged += listBoxStorage_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// buttonAddObject
|
||||||
|
//
|
||||||
|
buttonAddObject.Location = new Point(18, 48);
|
||||||
|
buttonAddObject.Name = "buttonAddObject";
|
||||||
|
buttonAddObject.Size = new Size(159, 34);
|
||||||
|
buttonAddObject.TabIndex = 1;
|
||||||
|
buttonAddObject.Text = "Добавить набор";
|
||||||
|
buttonAddObject.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddObject.Click += ButtonAddObject_Click;
|
||||||
|
//
|
||||||
|
// textBoxStorageName
|
||||||
|
//
|
||||||
|
textBoxStorageName.Location = new Point(3, 19);
|
||||||
|
textBoxStorageName.Name = "textBoxStorageName";
|
||||||
|
textBoxStorageName.Size = new Size(191, 23);
|
||||||
|
textBoxStorageName.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// maskedTextBoxNumber
|
||||||
|
//
|
||||||
|
maskedTextBoxNumber.Font = new Font("Showcard Gothic", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
maskedTextBoxNumber.Location = new Point(39, 346);
|
||||||
|
maskedTextBoxNumber.Mask = "00";
|
||||||
|
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
|
maskedTextBoxNumber.Size = new Size(100, 22);
|
||||||
|
maskedTextBoxNumber.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// buttonRemoveFighter
|
||||||
|
//
|
||||||
|
buttonRemoveFighter.Location = new Point(17, 374);
|
||||||
|
buttonRemoveFighter.Name = "buttonRemoveFighter";
|
||||||
|
buttonRemoveFighter.Size = new Size(166, 31);
|
||||||
|
buttonRemoveFighter.TabIndex = 3;
|
||||||
|
buttonRemoveFighter.Text = "Удалить истребитель";
|
||||||
|
buttonRemoveFighter.UseVisualStyleBackColor = true;
|
||||||
|
buttonRemoveFighter.Click += ButtonRemoveAirFighter_Click;
|
||||||
|
//
|
||||||
|
// buttonRefreshCollection
|
||||||
|
//
|
||||||
|
buttonRefreshCollection.Location = new Point(17, 411);
|
||||||
|
buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||||
|
buttonRefreshCollection.Size = new Size(166, 31);
|
||||||
|
buttonRefreshCollection.TabIndex = 4;
|
||||||
|
buttonRefreshCollection.Text = "Обновить коллекцию";
|
||||||
|
buttonRefreshCollection.UseVisualStyleBackColor = true;
|
||||||
|
buttonRefreshCollection.Click += ButtonRefreshCollection_Click;
|
||||||
|
//
|
||||||
|
// buttonAddFighter
|
||||||
|
//
|
||||||
|
buttonAddFighter.Location = new Point(17, 309);
|
||||||
|
buttonAddFighter.Name = "buttonAddFighter";
|
||||||
|
buttonAddFighter.Size = new Size(166, 31);
|
||||||
|
buttonAddFighter.TabIndex = 2;
|
||||||
|
buttonAddFighter.Text = "Добавить истребитель ";
|
||||||
|
buttonAddFighter.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddFighter.Click += ButtonAddAirFighter_Click;
|
||||||
|
//
|
||||||
|
// pictureBoxCollection
|
||||||
|
//
|
||||||
|
pictureBoxCollection.Location = new Point(0, 0);
|
||||||
|
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
|
pictureBoxCollection.Size = new Size(734, 448);
|
||||||
|
pictureBoxCollection.SizeMode = PictureBoxSizeMode.Zoom;
|
||||||
|
pictureBoxCollection.TabIndex = 1;
|
||||||
|
pictureBoxCollection.TabStop = false;
|
||||||
|
pictureBoxCollection.Click += ButtonAddAirFighter_Click;
|
||||||
|
//
|
||||||
|
// FormFighterCollection
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(953, 448);
|
||||||
|
Controls.Add(pictureBoxCollection);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Name = "FormFighterCollection";
|
||||||
|
Text = "Набор истребителя";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
groupBox2.ResumeLayout(false);
|
||||||
|
groupBox2.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private PictureBox pictureBoxCollection;
|
||||||
|
private Button buttonRemoveFighter;
|
||||||
|
private Button buttonRefreshCollection;
|
||||||
|
private Button buttonAddFighter;
|
||||||
|
private MaskedTextBox maskedTextBoxNumber;
|
||||||
|
private GroupBox groupBox2;
|
||||||
|
private TextBox textBoxStorageName;
|
||||||
|
private Button buttonDelObject;
|
||||||
|
private ListBox listBoxStorage;
|
||||||
|
private Button buttonAddObject;
|
||||||
|
}
|
||||||
|
}
|
187
AirFighter/AirFighter/FormAirFighterCollection.cs
Normal file
187
AirFighter/AirFighter/FormAirFighterCollection.cs
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
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;
|
||||||
|
using AirFighter.DrawningObjects;
|
||||||
|
using AirFighter.Drawnings;
|
||||||
|
using AirFighter.Generics;
|
||||||
|
using AirFighter.MovementStrategy;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Форма для работы с набором объектов класса DrawningCar
|
||||||
|
/// </summary>
|
||||||
|
public partial class FormAirFighterCollection : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Набор объектов
|
||||||
|
/// </summary>
|
||||||
|
private readonly AirFighterGenericStorage _storage;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public FormAirFighterCollection()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_storage = new AirFighterGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Заполнение listBoxObjects
|
||||||
|
/// </summary>
|
||||||
|
private void ReloadObjects()
|
||||||
|
{
|
||||||
|
int index = listBoxStorage.SelectedIndex;
|
||||||
|
listBoxStorage.Items.Clear();
|
||||||
|
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||||
|
{
|
||||||
|
listBoxStorage.Items.Add(_storage.Keys[i]);
|
||||||
|
}
|
||||||
|
if (listBoxStorage.Items.Count > 0 && (index == -1 || index
|
||||||
|
>= listBoxStorage.Items.Count))
|
||||||
|
{
|
||||||
|
listBoxStorage.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else if (listBoxStorage.Items.Count > 0 && index > -1 &&
|
||||||
|
index < listBoxStorage.Items.Count)
|
||||||
|
{
|
||||||
|
listBoxStorage.SelectedIndex = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <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();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Выбор набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void listBoxStorage_SelectedIndexChanged(object sender,
|
||||||
|
EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBoxCollection.Image =
|
||||||
|
_storage[listBoxStorage.SelectedItem?.ToString() ?? string.Empty]?.ShowAirFighter();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonDelObject_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorage.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
|
||||||
|
{
|
||||||
|
_storage.DelSet(listBoxStorage.SelectedItem.ToString()
|
||||||
|
?? string.Empty);
|
||||||
|
ReloadObjects();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление объекта в набор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonAddAirFighter_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorage.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorage.SelectedItem.ToString() ??
|
||||||
|
string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FormAirFighter form = new();
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (obj + form.SelectedAirFighter > -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBoxCollection.Image = obj.ShowAirFighter();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление объекта из набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonRemoveAirFighter_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorage.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorage.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.ShowAirFighter();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Обновление рисунка по набору
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorage.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorage.SelectedItem.ToString() ??
|
||||||
|
string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBoxCollection.Image = obj.ShowAirFighter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
AirFighter/AirFighter/FormAirFighterCollection.resx
Normal file
120
AirFighter/AirFighter/FormAirFighterCollection.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<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>
|
20
AirFighter/AirFighter/IMoveableObject.cs
Normal file
20
AirFighter/AirFighter/IMoveableObject.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using AirFighter.Drawnings;
|
||||||
|
|
||||||
|
namespace AirFighter.MovementStrategy
|
||||||
|
{
|
||||||
|
public interface IMoveableObject
|
||||||
|
{
|
||||||
|
ObjectParameters? GetObjectPosition { get; }
|
||||||
|
int GetStep { get; }
|
||||||
|
bool CheckCanMove(DirectionAirFighter direction);
|
||||||
|
void MoveObject(DirectionAirFighter direction);
|
||||||
|
void SetPosition(int x, int y);
|
||||||
|
void Draw(Graphics g);
|
||||||
|
}
|
||||||
|
}
|
51
AirFighter/AirFighter/IMoveableObject_Realise.cs
Normal file
51
AirFighter/AirFighter/IMoveableObject_Realise.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using AirFighter.DrawningObjects;
|
||||||
|
using AirFighter.Drawnings;
|
||||||
|
|
||||||
|
namespace AirFighter.MovementStrategy
|
||||||
|
{
|
||||||
|
public class DrawningObjectAirFighter : IMoveableObject
|
||||||
|
{
|
||||||
|
private readonly DrawningAirFighter? _drawningAirFighter = null;
|
||||||
|
public DrawningObjectAirFighter(DrawningAirFighter drawningAirFighter)
|
||||||
|
{
|
||||||
|
_drawningAirFighter = drawningAirFighter;
|
||||||
|
}
|
||||||
|
public ObjectParameters? GetObjectPosition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_drawningAirFighter == null || _drawningAirFighter.EntityAirFighter ==
|
||||||
|
null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new ObjectParameters(_drawningAirFighter.GetPosX, _drawningAirFighter.GetPosY, _drawningAirFighter.GetWidth, _drawningAirFighter.GetHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int GetStep => (int)(_drawningAirFighter?.EntityAirFighter?.Step ?? 0);
|
||||||
|
public bool CheckCanMove(DirectionAirFighter direction) =>
|
||||||
|
_drawningAirFighter?.CanMove(direction) ?? false;
|
||||||
|
public void MoveObject(DirectionAirFighter direction) =>
|
||||||
|
_drawningAirFighter?.MoveTransport(direction);
|
||||||
|
public void SetPosition(int x, int y)
|
||||||
|
{
|
||||||
|
if (_drawningAirFighter != null)
|
||||||
|
{
|
||||||
|
_drawningAirFighter.SetPosition(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Draw(Graphics g)
|
||||||
|
{
|
||||||
|
if (_drawningAirFighter != null)
|
||||||
|
{
|
||||||
|
_drawningAirFighter.DrawTransport(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
AirFighter/AirFighter/MoveToBorder.cs
Normal file
42
AirFighter/AirFighter/MoveToBorder.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter.MovementStrategy
|
||||||
|
{
|
||||||
|
public class MoveToBorder : AbstractStrategy
|
||||||
|
{
|
||||||
|
protected override bool IsTargetDestinaion()
|
||||||
|
{
|
||||||
|
var objParams = GetObjectParameters;
|
||||||
|
if (objParams == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return objParams.RightBorder <= FieldWidth &&
|
||||||
|
objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||||
|
objParams.DownBorder <= FieldHeight &&
|
||||||
|
objParams.DownBorder + GetStep() >= FieldHeight;
|
||||||
|
}
|
||||||
|
protected override void MoveToTarget()
|
||||||
|
{
|
||||||
|
var objParams = GetObjectParameters;
|
||||||
|
if (objParams == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var diffX = objParams.RightBorder - FieldWidth;
|
||||||
|
if (Math.Abs(diffX) > GetStep())
|
||||||
|
{
|
||||||
|
MoveRight();
|
||||||
|
}
|
||||||
|
var diffY = objParams.DownBorder - FieldHeight;
|
||||||
|
if (Math.Abs(diffY) > GetStep())
|
||||||
|
{
|
||||||
|
MoveDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
61
AirFighter/AirFighter/MoveToCenter.cs
Normal file
61
AirFighter/AirFighter/MoveToCenter.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter.MovementStrategy
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
||||||
|
|
||||||
|
if (Math.Abs(diffX) > GetStep() || Math.Abs(diffY) > GetStep())
|
||||||
|
{
|
||||||
|
if (Math.Abs(diffX) > GetStep())
|
||||||
|
{
|
||||||
|
if (diffX > 0)
|
||||||
|
{
|
||||||
|
MoveLeft();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MoveRight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Math.Abs(diffY) > GetStep())
|
||||||
|
{
|
||||||
|
if (diffY > 0)
|
||||||
|
{
|
||||||
|
MoveUp();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MoveDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
AirFighter/AirFighter/ObjectParameters.cs
Normal file
29
AirFighter/AirFighter/ObjectParameters.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter.MovementStrategy
|
||||||
|
{
|
||||||
|
public class ObjectParameters
|
||||||
|
{
|
||||||
|
private readonly int _x;
|
||||||
|
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;
|
||||||
|
public ObjectParameters(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
_x = x;
|
||||||
|
_y = y;
|
||||||
|
_width = width;
|
||||||
|
_height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@ namespace AirFighter
|
|||||||
// 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 Form1());
|
Application.Run(new FormAirFighterCollection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
113
AirFighter/AirFighter/Properties/Resources.Designer.cs
generated
Normal file
113
AirFighter/AirFighter/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace AirFighter.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("AirFighter.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 @__png_1 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("--png-1", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap @__png_2 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("--png-2", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap @__png_3 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("--png-3", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap @__png_31 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("--png-31", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap @__png_4 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("--png-4", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
136
AirFighter/AirFighter/Properties/Resources.resx
Normal file
136
AirFighter/AirFighter/Properties/Resources.resx
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<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>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="--png-3" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\--png-3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="--png-31" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\--png-31.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="--png-1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\--png-1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="--png-2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\--png-2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="--png-4" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\--png-4.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
BIN
AirFighter/AirFighter/Resources/--png-1.png
Normal file
BIN
AirFighter/AirFighter/Resources/--png-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
AirFighter/AirFighter/Resources/--png-2.png
Normal file
BIN
AirFighter/AirFighter/Resources/--png-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
AirFighter/AirFighter/Resources/--png-3.png
Normal file
BIN
AirFighter/AirFighter/Resources/--png-3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
AirFighter/AirFighter/Resources/--png-31.png
Normal file
BIN
AirFighter/AirFighter/Resources/--png-31.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
AirFighter/AirFighter/Resources/--png-4.png
Normal file
BIN
AirFighter/AirFighter/Resources/--png-4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
66
AirFighter/AirFighter/SetGeneric.cs
Normal file
66
AirFighter/AirFighter/SetGeneric.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
namespace AirFighter.Generics
|
||||||
|
{
|
||||||
|
internal class SetGeneric<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
private readonly List<T?> _places;
|
||||||
|
public int Count => _places.Count;
|
||||||
|
private readonly int _maxCount;
|
||||||
|
public SetGeneric(int count)
|
||||||
|
{
|
||||||
|
_maxCount = count;
|
||||||
|
_places = new List<T?>(count);
|
||||||
|
}
|
||||||
|
public int Insert(T fighter)
|
||||||
|
{
|
||||||
|
return Insert(fighter, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
private bool isCorrectPosition(int position)
|
||||||
|
{
|
||||||
|
return 0 <= position && position < _maxCount;
|
||||||
|
}
|
||||||
|
public int Insert(T fighter, int position)
|
||||||
|
{
|
||||||
|
if (!isCorrectPosition(position))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
_places.Insert(position, fighter);
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
public bool Remove(int position)
|
||||||
|
{
|
||||||
|
if ((position < 0) || (position > _maxCount)) return false;
|
||||||
|
_places.RemoveAt(position);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public T? this[int position]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (position < 0 || position > _maxCount)
|
||||||
|
return null;
|
||||||
|
return _places[position];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (position < 0 || position > _maxCount)
|
||||||
|
return;
|
||||||
|
_places[position] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IEnumerable<T?> GetAirFighter(int? maxAirFighter = null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _places.Count; ++i)
|
||||||
|
{
|
||||||
|
yield return _places[i];
|
||||||
|
if (maxAirFighter.HasValue && i == maxAirFighter.Value)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
15
AirFighter/AirFighter/Status.cs
Normal file
15
AirFighter/AirFighter/Status.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter.MovementStrategy
|
||||||
|
{
|
||||||
|
public enum Status
|
||||||
|
{
|
||||||
|
NotInit,
|
||||||
|
InProgress,
|
||||||
|
Finish
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user