Compare commits

...

27 Commits

Author SHA1 Message Date
foxkerik6
c219c25579 у меня уже нет идей, как избавиться от конфликта 2022-12-01 00:10:54 +04:00
foxkerik6
bd4cfcf2ec ... 2022-12-01 00:07:21 +04:00
foxkerik6
e6a679301d и ещё самую малость поправок 2022-12-01 00:05:43 +04:00
foxkerik6
6834a0e496 и ещё поправки 2022-12-01 00:03:16 +04:00
foxkerik6
4dec93f918 ещё поправки 2022-12-01 00:00:48 +04:00
30ad241b99 готово 2022-11-29 10:54:21 +04:00
foxkerik6
0a5fc475d2 проблемы с serialog 2022-11-29 06:08:45 +04:00
foxkerik6
bd2998b662 добавление фильтра 2022-11-29 04:45:44 +04:00
foxkerik6
4bfd8eb75c всё готово 2022-11-29 04:35:36 +04:00
foxkerik6
577de84cd5 Исправление неточностей 2022-11-29 02:11:15 +04:00
foxkerik6
f3d2973c84 всё готово 2022-11-29 01:56:58 +04:00
foxkerik6
b82e72038d Добавлена форма 2022-11-29 01:40:38 +04:00
foxkerik6
fa6ac61b63 финальные изменения 2022-11-29 00:26:24 +04:00
foxkerik6
d740eda7c3 исправление ошибки 2022-11-28 22:40:03 +04:00
foxkerik6
4d041377c3 финальные исправления 2022-11-28 22:32:40 +04:00
foxkerik6
86d3cae23e исправление 2022-11-28 22:28:31 +04:00
5eaac57cb2 чистка кода 2022-11-28 22:27:17 +04:00
61de90a13a Исправление неточностей 2022-11-28 22:23:27 +04:00
foxkerik6
e992d502d6 некоторые изменения 2022-11-28 22:09:03 +04:00
foxkerik6
468f859fe0 Чистка кода 2022-11-19 13:23:13 +04:00
foxkerik6
e28f874853 Всё готово 2022-11-15 02:15:02 +04:00
5172ab0e40 Некоторые изменения 2022-11-01 18:05:19 +04:00
8c5bb5b4a4 Добавлены новые карты 2022-11-01 03:30:37 +04:00
987d1fafa8 Создание коллизии 2022-11-01 02:55:40 +04:00
foxkerik6
ba856b7880 Создание модификации 2022-10-18 01:56:17 +04:00
foxkerik6
ace0650476 Merge branch 'LabWork2' of http://student.git.athene.tech/ker73rus/PIbd-21_Pyatakov_KM_Stormtrooper_Base into LabWork2 2022-10-07 00:28:40 +04:00
313713bca4 Изменение целевой платформы 2022-10-07 00:28:19 +04:00
39 changed files with 2905 additions and 456 deletions

View File

@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32002.261
# Visual Studio Version 17
VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stormtrooper", "Stormtrooper\Stormtrooper.csproj", "{D87DFF83-0536-4E02-BF47-7742AC403580}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stormtrooper", "Stormtrooper\Stormtrooper.csproj", "{8AA57368-9B39-4D80-8E57-A47747850BC6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D87DFF83-0536-4E02-BF47-7742AC403580}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D87DFF83-0536-4E02-BF47-7742AC403580}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D87DFF83-0536-4E02-BF47-7742AC403580}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D87DFF83-0536-4E02-BF47-7742AC403580}.Release|Any CPU.Build.0 = Release|Any CPU
{8AA57368-9B39-4D80-8E57-A47747850BC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8AA57368-9B39-4D80-8E57-A47747850BC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AA57368-9B39-4D80-8E57-A47747850BC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8AA57368-9B39-4D80-8E57-A47747850BC6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D4E232C0-9FA0-49BD-B4D6-D779415C9348}
SolutionGuid = {83CCA316-14CA-4D9C-BC16-70A84A6A05A1}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,151 @@
using Stormtrooper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal abstract class AbstractMap
{
private IDrawningObject _drawningObject = null;
protected int[,] _map = null;
protected int _width;
protected int _height;
protected float _size_x;
protected float _size_y;
protected readonly Random _random = new();
protected readonly int _freeRoad = 0;
protected readonly int _barrier = 1;
public Bitmap CreateMap(int width, int height, IDrawningObject drawningObject)
{
_width = width;
_height = height;
_drawningObject = drawningObject;
GenerateMap();
while (!SetObjectOnMap())
{
GenerateMap();
}
return DrawMapWithObject();
}
public Bitmap MoveObject(Direction direction)
{
if (CheckCollision(direction))
{
_drawningObject.MoveObject(direction);
}
return DrawMapWithObject();
}
private bool SetObjectOnMap()
{
if (_drawningObject == null || _map == null)
{
return false;
}
int x = _random.Next(0, (int)(_width * 0.9f));
int y = _random.Next(0, (int)(_height * 0.8f));
_drawningObject.SetObject(x, y, _width, _height);
while (!CheckCollision(Direction.None))
{
x = _random.Next(0, (int)(_width * 0.9f));
y = _random.Next(0, (int)(_height * 0.8f));
_drawningObject.SetObject(x, y, _width, _height);
}
return true;
}
private bool CheckCollision(Direction dir)
{
int left = (int)(_drawningObject.GetCurrentPosition().Left / _size_x);
int top = (int)(_drawningObject.GetCurrentPosition().Top / _size_y);
int bottom = (int)(_drawningObject.GetCurrentPosition().Bottom / _size_y) +1;
int right = (int)(_drawningObject.GetCurrentPosition().Right / _size_x) +1;
switch (dir)
{
case Direction.None:
break;
case Direction.Left:
if (left >= 1)
{
left--;
right--;
}
else return false;
break;
case Direction.Up:
if (top >= 1)
{
top--;
bottom--;
}
else return false;
break;
case Direction.Down:
if (bottom <= 98)
{
top++;
bottom++;
}
else return false;
break;
case Direction.Right:
if (right <= 98)
{
left++;
right++;
}
else return false;
break;
}
for (int i = left; i < right && i < _map.GetLength(0); i++)
{
for (int j = top; j < bottom && j < _map.GetLength(1); j++)
{
if (_map[i, j] == _barrier)
{
return false;
}
}
}
return true;
}
private Bitmap DrawMapWithObject()
{
Bitmap bmp = new(_width, _height);
if (_drawningObject == null || _map == null)
{
return bmp;
}
Graphics gr = Graphics.FromImage(bmp);
for (int i = 0; i < _map.GetLength(0); ++i)
{
for (int j = 0; j < _map.GetLength(1); ++j)
{
if (_map[i, j] == _freeRoad)
{
DrawRoadPart(gr, i, j);
}
else if (_map[i, j] == _barrier)
{
DrawBarrierPart(gr, i, j);
}
}
}
_drawningObject.DrawningObject(gr);
return bmp;
}
protected abstract void GenerateMap();
protected abstract void DrawRoadPart(Graphics g, int i, int j);
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal class AirplaneNotFoundException : ApplicationException
{
public AirplaneNotFoundException() : base() { }
public AirplaneNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
public AirplaneNotFoundException(string message) : base(message) { }
public AirplaneNotFoundException(string message, Exception exception) : base(message, exception) { }
protected AirplaneNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@ -0,0 +1,61 @@
using Strormtrooper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal class CloudMap: AbstractMap
{
private readonly Brush barrierColor = new SolidBrush(Color.Gray);
/// <summary>
/// Цвет участка открытого
/// </summary>
private readonly Brush roadColor = new SolidBrush(Color.White);
protected override void DrawBarrierPart(Graphics g, int i, int j)
{
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y);
}
protected override void DrawRoadPart(Graphics g, int i, int j)
{
g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y);
}
protected override void GenerateMap()
{
_map = new int[100, 100];
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
for (int i = 0; i < _map.GetLength(0); ++i)
{
for (int j = 0; j < _map.GetLength(1); ++j)
{
_map[i, j] = _freeRoad;
}
}
for (int c = _random.Next(1, 5); c > 0; c--)
{
int i = _random.Next(0, 100);
int j = _random.Next(0, 100);
int wight = _random.Next(0, Math.Min(100 - j, j));
int height = _random.Next(0, Math.Min(100 - i,i));
for (int k = 0; k <= wight; k++, height--)
{
for(int l = 0; l <= height; l++)
{
_map[i + l, j + k] = _barrier;
_map[i -l, j - k] = _barrier;
_map[i - l, j + k] = _barrier;
_map[i + l, j - k] = _barrier;
}
}
}
}
}
}

View File

@ -0,0 +1,52 @@
using Strormtrooper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal class DangerMap : AbstractMap
{
private readonly Brush barrierColor = new SolidBrush(Color.Red);
/// <summary>
/// Цвет участка открытого
/// </summary>
private readonly Brush roadColor = new SolidBrush(Color.Black);
protected override void DrawBarrierPart(Graphics g, int i, int j)
{
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y);
}
protected override void DrawRoadPart(Graphics g, int i, int j)
{
g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y);
}
protected override void GenerateMap()
{
_map = new int[100, 100];
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
for (int i = 0; i < _map.GetLength(0); ++i)
{
for (int j = 0; j < _map.GetLength(1); ++j)
{
_map[i, j] = _freeRoad;
}
}
for(int c = _random.Next(1, 10); c > 0; c--)
{
int i = _random.Next(0, 100);
int maxj = _random.Next(30, 70);
for (int j = 0; j < maxj; j++)
{
_map[i, j] = _barrier;
}
}
}
}
}

View File

@ -6,9 +6,10 @@ using System.Threading.Tasks;
namespace Stormtrooper
{
internal enum Direction
public enum Direction
{
None,
Up,
Down,
Left,

View File

@ -7,20 +7,20 @@ using System.Threading.Tasks;
namespace Stormtrooper
{
internal class DrawningMilitaryAirplane
public class DrawningMilitaryAirplane
{
/// <summary>
/// Класс-сущность
/// </summary>
public EntityMilitaryAirplane Airplane { get; private set; }
public EntityMilitaryAirplane Airplane { get; protected set; }
/// <summary>
/// Левая координата отрисовки автомобиля
/// </summary>
private float _startPosX;
protected float _startPosX;
/// <summary>
/// Верхняя кооридната отрисовки автомобиля
/// </summary>
private float _startPosY;
protected float _startPosY;
/// <summary>
/// Ширина окна отрисовки
/// </summary>
@ -32,15 +32,16 @@ namespace Stormtrooper
/// <summary>
/// Ширина отрисовки самолёта
/// </summary>
private readonly int _airplaneWidth = 80;
protected readonly int _airplaneWidth;
/// <summary>
/// Высота отрисовки самолёта
/// </summary>
private readonly int _airplaneHeight = 100;
public void Init(int speed, int weight)
protected readonly int _airplaneHeight;
public DrawningMilitaryAirplane(int speed, int weight,Color color, int wight = 80, int height = 100)
{
Airplane = new EntityMilitaryAirplane();
Airplane.Init(speed, weight);
Airplane = new EntityMilitaryAirplane(speed, weight, color);
_airplaneWidth = wight;
_airplaneHeight = height;
}
public void SetPosition(int x, int y, int width, int height)
@ -99,7 +100,7 @@ namespace Stormtrooper
}
}
public void DrawAirplane(Graphics g)
public virtual void DrawAirplane(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
@ -109,23 +110,24 @@ namespace Stormtrooper
Pen pen = new Pen(Color.Black);
Brush brush = new SolidBrush(Color.Black);
Brush brush = new SolidBrush(Airplane.Color);
g.FillPolygon(brush, new PointF[3] {new PointF(_startPosX, _startPosY + _airplaneHeight / 2),
new PointF(_startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.45f),
new PointF(_startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.55f)});
g.DrawPolygon(pen, new PointF[6] { new PointF(_startPosX + _airplaneWidth*0.45f,_startPosY),
new PointF(_startPosX + _airplaneWidth*0.50f,_startPosY),
g.FillPolygon(brush, new PointF[6] { new PointF(_startPosX + _airplaneWidth*0.45f,_startPosY),
new PointF(_startPosX + _airplaneWidth * 0.50f,_startPosY),
new PointF(_startPosX + _airplaneWidth * 0.60f, _startPosY+_airplaneHeight*0.45f) ,
new PointF(_startPosX + _airplaneWidth * 0.60f, _startPosY+ _airplaneHeight*0.55f),
new PointF(_startPosX + _airplaneWidth * 0.50f,_startPosY + _airplaneHeight),
new PointF(_startPosX + _airplaneWidth * 0.45f,_startPosY + _airplaneHeight)});
g.DrawPolygon(pen, new PointF[4] {
g.FillPolygon(brush, new PointF[4] {
new PointF(_startPosX + _airplaneWidth, _startPosY + _airplaneHeight*0.20f),
new PointF(_startPosX + _airplaneWidth*0.85f,_startPosY+_airplaneHeight*0.35f),
new PointF(_startPosX + _airplaneWidth * 0.85f,_startPosY + _airplaneHeight*0.65f),
new PointF(_startPosX + _airplaneWidth, _startPosY + _airplaneHeight*0.80f)
});
g.FillRectangle(new SolidBrush(Color.White), _startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.45f, _airplaneWidth * 0.9f, _airplaneHeight * 0.1f);
g.FillRectangle(brush, _startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.45f, _airplaneWidth * 0.9f, _airplaneHeight * 0.1f);
g.DrawRectangle(pen, _startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.45f, _airplaneWidth * 0.9f, _airplaneHeight * 0.1f);
}
public void ChangeBorders(int width, int height)
@ -147,5 +149,10 @@ namespace Stormtrooper
_startPosY = _pictureHeight.Value - _airplaneHeight;
}
}
public (float Left, float Top, float Right, float Bottom) GetCurrentPosition()
{
return (_startPosX, _startPosY, _startPosX + _airplaneWidth, _startPosY + _airplaneHeight);
}
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal class DrawningObject : IDrawningObject
{
private DrawningMilitaryAirplane _airplane;
public DrawningObject(DrawningMilitaryAirplane airplane)
{
_airplane = airplane;
}
public float Step => _airplane?.Airplane?.Step ?? 0;
public (float Left, float Top, float Right, float Bottom) GetCurrentPosition()
{
return _airplane?.GetCurrentPosition() ?? default;
}
public string GetInfo()
{
return _airplane?.GetDataForSave();
}
public void MoveObject(Direction direction)
{
_airplane?.MoveAirplane(direction);
}
public void SetObject(int x, int y, int width, int height)
{
_airplane?.SetPosition(x, y, width, height);
}
void IDrawningObject.DrawningObject(Graphics g)
{
_airplane.DrawAirplane(g);
}
public static IDrawningObject Create(string data) => new DrawningObject(data.CreateDrawningAirplane());
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal class DrawningStormtrooper : DrawningMilitaryAirplane
{
public DrawningStormtrooper(int speed, int weight, Color color, Color advColor, bool rockets, bool boosters, bool radar) : base(speed, weight, color)
{
Airplane = new EntityStormtrooper(speed, weight,color, advColor, rockets, boosters, radar);
}
public override void DrawAirplane(Graphics g)
{
if (Airplane is not EntityStormtrooper stormtrooper)
{
return;
}
Pen pen = new Pen(stormtrooper.AdvColor);
Brush brush = new SolidBrush(stormtrooper.AdvColor);
if (stormtrooper.Rockets)
{
g.FillEllipse(brush,_startPosX + _airplaneWidth * 0.3f,_startPosY + _airplaneHeight * 0.2f,_airplaneWidth * 0.3f,_airplaneHeight * 0.03f);
g.FillEllipse(brush,_startPosX + _airplaneWidth * 0.3f,_startPosY + _airplaneHeight * 0.3f, _airplaneWidth * 0.3f, _airplaneHeight * 0.03f);
g.FillEllipse(brush,_startPosX + _airplaneWidth * 0.3f,_startPosY + _airplaneHeight * 0.7f, _airplaneWidth * 0.3f, _airplaneHeight * 0.03f);
g.FillEllipse(brush,_startPosX + _airplaneWidth * 0.3f,_startPosY + _airplaneHeight * 0.8f, _airplaneWidth * 0.3f, _airplaneHeight * 0.03f);
}
base.DrawAirplane(g);
if (stormtrooper.Booster)
{
g.FillRectangle(brush, _startPosX + _airplaneWidth * 0.95f, _startPosY + _airplaneHeight * 0.35f, _airplaneWidth * 0.055f, _airplaneHeight * 0.03f);
g.FillRectangle(brush, _startPosX + _airplaneWidth * 0.95f, _startPosY + _airplaneHeight * 0.63f, _airplaneWidth * 0.055f, _airplaneHeight * 0.03f);
}
if (stormtrooper.Radar)
{
g.FillEllipse(brush, _startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.45f, _airplaneWidth*0.125f, _airplaneHeight * 0.1f);
}
}
}
}

View File

@ -6,20 +6,20 @@ using System.Threading.Tasks;
namespace Stormtrooper
{
internal class EntityMilitaryAirplane
public class EntityMilitaryAirplane
{
public int Speed { get; private set; }
public int Weight { get; private set; }
public int Crew { get; private set; }
public Color Color { get; set; }
public float Step => Speed * 25 / Weight;
public void Init(int speed, int weight, int crew = 10)
public EntityMilitaryAirplane(int speed, int weight, Color color)
{
Random random = new Random();
Speed = speed <= 0 ? random.Next(10, 100) : speed;
Weight = weight <= 0 ? random.Next(50, 150) : weight;
Crew = crew;
Color = color;
}

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal class EntityStormtrooper : EntityMilitaryAirplane
{
/// <summary>
/// Доп цвет
/// </summary>
public Color AdvColor { get; set; }
/// <summary>
/// Наличие рокет
/// </summary>
public bool Rockets { get; set; }
/// <summary>
/// Наличие ускорителей
/// </summary>
public bool Booster { get; set; }
/// <summary>
/// Наличие радара
/// </summary>
public bool Radar { get; set; }
public EntityStormtrooper(int speed, int weight, Color color, Color advColor, bool rockets, bool boosters, bool radar)
: base(speed, weight, color)
{
Rockets = rockets;
Booster = boosters;
Radar = radar;
AdvColor = advColor;
}
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal static class ExtentionAirplane
{
private static readonly char _separatorForObject = ':';
public static string GetDataForSave(this DrawningMilitaryAirplane drawningMilitaryAirplane)
{
var air = drawningMilitaryAirplane.Airplane;
var str = $"{air.Speed}{_separatorForObject}{air.Weight}{_separatorForObject}{air.Color.ToArgb()}";
if (air is not EntityStormtrooper stormtrooper)
{
return str;
}
else return
$"{str}{_separatorForObject}{stormtrooper.AdvColor.ToArgb()}{_separatorForObject}{stormtrooper.Rockets}{_separatorForObject}{stormtrooper.Booster}{_separatorForObject}{stormtrooper.Radar}";
}
public static DrawningMilitaryAirplane CreateDrawningAirplane(this string info)
{
string[] strs = info.Split(_separatorForObject);
if (strs.Length == 3)
{
return new DrawningMilitaryAirplane(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]), Color.FromArgb(Convert.ToInt32(strs[2])));
}
if (strs.Length == 7)
{
return new DrawningStormtrooper(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]), Color.FromArgb(Convert.ToInt32(strs[2])),
Color.FromArgb(Convert.ToInt32(strs[3])), Convert.ToBoolean(strs[4]),
Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
}
return null;
}
}
}

View File

@ -0,0 +1,398 @@
namespace Stormtrooper
{
partial class FormAirConfig
{
/// <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.groupBoxConfig = new System.Windows.Forms.GroupBox();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.labelAdvanced = new System.Windows.Forms.Label();
this.labelSimple = new System.Windows.Forms.Label();
this.groupBoxColor = new System.Windows.Forms.GroupBox();
this.panelGreen = new System.Windows.Forms.Panel();
this.panelCyan = new System.Windows.Forms.Panel();
this.panelPink = new System.Windows.Forms.Panel();
this.panelBlack = new System.Windows.Forms.Panel();
this.panelPurple = new System.Windows.Forms.Panel();
this.panelBlue = new System.Windows.Forms.Panel();
this.panelYellow = new System.Windows.Forms.Panel();
this.panelRed = new System.Windows.Forms.Panel();
this.checkBoxBoosters = new System.Windows.Forms.CheckBox();
this.checkBoxRocket = new System.Windows.Forms.CheckBox();
this.checkBoxRadar = new System.Windows.Forms.CheckBox();
this.labelWeight = new System.Windows.Forms.Label();
this.labelSpeed = new System.Windows.Forms.Label();
this.pictureBoxShow = new System.Windows.Forms.PictureBox();
this.panelShow = new System.Windows.Forms.Panel();
this.labelAdvancedColor = new System.Windows.Forms.Label();
this.labelColor = new System.Windows.Forms.Label();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxConfig.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
this.groupBoxColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShow)).BeginInit();
this.panelShow.SuspendLayout();
this.SuspendLayout();
//
// groupBoxConfig
//
this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
this.groupBoxConfig.Controls.Add(this.labelAdvanced);
this.groupBoxConfig.Controls.Add(this.labelSimple);
this.groupBoxConfig.Controls.Add(this.groupBoxColor);
this.groupBoxConfig.Controls.Add(this.checkBoxBoosters);
this.groupBoxConfig.Controls.Add(this.checkBoxRocket);
this.groupBoxConfig.Controls.Add(this.checkBoxRadar);
this.groupBoxConfig.Controls.Add(this.labelWeight);
this.groupBoxConfig.Controls.Add(this.labelSpeed);
this.groupBoxConfig.Location = new System.Drawing.Point(12, 12);
this.groupBoxConfig.Name = "groupBoxConfig";
this.groupBoxConfig.Size = new System.Drawing.Size(590, 357);
this.groupBoxConfig.TabIndex = 0;
this.groupBoxConfig.TabStop = false;
this.groupBoxConfig.Text = "Параметры";
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(95, 78);
this.numericUpDownWeight.Maximum = new decimal(new int[] {
250,
0,
0,
0});
this.numericUpDownWeight.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(62, 23);
this.numericUpDownWeight.TabIndex = 11;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(95, 42);
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
2500,
0,
0,
0});
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(62, 23);
this.numericUpDownSpeed.TabIndex = 10;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// labelAdvanced
//
this.labelAdvanced.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAdvanced.Location = new System.Drawing.Point(410, 192);
this.labelAdvanced.Name = "labelAdvanced";
this.labelAdvanced.Size = new System.Drawing.Size(115, 32);
this.labelAdvanced.TabIndex = 9;
this.labelAdvanced.Text = "Продвинутый";
this.labelAdvanced.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelAdvanced.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
//
// labelSimple
//
this.labelSimple.AllowDrop = true;
this.labelSimple.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimple.Location = new System.Drawing.Point(289, 192);
this.labelSimple.Name = "labelSimple";
this.labelSimple.Size = new System.Drawing.Size(115, 32);
this.labelSimple.TabIndex = 8;
this.labelSimple.Text = "Простой";
this.labelSimple.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
//
// groupBoxColor
//
this.groupBoxColor.Controls.Add(this.panelGreen);
this.groupBoxColor.Controls.Add(this.panelCyan);
this.groupBoxColor.Controls.Add(this.panelPink);
this.groupBoxColor.Controls.Add(this.panelBlack);
this.groupBoxColor.Controls.Add(this.panelPurple);
this.groupBoxColor.Controls.Add(this.panelBlue);
this.groupBoxColor.Controls.Add(this.panelYellow);
this.groupBoxColor.Controls.Add(this.panelRed);
this.groupBoxColor.Location = new System.Drawing.Point(289, 26);
this.groupBoxColor.Name = "groupBoxColor";
this.groupBoxColor.Size = new System.Drawing.Size(234, 150);
this.groupBoxColor.TabIndex = 7;
this.groupBoxColor.TabStop = false;
this.groupBoxColor.Text = "Цвета";
//
// panelGreen
//
this.panelGreen.BackColor = System.Drawing.Color.Lime;
this.panelGreen.Location = new System.Drawing.Point(65, 26);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(50, 41);
this.panelGreen.TabIndex = 1;
//
// panelCyan
//
this.panelCyan.BackColor = System.Drawing.Color.Cyan;
this.panelCyan.Location = new System.Drawing.Point(9, 89);
this.panelCyan.Name = "panelCyan";
this.panelCyan.Size = new System.Drawing.Size(50, 41);
this.panelCyan.TabIndex = 1;
//
// panelPink
//
this.panelPink.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
this.panelPink.Location = new System.Drawing.Point(65, 89);
this.panelPink.Name = "panelPink";
this.panelPink.Size = new System.Drawing.Size(50, 41);
this.panelPink.TabIndex = 1;
//
// panelBlack
//
this.panelBlack.BackColor = System.Drawing.Color.Black;
this.panelBlack.Location = new System.Drawing.Point(121, 89);
this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(50, 41);
this.panelBlack.TabIndex = 1;
//
// panelPurple
//
this.panelPurple.BackColor = System.Drawing.Color.Purple;
this.panelPurple.Location = new System.Drawing.Point(178, 89);
this.panelPurple.Name = "panelPurple";
this.panelPurple.Size = new System.Drawing.Size(50, 41);
this.panelPurple.TabIndex = 1;
//
// panelBlue
//
this.panelBlue.BackColor = System.Drawing.Color.Blue;
this.panelBlue.Location = new System.Drawing.Point(121, 26);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(50, 41);
this.panelBlue.TabIndex = 1;
//
// panelYellow
//
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.panelYellow.Location = new System.Drawing.Point(178, 26);
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(50, 41);
this.panelYellow.TabIndex = 1;
//
// panelRed
//
this.panelRed.BackColor = System.Drawing.Color.Red;
this.panelRed.Location = new System.Drawing.Point(9, 26);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(50, 41);
this.panelRed.TabIndex = 0;
//
// checkBoxBoosters
//
this.checkBoxBoosters.AutoSize = true;
this.checkBoxBoosters.Location = new System.Drawing.Point(21, 132);
this.checkBoxBoosters.Name = "checkBoxBoosters";
this.checkBoxBoosters.Size = new System.Drawing.Size(148, 19);
this.checkBoxBoosters.TabIndex = 6;
this.checkBoxBoosters.Text = "Наличие ускорителей";
this.checkBoxBoosters.UseVisualStyleBackColor = true;
this.checkBoxBoosters.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);
//
// checkBoxRocket
//
this.checkBoxRocket.AutoSize = true;
this.checkBoxRocket.Location = new System.Drawing.Point(21, 157);
this.checkBoxRocket.Name = "checkBoxRocket";
this.checkBoxRocket.Size = new System.Drawing.Size(108, 19);
this.checkBoxRocket.TabIndex = 5;
this.checkBoxRocket.Text = "Наличие ракет";
this.checkBoxRocket.UseVisualStyleBackColor = true;
this.checkBoxRocket.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);
//
// checkBoxRadar
//
this.checkBoxRadar.AutoSize = true;
this.checkBoxRadar.Location = new System.Drawing.Point(21, 107);
this.checkBoxRadar.Name = "checkBoxRadar";
this.checkBoxRadar.Size = new System.Drawing.Size(116, 19);
this.checkBoxRadar.TabIndex = 4;
this.checkBoxRadar.Text = "Наличие радара";
this.checkBoxRadar.UseVisualStyleBackColor = true;
this.checkBoxRadar.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);
//
// labelWeight
//
this.labelWeight.AutoSize = true;
this.labelWeight.Location = new System.Drawing.Point(21, 78);
this.labelWeight.Name = "labelWeight";
this.labelWeight.Size = new System.Drawing.Size(26, 15);
this.labelWeight.TabIndex = 1;
this.labelWeight.Text = "Вес";
//
// labelSpeed
//
this.labelSpeed.AutoSize = true;
this.labelSpeed.Location = new System.Drawing.Point(21, 44);
this.labelSpeed.Name = "labelSpeed";
this.labelSpeed.Size = new System.Drawing.Size(59, 15);
this.labelSpeed.TabIndex = 0;
this.labelSpeed.Text = "Скорость";
//
// pictureBoxShow
//
this.pictureBoxShow.Location = new System.Drawing.Point(38, 68);
this.pictureBoxShow.Name = "pictureBoxShow";
this.pictureBoxShow.Size = new System.Drawing.Size(481, 221);
this.pictureBoxShow.TabIndex = 1;
this.pictureBoxShow.TabStop = false;
//
// panelShow
//
this.panelShow.AllowDrop = true;
this.panelShow.Controls.Add(this.labelAdvancedColor);
this.panelShow.Controls.Add(this.labelColor);
this.panelShow.Controls.Add(this.pictureBoxShow);
this.panelShow.Location = new System.Drawing.Point(658, 22);
this.panelShow.Name = "panelShow";
this.panelShow.Size = new System.Drawing.Size(558, 292);
this.panelShow.TabIndex = 2;
this.panelShow.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelShow_DragDrop);
this.panelShow.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelShow_DragEnter);
//
// labelAdvancedColor
//
this.labelAdvancedColor.AllowDrop = true;
this.labelAdvancedColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAdvancedColor.Location = new System.Drawing.Point(320, 16);
this.labelAdvancedColor.Name = "labelAdvancedColor";
this.labelAdvancedColor.Size = new System.Drawing.Size(164, 39);
this.labelAdvancedColor.TabIndex = 3;
this.labelAdvancedColor.Text = "Дополнительный цвет";
this.labelAdvancedColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelAdvancedColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelDopColor_DragDrop);
this.labelAdvancedColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
//
// labelColor
//
this.labelColor.AllowDrop = true;
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelColor.Location = new System.Drawing.Point(82, 16);
this.labelColor.Name = "labelColor";
this.labelColor.Size = new System.Drawing.Size(164, 39);
this.labelColor.TabIndex = 2;
this.labelColor.Text = "Основной цвет";
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelBaseColor_DragDrop);
this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(677, 333);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(227, 45);
this.buttonAdd.TabIndex = 3;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(978, 333);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(227, 45);
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "Отменить";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// FormAirConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1244, 390);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.panelShow);
this.Controls.Add(this.groupBoxConfig);
this.Name = "FormAirConfig";
this.Text = "FormAirConfig";
this.groupBoxConfig.ResumeLayout(false);
this.groupBoxConfig.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
this.groupBoxColor.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShow)).EndInit();
this.panelShow.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private Label labelWeight;
private Label labelSpeed;
private Label labelAdvanced;
private Label labelSimple;
private GroupBox groupBoxColor;
private Panel panelGreen;
private Panel panelCyan;
private Panel panelPink;
private Panel panelBlack;
private Panel panelPurple;
private Panel panelBlue;
private Panel panelYellow;
private Panel panelRed;
private CheckBox checkBoxBoosters;
private CheckBox checkBoxRocket;
private CheckBox checkBoxRadar;
private PictureBox pictureBoxShow;
private Panel panelShow;
private Label labelAdvancedColor;
private Label labelColor;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Button buttonAdd;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,141 @@
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 Stormtrooper
{
public partial class FormAirConfig : Form
{
DrawningMilitaryAirplane _airplane = null;
private event Action<DrawningMilitaryAirplane> EventAddAirplane;
public FormAirConfig()
{
InitializeComponent();
panelBlack.MouseDown += PanelColor_MouseDown;
panelPurple.MouseDown += PanelColor_MouseDown;
panelPink.MouseDown += PanelColor_MouseDown;
panelGreen.MouseDown += PanelColor_MouseDown;
panelRed.MouseDown += PanelColor_MouseDown;
panelCyan.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
buttonCancel.Click += (object sender, EventArgs e) => Close();
}
private void DrawAirplane()
{
Bitmap bmp = new(pictureBoxShow.Width, pictureBoxShow.Height);
Graphics gr = Graphics.FromImage(bmp);
_airplane?.SetPosition(200, 70, pictureBoxShow.Width, pictureBoxShow.Height);
_airplane?.DrawAirplane(gr);
pictureBoxShow.Image = bmp;
}
public void AddEvent(Action<DrawningMilitaryAirplane> ev)
{
if (EventAddAirplane == null)
{
EventAddAirplane = new Action<DrawningMilitaryAirplane>(ev);
}
else
{
EventAddAirplane += ev;
}
}
private void label_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
}
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
private void labelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void labelBaseColor_DragDrop(object sender, DragEventArgs e)
{
if (_airplane != null)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
_airplane.Airplane.Color = (Color)e.Data.GetData(typeof(Color));
}
DrawAirplane();
}
}
private void labelDopColor_DragDrop(object sender, DragEventArgs e)
{
if (_airplane != null && _airplane is DrawningStormtrooper stormtrooper)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
if(stormtrooper.Airplane is EntityStormtrooper entityStormtrooper)
{
entityStormtrooper.AdvColor = (Color)e.Data.GetData(typeof(Color));
}
}
DrawAirplane();
}
}
private void panelShow_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void panelShow_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data.GetData(DataFormats.Text).ToString())
{
case "labelSimple":
_airplane = new DrawningMilitaryAirplane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
break;
case "labelAdvanced":
_airplane = new DrawningStormtrooper((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black,
checkBoxRocket.Checked, checkBoxBoosters.Checked, checkBoxRadar.Checked);
break;
}
DrawAirplane();
}
private void checkBox_CheckedChanged(object sender, EventArgs e)
{
if(_airplane is DrawningStormtrooper)
{
_airplane = new DrawningStormtrooper((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, _airplane.Airplane.Color, (_airplane.Airplane as EntityStormtrooper).AdvColor,
checkBoxRocket.Checked, checkBoxBoosters.Checked, checkBoxRadar.Checked);
DrawAirplane();
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
EventAddAirplane?.Invoke(_airplane);
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<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>

View File

@ -0,0 +1,214 @@

namespace Stormtrooper
{
partial class FormMap
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
this.pictureBoxAirplane = new System.Windows.Forms.PictureBox();
this.buttonCreate = new System.Windows.Forms.Button();
this.toolStripStatus = new System.Windows.Forms.ToolStrip();
this.toolStripLabelSpeed = new System.Windows.Forms.ToolStripLabel();
this.toolStripLabelWeight = new System.Windows.Forms.ToolStripLabel();
this.toolStripLabelCrew = new System.Windows.Forms.ToolStripLabel();
this.buttonUp = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonCreateMod = new System.Windows.Forms.Button();
this.comboBoxMapSelector = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit();
this.toolStripStatus.SuspendLayout();
this.SuspendLayout();
//
// pictureBoxAirplane
//
this.pictureBoxAirplane.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pictureBoxAirplane.BackColor = System.Drawing.Color.White;
this.pictureBoxAirplane.Location = new System.Drawing.Point(14, 14);
this.pictureBoxAirplane.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.pictureBoxAirplane.Name = "pictureBoxAirplane";
this.pictureBoxAirplane.Size = new System.Drawing.Size(1127, 558);
this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxAirplane.TabIndex = 0;
this.pictureBoxAirplane.TabStop = false;
//
// buttonCreate
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreate.Cursor = System.Windows.Forms.Cursors.Hand;
this.buttonCreate.Location = new System.Drawing.Point(31, 598);
this.buttonCreate.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(88, 27);
this.buttonCreate.TabIndex = 1;
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
//
// toolStripStatus
//
this.toolStripStatus.Dock = System.Windows.Forms.DockStyle.Bottom;
this.toolStripStatus.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripLabelSpeed,
this.toolStripLabelWeight,
this.toolStripLabelCrew});
this.toolStripStatus.Location = new System.Drawing.Point(0, 678);
this.toolStripStatus.Name = "toolStripStatus";
this.toolStripStatus.Size = new System.Drawing.Size(1343, 25);
this.toolStripStatus.TabIndex = 2;
this.toolStripStatus.Text = "toolStrip1";
//
// toolStripLabelSpeed
//
this.toolStripLabelSpeed.Name = "toolStripLabelSpeed";
this.toolStripLabelSpeed.Size = new System.Drawing.Size(86, 22);
this.toolStripLabelSpeed.Text = "toolStripLabel1";
//
// toolStripLabelWeight
//
this.toolStripLabelWeight.Name = "toolStripLabelWeight";
this.toolStripLabelWeight.Size = new System.Drawing.Size(86, 22);
this.toolStripLabelWeight.Text = "toolStripLabel2";
//
// toolStripLabelCrew
//
this.toolStripLabelCrew.Name = "toolStripLabelCrew";
this.toolStripLabelCrew.Size = new System.Drawing.Size(86, 22);
this.toolStripLabelCrew.Text = "toolStripLabel3";
//
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.Location = new System.Drawing.Point(1203, 556);
this.buttonUp.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(35, 35);
this.buttonUp.TabIndex = 3;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.Location = new System.Drawing.Point(1203, 598);
this.buttonDown.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(35, 35);
this.buttonDown.TabIndex = 4;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonLeft
//
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.Location = new System.Drawing.Point(1161, 597);
this.buttonLeft.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(35, 35);
this.buttonLeft.TabIndex = 5;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonRight
//
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.Location = new System.Drawing.Point(1245, 597);
this.buttonRight.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(35, 35);
this.buttonRight.TabIndex = 6;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonCreateMod
//
this.buttonCreateMod.Location = new System.Drawing.Point(162, 598);
this.buttonCreateMod.Name = "buttonCreateMod";
this.buttonCreateMod.Size = new System.Drawing.Size(104, 27);
this.buttonCreateMod.TabIndex = 7;
this.buttonCreateMod.Text = "Модификация";
this.buttonCreateMod.UseVisualStyleBackColor = true;
this.buttonCreateMod.Click += new System.EventHandler(this.buttonCreateMod_Click);
//
// comboBoxMapSelector
//
this.comboBoxMapSelector.FormattingEnabled = true;
this.comboBoxMapSelector.Items.AddRange(new object[] {
"Простая карта",
"Опасная карта",
"Облачная карта"});
this.comboBoxMapSelector.Location = new System.Drawing.Point(31, 27);
this.comboBoxMapSelector.Name = "comboBoxMapSelector";
this.comboBoxMapSelector.Size = new System.Drawing.Size(117, 23);
this.comboBoxMapSelector.TabIndex = 8;
this.comboBoxMapSelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxMapSelector_SelectedIndexChanged);
//
// FormMap
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1343, 703);
this.Controls.Add(this.comboBoxMapSelector);
this.Controls.Add(this.buttonCreateMod);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.toolStripStatus);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxAirplane);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "FormMap";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit();
this.toolStripStatus.ResumeLayout(false);
this.toolStripStatus.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBoxAirplane;
private System.Windows.Forms.Button buttonCreate;
private System.Windows.Forms.ToolStrip toolStripStatus;
private System.Windows.Forms.ToolStripLabel toolStripLabelSpeed;
private System.Windows.Forms.ToolStripLabel toolStripLabelWeight;
private System.Windows.Forms.ToolStripLabel toolStripLabelCrew;
private System.Windows.Forms.Button buttonUp;
private System.Windows.Forms.Button buttonDown;
private System.Windows.Forms.Button buttonLeft;
private System.Windows.Forms.Button buttonRight;
private Button buttonCreateMod;
private ComboBox comboBoxMapSelector;
}
}

View File

@ -0,0 +1,88 @@
using Strormtrooper;
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 Stormtrooper
{
public partial class FormMap : Form
{
DrawningMilitaryAirplane _airplane;
AbstractMap _abstractMap;
public FormMap()
{
InitializeComponent();
_abstractMap = new SimpleMap();
}
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new Random();
_airplane = new DrawningMilitaryAirplane(10, 50, Color.DarkGreen);
_airplane.SetPosition(random.Next(100,150), random.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
SetData();
}
private void buttonMove_Click(object sender,EventArgs e)
{
//получаем имя кнопки
string name = ((Button)sender)?.Name ?? string.Empty;
Direction dir = Direction.None;
switch (name)
{
case "buttonUp":
dir = Direction.Up;
break;
case "buttonDown":
dir = Direction.Down;
break;
case "buttonLeft":
dir = Direction.Left;
break;
case "buttonRight":
dir = Direction.Right;
break;
}
pictureBoxAirplane.Image = _abstractMap?.MoveObject(dir);
}
private void SetData()
{
toolStripLabelSpeed.Text = $"Скорость: {_airplane.Airplane.Speed}";
toolStripLabelWeight.Text = $"Вес: {_airplane.Airplane.Weight}";
pictureBoxAirplane.Image = _abstractMap.CreateMap(pictureBoxAirplane.Width, pictureBoxAirplane.Height,
new DrawningObject(_airplane));
}
private void buttonCreateMod_Click(object sender, EventArgs e)
{
Random random = new Random();
_airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0,256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0,2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_airplane.SetPosition(random.Next(100, 150), random.Next(100, 150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
SetData();
}
private void comboBoxMapSelector_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxMapSelector.Text)
{
case "Простая карта":
_abstractMap = new SimpleMap();
break;
case "Опасная карта":
_abstractMap = new DangerMap();
break;
case "Облачная карта":
_abstractMap = new CloudMap();
break;
}
}
}
}

View File

@ -0,0 +1,66 @@
<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>
<metadata name="toolStripStatus.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root>

View File

@ -0,0 +1,332 @@
namespace Stormtrooper
{
partial class FormMapWithSetAirplane
{
/// <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.groupBoxTools = new System.Windows.Forms.GroupBox();
this.groupBoxMap = new System.Windows.Forms.GroupBox();
this.buttonRemoveMap = new System.Windows.Forms.Button();
this.listBoxMap = new System.Windows.Forms.ListBox();
this.textBoxMapName = new System.Windows.Forms.TextBox();
this.buttonAddMap = new System.Windows.Forms.Button();
this.comboBoxMapSelector = new System.Windows.Forms.ComboBox();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.buttonShowOnMap = new System.Windows.Forms.Button();
this.buttonShowStorage = new System.Windows.Forms.Button();
this.buttonRemove = new System.Windows.Forms.Button();
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
this.buttonCreate = new System.Windows.Forms.Button();
this.pictureBox = new System.Windows.Forms.PictureBox();
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.groupBoxTools.SuspendLayout();
this.groupBoxMap.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// groupBoxTools
//
this.groupBoxTools.Controls.Add(this.groupBoxMap);
this.groupBoxTools.Controls.Add(this.buttonRight);
this.groupBoxTools.Controls.Add(this.buttonLeft);
this.groupBoxTools.Controls.Add(this.buttonDown);
this.groupBoxTools.Controls.Add(this.buttonUp);
this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
this.groupBoxTools.Controls.Add(this.buttonShowStorage);
this.groupBoxTools.Controls.Add(this.buttonRemove);
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
this.groupBoxTools.Controls.Add(this.buttonCreate);
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
this.groupBoxTools.Location = new System.Drawing.Point(1069, 24);
this.groupBoxTools.Name = "groupBoxTools";
this.groupBoxTools.Size = new System.Drawing.Size(200, 564);
this.groupBoxTools.TabIndex = 0;
this.groupBoxTools.TabStop = false;
this.groupBoxTools.Text = "Инструменты";
//
// groupBoxMap
//
this.groupBoxMap.Controls.Add(this.buttonRemoveMap);
this.groupBoxMap.Controls.Add(this.listBoxMap);
this.groupBoxMap.Controls.Add(this.textBoxMapName);
this.groupBoxMap.Controls.Add(this.buttonAddMap);
this.groupBoxMap.Controls.Add(this.comboBoxMapSelector);
this.groupBoxMap.Location = new System.Drawing.Point(6, 22);
this.groupBoxMap.Name = "groupBoxMap";
this.groupBoxMap.Size = new System.Drawing.Size(182, 259);
this.groupBoxMap.TabIndex = 19;
this.groupBoxMap.TabStop = false;
this.groupBoxMap.Text = "Карты";
//
// buttonRemoveMap
//
this.buttonRemoveMap.Location = new System.Drawing.Point(20, 207);
this.buttonRemoveMap.Name = "buttonRemoveMap";
this.buttonRemoveMap.Size = new System.Drawing.Size(144, 23);
this.buttonRemoveMap.TabIndex = 13;
this.buttonRemoveMap.Text = "Удалить карту";
this.buttonRemoveMap.UseVisualStyleBackColor = true;
this.buttonRemoveMap.Click += new System.EventHandler(this.ButtonRemoveMap_Click);
//
// listBoxMap
//
this.listBoxMap.FormattingEnabled = true;
this.listBoxMap.ItemHeight = 15;
this.listBoxMap.Location = new System.Drawing.Point(18, 104);
this.listBoxMap.Name = "listBoxMap";
this.listBoxMap.Size = new System.Drawing.Size(146, 94);
this.listBoxMap.TabIndex = 12;
this.listBoxMap.SelectedIndexChanged += new System.EventHandler(this.listBoxMap_SelectedIndexChanged);
//
// textBoxMapName
//
this.textBoxMapName.Location = new System.Drawing.Point(18, 17);
this.textBoxMapName.Name = "textBoxMapName";
this.textBoxMapName.Size = new System.Drawing.Size(146, 23);
this.textBoxMapName.TabIndex = 11;
//
// buttonAddMap
//
this.buttonAddMap.Location = new System.Drawing.Point(18, 75);
this.buttonAddMap.Name = "buttonAddMap";
this.buttonAddMap.Size = new System.Drawing.Size(146, 23);
this.buttonAddMap.TabIndex = 10;
this.buttonAddMap.Text = "Добавить карту";
this.buttonAddMap.UseVisualStyleBackColor = true;
this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
//
// comboBoxMapSelector
//
this.comboBoxMapSelector.BackColor = System.Drawing.SystemColors.Window;
this.comboBoxMapSelector.FormattingEnabled = true;
this.comboBoxMapSelector.Items.AddRange(new object[] {
"Простая карта",
"Опасная карта",
"Облачная карта"});
this.comboBoxMapSelector.Location = new System.Drawing.Point(18, 46);
this.comboBoxMapSelector.Name = "comboBoxMapSelector";
this.comboBoxMapSelector.Size = new System.Drawing.Size(146, 23);
this.comboBoxMapSelector.TabIndex = 9;
//
// buttonRight
//
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.Location = new System.Drawing.Point(119, 516);
this.buttonRight.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(35, 35);
this.buttonRight.TabIndex = 18;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonLeft
//
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.Location = new System.Drawing.Point(35, 516);
this.buttonLeft.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(35, 35);
this.buttonLeft.TabIndex = 17;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.Location = new System.Drawing.Point(77, 517);
this.buttonDown.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(35, 35);
this.buttonDown.TabIndex = 16;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.Location = new System.Drawing.Point(77, 475);
this.buttonUp.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(35, 35);
this.buttonUp.TabIndex = 15;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonShowOnMap
//
this.buttonShowOnMap.Location = new System.Drawing.Point(8, 453);
this.buttonShowOnMap.Name = "buttonShowOnMap";
this.buttonShowOnMap.Size = new System.Drawing.Size(174, 23);
this.buttonShowOnMap.TabIndex = 14;
this.buttonShowOnMap.Text = "Посмотреть карту";
this.buttonShowOnMap.UseVisualStyleBackColor = true;
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
//
// buttonShowStorage
//
this.buttonShowStorage.Location = new System.Drawing.Point(8, 424);
this.buttonShowStorage.Name = "buttonShowStorage";
this.buttonShowStorage.Size = new System.Drawing.Size(174, 23);
this.buttonShowStorage.TabIndex = 13;
this.buttonShowStorage.Text = "Посмотреть хранилище";
this.buttonShowStorage.UseVisualStyleBackColor = true;
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
//
// buttonRemove
//
this.buttonRemove.Location = new System.Drawing.Point(7, 378);
this.buttonRemove.Name = "buttonRemove";
this.buttonRemove.Size = new System.Drawing.Size(174, 23);
this.buttonRemove.TabIndex = 12;
this.buttonRemove.Text = "Удалить самолёт";
this.buttonRemove.UseVisualStyleBackColor = true;
this.buttonRemove.Click += new System.EventHandler(this.ButtonRemove_Click);
//
// maskedTextBoxPosition
//
this.maskedTextBoxPosition.Location = new System.Drawing.Point(8, 347);
this.maskedTextBoxPosition.Mask = "00";
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
this.maskedTextBoxPosition.TabIndex = 11;
this.maskedTextBoxPosition.ValidatingType = typeof(int);
//
// buttonCreate
//
this.buttonCreate.Location = new System.Drawing.Point(8, 318);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(175, 23);
this.buttonCreate.TabIndex = 10;
this.buttonCreate.Text = "Добавить самолёт";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Location = new System.Drawing.Point(0, 24);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(1069, 564);
this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false;
//
// menuStrip
//
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.файлToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1269, 24);
this.menuStrip.TabIndex = 2;
this.menuStrip.Text = "menuStrip1";
//
// файлToolStripMenuItem
//
this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.SaveToolStripMenuItem,
this.LoadToolStripMenuItem});
this.файлToolStripMenuItem.Name = айлToolStripMenuItem";
this.файлToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
this.файлToolStripMenuItem.Text = "Файл";
//
// SaveToolStripMenuItem
//
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.SaveToolStripMenuItem.Text = "Сохранение";
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
//
// LoadToolStripMenuItem
//
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.LoadToolStripMenuItem.Text = "Загрузка";
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
//
// openFileDialog
//
this.openFileDialog.FileName = "openFileDialog1";
//
// FormMapWithSetAirplane
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1269, 588);
this.Controls.Add(this.pictureBox);
this.Controls.Add(this.groupBoxTools);
this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip;
this.Name = "FormMapWithSetAirplane";
this.Text = "FormMapWithSetAirplane";
this.groupBoxTools.ResumeLayout(false);
this.groupBoxTools.PerformLayout();
this.groupBoxMap.ResumeLayout(false);
this.groupBoxMap.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private GroupBox groupBoxTools;
private PictureBox pictureBox;
private Button buttonShowOnMap;
private Button buttonShowStorage;
private Button buttonRemove;
private MaskedTextBox maskedTextBoxPosition;
private Button buttonCreate;
private ComboBox comboBoxMapSelector;
private Button buttonRight;
private Button buttonLeft;
private Button buttonDown;
private Button buttonUp;
private GroupBox groupBoxMap;
private TextBox textBoxMapName;
private Button buttonAddMap;
private Button buttonRemoveMap;
private ListBox listBoxMap;
private MenuStrip menuStrip;
private ToolStripMenuItem файлToolStripMenuItem;
private ToolStripMenuItem SaveToolStripMenuItem;
private ToolStripMenuItem LoadToolStripMenuItem;
private SaveFileDialog saveFileDialog;
private OpenFileDialog openFileDialog;
}
}

View File

@ -0,0 +1,293 @@
using Microsoft.Extensions.Logging;
using Strormtrooper;
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 static System.Windows.Forms.DataFormats;
namespace Stormtrooper
{
public partial class FormMapWithSetAirplane : Form
{
private readonly ILogger _logger;
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
{
{"Простая карта", new SimpleMap()},
{"Опасная карта", new DangerMap()},
{"Облачная карта", new CloudMap()}
};
/// <summary>
/// Объект от коллекции карт
/// </summary>
private readonly MapCollection _mapCollection;
public FormMapWithSetAirplane(ILogger<FormMapWithSetAirplane> logger)
{
_logger = logger;
InitializeComponent();
openFileDialog.Filter = "Text files(*.txt)|*.txt";
saveFileDialog.Filter = "Text files(*.txt)|*.txt";
_mapCollection = new MapCollection(pictureBox.Width, pictureBox.Height);
comboBoxMapSelector.Items.Clear();
foreach(var map in _mapsDict)
{
comboBoxMapSelector.Items.Add(map.Key);
}
}
/// <summary>
/// Выбор карты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ReloadMaps()
{
int index = listBoxMap.SelectedIndex;
listBoxMap.Items.Clear();
for (int i = 0; i < _mapCollection.Keys.Count; i++)
{
listBoxMap.Items.Add(_mapCollection.Keys[i]);
}
if (listBoxMap.Items.Count > 0 && (index == -1 || index >= listBoxMap.Items.Count))
{
listBoxMap.SelectedIndex = 0;
}
else if (listBoxMap.Items.Count > 0 && index > -1 && index < listBoxMap.Items.Count)
{
listBoxMap.SelectedIndex = index;
}
}
private void ButtonAddMap_Click(object sender, EventArgs e)
{
if (comboBoxMapSelector.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxMapName.Text))
{
_logger.LogInformation("Не все данные заполнены при попытке создании карты");
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!_mapsDict.ContainsKey(comboBoxMapSelector.Text))
{
_logger.LogInformation($"Нет карты с названием {comboBoxMapSelector.Text}");
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (textBoxMapName.Text.Contains('|') || textBoxMapName.Text.Contains(':') || textBoxMapName.Text.Contains(';'))
{
_logger.LogInformation("Присутствуют символы, недопустимые для имени карты");
MessageBox.Show("Присутствуют символы, недопустимые для имени карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_mapCollection.AddMap(textBoxMapName.Text, _mapsDict[comboBoxMapSelector.Text]);
ReloadMaps();
_logger.LogInformation($"Добавлена карта {textBoxMapName.Text}");
}
/// <summary>
/// Добавление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAdd_Click(object sender, EventArgs e)
{
var formAirConfig = new FormAirConfig();
formAirConfig.AddEvent(AddAirplane);
formAirConfig.Show();
}
private void AddAirplane(DrawningMilitaryAirplane drawningMilitaryAirplane)
{
if (listBoxMap.SelectedIndex == -1)
{
return;
}
DrawningObject airplane = new(drawningMilitaryAirplane);
try
{
if (_mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty] + airplane != -1)
{
_logger.LogInformation($"Добавление объекта {airplane}");
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
_logger.LogInformation("Не удалось добавить объект");
MessageBox.Show("Не удалось добавить объект");
}
}
catch (StorageOverflowException ex)
{
_logger.LogWarning($"Ошибка переполнения хранилища: {ex.Message}");
MessageBox.Show($"Ошибка переполнения хранилища: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
_logger.LogWarning($"Неизвестная ошибка: {ex.Message}");
MessageBox.Show($"Неизвестная ошибка: {ex.Message}");
}
}
/// <summary>
/// Удаление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (listBoxMap.SelectedIndex == -1)
{
return;
}
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
try
{
var deletedAirplane = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty] - pos;
if (deletedAirplane != null)
{
_logger.LogInformation($"Объект {deletedAirplane} удалён");
MessageBox.Show("Объект удален");
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
catch (AirplaneNotFoundException ex)
{
_logger.LogWarning($"Ошибка удаления: {ex.Message}");
MessageBox.Show($"Ошибка удаления: {ex.Message}");
}
catch(Exception ex)
{
_logger.LogWarning($"Неизвестная ошибка: {ex.Message}");
MessageBox.Show($"Неизвестная ошибка: {ex.Message}");
}
}
/// <summary>
/// Вывод набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonShowStorage_Click(object sender, EventArgs e)
{
if (listBoxMap.SelectedIndex == -1)
{
return;
}
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
/// <summary>
/// Вывод карты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonShowOnMap_Click(object sender, EventArgs e)
{
if (listBoxMap.SelectedIndex == -1)
{
return;
}
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
}
/// <summary>
/// Перемещение
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonMove_Click(object sender, EventArgs e)
{
if (listBoxMap.SelectedIndex == -1)
{
return;
}
//получаем имя кнопки
string name = ((Button)sender)?.Name ?? string.Empty;
Direction dir = Direction.None;
switch (name)
{
case "buttonUp":
dir = Direction.Up;
break;
case "buttonDown":
dir = Direction.Down;
break;
case "buttonLeft":
dir = Direction.Left;
break;
case "buttonRight":
dir = Direction.Right;
break;
}
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
}
private void listBoxMap_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet();
_logger.LogInformation($"Текущая карта сменена на {listBoxMap.SelectedItem?.ToString() ?? string.Empty}");
}
private void ButtonRemoveMap_Click(object sender, EventArgs e)
{
if (listBoxMap.SelectedIndex == -1)
{
return;
}
if (MessageBox.Show($"Удалить карту {listBoxMap.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
_mapCollection.DelMap(listBoxMap.SelectedItem?.ToString() ?? string.Empty);
ReloadMaps();
_logger.LogInformation($"Удалена карта {listBoxMap.SelectedItem?.ToString() ?? string.Empty}");
}
}
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
{
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
_mapCollection.SaveData(saveFileDialog.FileName);
_logger.LogInformation($"Успешное сохранение по пути {saveFileDialog.FileName}");
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogWarning($"Не удалось сохранить данные. Ошибка - {ex.Message}");
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
_mapCollection.LoadData(openFileDialog.FileName);
ReloadMaps();
_logger.LogInformation($"Успешная загрузка по пути {openFileDialog.FileName}");
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogWarning($"Не удалось загрузить данные. Ошибка - {ex.Message}");
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -0,0 +1,69 @@
<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>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>125, 17</value>
</metadata>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>254, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal interface IDrawningObject
{
/// <summary>
/// Шаг перемещения объекта
/// </summary>
public float Step { get; }
/// <summary>
/// Установка позиции объекта
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
/// <param name="width">Ширина полотна</param>
/// <param name="height">Высота полотна</param>
void SetObject(int x, int y, int width, int height);
/// <summary>
/// Изменение направления пермещения объекта
/// </summary>
/// <param name="direction">Направление</param>
/// <returns></returns>
void MoveObject(Direction direction);
/// <summary>
/// Отрисовка объекта
/// </summary>
/// <param name="g"></param>
void DrawningObject(Graphics g);
/// <summary>
/// Получение текущей позиции объекта
/// </summary>
/// <returns></returns>
(float Left, float Top, float Right, float Bottom) GetCurrentPosition();
string GetInfo();
}
}

View File

@ -39,6 +39,8 @@ namespace Stormtrooper
this.buttonDown = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonCreateMod = new System.Windows.Forms.Button();
this.button_Add = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit();
this.toolStripStatus.SuspendLayout();
this.SuspendLayout();
@ -49,7 +51,8 @@ namespace Stormtrooper
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pictureBoxAirplane.BackColor = System.Drawing.Color.White;
this.pictureBoxAirplane.Location = new System.Drawing.Point(12, 12);
this.pictureBoxAirplane.Location = new System.Drawing.Point(14, 14);
this.pictureBoxAirplane.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.pictureBoxAirplane.Name = "pictureBoxAirplane";
this.pictureBoxAirplane.Size = new System.Drawing.Size(1127, 558);
this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
@ -61,9 +64,10 @@ namespace Stormtrooper
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreate.Cursor = System.Windows.Forms.Cursors.Hand;
this.buttonCreate.Location = new System.Drawing.Point(27, 518);
this.buttonCreate.Location = new System.Drawing.Point(31, 598);
this.buttonCreate.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
this.buttonCreate.Size = new System.Drawing.Size(88, 27);
this.buttonCreate.TabIndex = 1;
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
@ -76,9 +80,9 @@ namespace Stormtrooper
this.toolStripLabelSpeed,
this.toolStripLabelWeight,
this.toolStripLabelCrew});
this.toolStripStatus.Location = new System.Drawing.Point(0, 584);
this.toolStripStatus.Location = new System.Drawing.Point(0, 678);
this.toolStripStatus.Name = "toolStripStatus";
this.toolStripStatus.Size = new System.Drawing.Size(1151, 25);
this.toolStripStatus.Size = new System.Drawing.Size(1343, 25);
this.toolStripStatus.TabIndex = 2;
this.toolStripStatus.Text = "toolStrip1";
//
@ -103,9 +107,10 @@ namespace Stormtrooper
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.Location = new System.Drawing.Point(1031, 482);
this.buttonUp.Location = new System.Drawing.Point(1203, 556);
this.buttonUp.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(30, 30);
this.buttonUp.Size = new System.Drawing.Size(35, 35);
this.buttonUp.TabIndex = 3;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
@ -113,9 +118,10 @@ namespace Stormtrooper
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.Location = new System.Drawing.Point(1031, 518);
this.buttonDown.Location = new System.Drawing.Point(1203, 598);
this.buttonDown.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(30, 30);
this.buttonDown.Size = new System.Drawing.Size(35, 35);
this.buttonDown.TabIndex = 4;
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
@ -123,9 +129,10 @@ namespace Stormtrooper
// buttonLeft
//
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.Location = new System.Drawing.Point(995, 517);
this.buttonLeft.Location = new System.Drawing.Point(1161, 597);
this.buttonLeft.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
this.buttonLeft.Size = new System.Drawing.Size(35, 35);
this.buttonLeft.TabIndex = 5;
this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
@ -133,18 +140,41 @@ namespace Stormtrooper
// buttonRight
//
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRight.Location = new System.Drawing.Point(1067, 517);
this.buttonRight.Location = new System.Drawing.Point(1245, 597);
this.buttonRight.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(30, 30);
this.buttonRight.Size = new System.Drawing.Size(35, 35);
this.buttonRight.TabIndex = 6;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonCreateMod
//
this.buttonCreateMod.Location = new System.Drawing.Point(162, 598);
this.buttonCreateMod.Name = "buttonCreateMod";
this.buttonCreateMod.Size = new System.Drawing.Size(104, 27);
this.buttonCreateMod.TabIndex = 7;
this.buttonCreateMod.Text = "Модификация";
this.buttonCreateMod.UseVisualStyleBackColor = true;
this.buttonCreateMod.Click += new System.EventHandler(this.buttonCreateMod_Click);
//
// button_Add
//
this.button_Add.Location = new System.Drawing.Point(573, 600);
this.button_Add.Name = "button_Add";
this.button_Add.Size = new System.Drawing.Size(75, 23);
this.button_Add.TabIndex = 8;
this.button_Add.Text = "Добавить";
this.button_Add.UseVisualStyleBackColor = true;
this.button_Add.Click += new System.EventHandler(this.button_Add_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1151, 609);
this.ClientSize = new System.Drawing.Size(1343, 703);
this.Controls.Add(this.button_Add);
this.Controls.Add(this.buttonCreateMod);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonDown);
@ -152,6 +182,7 @@ namespace Stormtrooper
this.Controls.Add(this.toolStripStatus);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxAirplane);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "MainForm";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit();
@ -174,6 +205,8 @@ namespace Stormtrooper
private System.Windows.Forms.Button buttonDown;
private System.Windows.Forms.Button buttonLeft;
private System.Windows.Forms.Button buttonRight;
private Button buttonCreateMod;
private Button button_Add;
}
}

View File

@ -13,6 +13,7 @@ namespace Stormtrooper
public partial class MainForm : Form
{
DrawningMilitaryAirplane _airplane;
public DrawningMilitaryAirplane SelectedAirplane { get; private set; }
public MainForm()
{
InitializeComponent();
@ -29,12 +30,15 @@ namespace Stormtrooper
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new Random();
_airplane = new DrawningMilitaryAirplane();
_airplane.Init(10, 50);
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;
}
_airplane = new DrawningMilitaryAirplane(10, 50, color);
_airplane.SetPosition(random.Next(100,150), random.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
toolStripLabelSpeed.Text = $"Скорость: {_airplane.Airplane.Speed}";
toolStripLabelWeight.Text = $"Вес: {_airplane.Airplane.Weight}";
toolStripLabelCrew.Text = $"Экипаж: {_airplane.Airplane.Crew}";
SetData();
Draw();
}
@ -65,5 +69,39 @@ namespace Stormtrooper
}
Draw();
}
private void SetData()
{
toolStripLabelSpeed.Text = $"Скорость: {_airplane.Airplane.Speed}";
toolStripLabelWeight.Text = $"Вес: {_airplane.Airplane.Weight}";
}
private void buttonCreateMod_Click(object sender, EventArgs e)
{
Random random = new Random();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
Color advColor = 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;
}
if (dialog.ShowDialog() == DialogResult.OK)
{
advColor = dialog.Color;
}
_airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250),advColor,
color,
Convert.ToBoolean(random.Next(0,2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_airplane.SetPosition(random.Next(100, 150), random.Next(100, 150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
SetData();
Draw();
}
private void button_Add_Click(object sender, EventArgs e)
{
SelectedAirplane = _airplane;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -1,64 +1,4 @@
<?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.
-->
<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">

View File

@ -0,0 +1,144 @@
using Strormtrooper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal class MapCollection
{
/// <summary>
/// Словарь (хранилище) с картами
/// </summary>
readonly Dictionary<string, MapWithSetAirplaneGeneric<IDrawningObject, AbstractMap>> _mapStorages;
private readonly char separatorDict = '|';
private readonly char separatorData = ';';
/// <summary>
/// Возвращение списка названий карт
/// </summary>
public List<string> Keys => _mapStorages.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 MapCollection(int pictureWidth, int pictureHeight)
{
_mapStorages = new Dictionary<string, MapWithSetAirplaneGeneric<IDrawningObject, AbstractMap>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
/// <summary>
/// Добавление карты
/// </summary>
/// <param name="name">Название карты</param>
/// <param name="map">Карта</param>
public void AddMap(string name, AbstractMap map)
{
// Добавление карты
MapWithSetAirplaneGeneric<IDrawningObject, AbstractMap> newMap = new(_pictureWidth, _pictureHeight, map);
if (!_mapStorages.ContainsKey(name))
_mapStorages.Add(name, newMap);
}
/// <summary>
/// Удаление карты
/// </summary>
/// <param name="name">Название карты</param>
public void DelMap(string name)
{
// Удаление карты
if (!_mapStorages.ContainsKey(name))
{
return;
}
_mapStorages.Remove(name);
}
public void SaveData(string filename)
{
if (File.Exists(filename))
{
File.Delete(filename);
}
using (StreamWriter sw = new(filename))
{
sw.Write($"MapCollection{Environment.NewLine}");
foreach (var storage in _mapStorages)
{
sw.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}");
}
}
}
/// <summary>
/// Загрузка информации по локомотивам в депо из файла
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
public void LoadData(string filename)
{
if (!File.Exists(filename))
{
throw new FileNotFoundException("Файл не найден");
}
using (StreamReader sr = new(filename))
{
string str = sr.ReadLine();
if (!str.Contains("MapCollection"))
{
//если нет такой записи, то это не те данные
throw new FileFormatException("Формат данных в файле неправильный");
}
_mapStorages.Clear();
while ((str = sr.ReadLine()) != null)
{
var elem = str.Split(separatorDict);
AbstractMap map = null;
switch (elem[1])
{
case "SimpleMap":
map = new SimpleMap();
break;
case "DangerMap":
map = new DangerMap();
break;
case "CloudMap":
map = new CloudMap();
break;
}
_mapStorages.Add(elem[0], new MapWithSetAirplaneGeneric<IDrawningObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
_mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
}
}
}
/// <summary>
/// Доступ к гавани
/// </summary>
/// <param name="ind"></param>
/// <returns></returns>
public MapWithSetAirplaneGeneric<IDrawningObject, AbstractMap> this[string index]
{
get
{
// Получение объекта
if (_mapStorages.ContainsKey(index))
{
return _mapStorages[index];
}
return null;
}
}
}
}

View File

@ -0,0 +1,208 @@
using Strormtrooper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal class MapWithSetAirplaneGeneric<T, U>
where T : class, IDrawningObject
where U : AbstractMap
{
/// <summary>
/// Ширина окна отрисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна отрисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Размер занимаемого объектом места (ширина)
/// </summary>
private readonly int _placeSizeWidth = 210;
/// <summary>
/// Размер занимаемого объектом места (высота)
/// </summary>
private readonly int _placeSizeHeight = 110;
/// <summary>
/// Набор объектов
/// </summary>
private readonly SetAirplaneGeneric<T> _setAirs;
/// <summary>
/// Карта
/// </summary>
private readonly U _map;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
/// <param name="map"></param>
public MapWithSetAirplaneGeneric(int picWidth, int picHeight, U map)
{
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_setAirs = new SetAirplaneGeneric<T>(width * height);
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_map = map;
}
/// <summary>
/// Перегрузка оператора сложения
/// </summary>
/// <param name="map"></param>
/// <param name="air"></param>
/// <returns></returns>
public static int operator +(MapWithSetAirplaneGeneric<T, U> map, T air)
{
return map._setAirs.Insert(air);
}
/// <summary>
/// Перегрузка оператора вычитания
/// </summary>
/// <param name="map"></param>
/// <param name="position"></param>
/// <returns></returns>
public static T operator -(MapWithSetAirplaneGeneric<T, U> map, int position)
{
return map._setAirs.Remove(position);
}
/// <summary>
/// Вывод всего набора объектов
/// </summary>
/// <returns></returns>
public Bitmap ShowSet()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
Graphics gr = Graphics.FromImage(bmp);
DrawBackground(gr);
DrawAirs(gr);
return bmp;
}
/// <summary>
/// Просмотр объекта на карте
/// </summary>
/// <returns></returns>
public Bitmap ShowOnMap()
{
foreach (var air in _setAirs.GetAirs())
{
return _map.CreateMap(_pictureWidth, _pictureHeight, air);
}
return new(_pictureWidth, _pictureHeight);
}
/// <summary>
/// Перемещение объекта по крате
/// </summary>
/// <param name="direction"></param>
/// <returns></returns>
public Bitmap MoveObject(Direction direction)
{
if (_map != null)
{
return _map.MoveObject(direction);
}
return new(_pictureWidth, _pictureHeight);
}
public string GetData(char separatorType, char separatorData)
{
string data = $"{_map.GetType().Name}{separatorType}";
foreach (var air in _setAirs.GetAirs())
{
data += $"{air.GetInfo()}{separatorData}";
}
return data;
}
public void LoadData(string[] records)
{
foreach (var rec in records.Reverse())
{
_setAirs.Insert(DrawningObject.Create(rec) as T);
}
}
/// <summary>
/// "Взбалтываем" набор, чтобы все элементы оказались в начале
/// </summary>
private void Shaking()
{
int j = _setAirs.Count - 1;
for (int i = 0; i < _setAirs.Count; i++)
{
if (_setAirs[i] == null)
{
for (; j > i; j--)
{
var air = _setAirs[j];
if (air != null)
{
_setAirs.Insert(air, i);
_setAirs.Remove(j);
break;
}
}
if (j <= i)
{
return;
}
}
}
}
/// <summary>
/// Метод отрисовки фона
/// </summary>
/// <param name="g"></param>
private void DrawBackground(Graphics g)
{
Pen pen = new(Color.Black, 3);
g.FillRectangle(new SolidBrush(Color.DarkGray),0,0,_pictureWidth, _pictureHeight);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
g.FillRectangle(new SolidBrush(Color.Gray), i * _placeSizeWidth, 0, _placeSizeWidth / 2, _placeSizeHeight * (_pictureHeight / _placeSizeHeight));
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 DrawAirs(Graphics g)
{
int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
int currentWidth = width - 1;
int currentHeight = 0;
foreach (var air in _setAirs.GetAirs())
{
air?.SetObject(currentWidth * _placeSizeWidth,
currentHeight * _placeSizeHeight,
_pictureWidth, _pictureHeight);
air?.DrawningObject(g);
if (currentWidth > 0)
currentWidth--;
else
{
currentWidth = width - 1;
currentHeight++;
}
if (currentHeight > height) return;
}
}
}
}

View File

@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;
namespace Stormtrooper
{
@ -16,7 +15,31 @@ namespace Stormtrooper
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
{
Application.Run(serviceProvider.GetRequiredService<FormMapWithSetAirplane>());
}
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddSingleton<FormMapWithSetAirplane>()
.AddLogging(option =>
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(path: "appSetting.json", optional: false, reloadOnChange: true)
.Build();
var logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.CreateLogger();
option.SetMinimumLevel(LogLevel.Information);
option.AddSerilog(logger);
});
}
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("Stormtrooper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Stormtrooper")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("d87dff83-0536-4e02-bf47-7742ac403580")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,70 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программным средством.
// Версия среды выполнения: 4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
// код создан повторно.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Stormtrooper.Properties
{
/// <summary>
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
/// </summary>
// Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
// класс с помощью таких средств, как ResGen или Visual Studio.
// Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
// с параметром /str или заново постройте свой VS-проект.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.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 ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Stormtrooper.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;
}
}
}
}

View File

@ -1,117 +0,0 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,29 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Stormtrooper.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal class SetAirplaneGeneric<T>
where T : class
{
/// <summary>
/// List объектов, которые храним
/// </summary>
private readonly List<T> _places;
/// <summary>
/// Количество объектов в массиве
/// </summary>
public int Count => _places.Count;
private readonly int _maxCount;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="count"></param>
public SetAirplaneGeneric(int count)
{
_places = new List<T>();
_maxCount = count;
}
/// <summary>
/// Добавление объекта в набор
/// </summary>
/// <param name="airplane">Добавляемый самолёт</param>
/// <returns></returns>
public int Insert(T airplane)
{
if (Count >= _maxCount)
throw new StorageOverflowException(_maxCount);
Insert(airplane, 0);
return 0;
}
/// <summary>
/// Добавление объекта в набор на конкретную позицию
/// </summary>
/// <param name="airplane">Добавляемый самолёт</param>
/// <param name="position">Позиция</param>
/// <returns></returns>
public int Insert(T airplane, int position)
{
if (position < 0 || position >= _maxCount - 1)
throw new StorageOverflowException(_maxCount);
_places.Insert(position, airplane);
return position;
}
/// <summary>
/// Удаление объекта из набора с конкретной позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public T Remove(int position)
{
if (Count == 0 || position < 0 || position >= _maxCount)
throw new AirplaneNotFoundException(position);
T air = _places[position];
_places.RemoveAt(position);
return air;
}
/// <summary>
/// Получение объекта из набора по позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public T this[int position]
{
get
{
// Проверка позиции
if (position < 0 || position >= Count)
return null;
return _places[position];
}
set
{
// Проверка позиции
if (position < 0 || position >= Count)
return;
// Вставка по позиции
_places[position] = value;
}
}
public IEnumerable<T> GetAirs()
{
foreach (var air in _places)
{
if (air != null)
{
yield return air;
}
else
{
yield break;
}
}
}
}
}

View File

@ -0,0 +1,52 @@
using Stormtrooper;
namespace Strormtrooper
{
/// <summary>
/// Простая реализация абсрактного класса AbstractMap
/// </summary>
internal class SimpleMap : AbstractMap
{
/// <summary>
/// Цвет участка закрытого
/// </summary>
private readonly Brush barrierColor = new SolidBrush(Color.Black);
/// <summary>
/// Цвет участка открытого
/// </summary>
private readonly Brush roadColor = new SolidBrush(Color.Gray);
protected override void DrawBarrierPart(Graphics g, int i, int j)
{
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, (i+1) * _size_x, (j+1) * _size_y);
}
protected override void DrawRoadPart(Graphics g, int i, int j)
{
g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y);
}
protected override void GenerateMap()
{
_map = new int[100, 100];
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
int counter = 0;
for (int i = 0; i < _map.GetLength(0); ++i)
{
for (int j = 0; j < _map.GetLength(1); ++j)
{
_map[i, j] = _freeRoad;
}
}
while (counter < 100)
{
int x = _random.Next(0, 100);
int y = _random.Next(0, 100);
if (_map[x, y] == _freeRoad)
{
_map[x, y] = _barrier;
counter++;
}
}
}
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
[Serializable]
internal class StorageOverflowException : ApplicationException
{
public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: {count}") { }
public StorageOverflowException() : base() { }
public StorageOverflowException(string message) : base(message) { }
public StorageOverflowException(string message, Exception exception) : base(message, exception) { }
protected StorageOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}
}

View File

@ -1,86 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D87DFF83-0536-4E02-BF47-7742AC403580}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Stormtrooper</RootNamespace>
<AssemblyName>Stormtrooper</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<None Remove="appSetting.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="Direction.cs" />
<Compile Include="DrawningMilitaryAirplane.cs" />
<Compile Include="EntityMilitaryAirplane.cs" />
<Compile Include="MainForm.cs">
<EmbeddedResource Include="appSetting.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="FormMap.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
</Project>

View File

@ -0,0 +1,20 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Information",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "log_.log",
"rollingInterval": "Day",
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "Stormtrooper"
}
}
}