Merge pull request 'Pyatakov K.M. LabWork2' (#3) from LabWork2 into LabWork1

Reviewed-on: http://student.git.athene.tech/ker73rus/PIbd-21_Pyatakov_KM_Stormtrooper_Base/pulls/3
This commit is contained in:
Евгений Эгов 2022-11-07 09:44:07 +04:00
commit 59b123cca2
26 changed files with 947 additions and 448 deletions

View File

@ -1,9 +1,9 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 17
VisualStudioVersion = 16.0.32002.261 VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 10.0.40219.1 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D87DFF83-0536-4E02-BF47-7742AC403580}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8AA57368-9B39-4D80-8E57-A47747850BC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D87DFF83-0536-4E02-BF47-7742AC403580}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AA57368-9B39-4D80-8E57-A47747850BC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D87DFF83-0536-4E02-BF47-7742AC403580}.Release|Any CPU.ActiveCfg = Release|Any CPU {8AA57368-9B39-4D80-8E57-A47747850BC6}.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}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D4E232C0-9FA0-49BD-B4D6-D779415C9348} SolutionGuid = {83CCA316-14CA-4D9C-BC16-70A84A6A05A1}
EndGlobalSection EndGlobalSection
EndGlobal 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 Cars
{
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++)
{
for (int j = top; j < bottom; 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

@ -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 Cars;
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 Cars;
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

@ -9,6 +9,7 @@ namespace Stormtrooper
internal enum Direction internal enum Direction
{ {
None,
Up, Up,
Down, Down,
Left, Left,

View File

@ -12,15 +12,15 @@ namespace Stormtrooper
/// <summary> /// <summary>
/// Класс-сущность /// Класс-сущность
/// </summary> /// </summary>
public EntityMilitaryAirplane Airplane { get; private set; } public EntityMilitaryAirplane Airplane { get; protected set; }
/// <summary> /// <summary>
/// Левая координата отрисовки автомобиля /// Левая координата отрисовки автомобиля
/// </summary> /// </summary>
private float _startPosX; protected float _startPosX;
/// <summary> /// <summary>
/// Верхняя кооридната отрисовки автомобиля /// Верхняя кооридната отрисовки автомобиля
/// </summary> /// </summary>
private float _startPosY; protected float _startPosY;
/// <summary> /// <summary>
/// Ширина окна отрисовки /// Ширина окна отрисовки
/// </summary> /// </summary>
@ -32,15 +32,16 @@ namespace Stormtrooper
/// <summary> /// <summary>
/// Ширина отрисовки самолёта /// Ширина отрисовки самолёта
/// </summary> /// </summary>
private readonly int _airplaneWidth = 80; protected readonly int _airplaneWidth;
/// <summary> /// <summary>
/// Высота отрисовки самолёта /// Высота отрисовки самолёта
/// </summary> /// </summary>
private readonly int _airplaneHeight = 100; protected readonly int _airplaneHeight;
public void Init(int speed, int weight) public DrawningMilitaryAirplane(int speed, int weight, int wight = 80, int height = 100)
{ {
Airplane = new EntityMilitaryAirplane(); Airplane = new EntityMilitaryAirplane(speed, weight);
Airplane.Init(speed, weight); _airplaneWidth = wight;
_airplaneHeight = height;
} }
public void SetPosition(int x, int y, int width, int 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 if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue) || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
@ -109,23 +110,24 @@ namespace Stormtrooper
Pen pen = new Pen(Color.Black); Pen pen = new Pen(Color.Black);
Brush brush = new SolidBrush(Color.Black); Brush brush = new SolidBrush(Color.DarkGreen);
g.FillPolygon(brush, new PointF[3] {new PointF(_startPosX, _startPosY + _airplaneHeight / 2), 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.45f),
new PointF(_startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.55f)}); new PointF(_startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.55f)});
g.DrawPolygon(pen, new PointF[6] { new PointF(_startPosX + _airplaneWidth*0.45f,_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.50f,_startPosY),
new PointF(_startPosX + _airplaneWidth * 0.60f, _startPosY+_airplaneHeight*0.45f) , 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.60f, _startPosY+ _airplaneHeight*0.55f),
new PointF(_startPosX + _airplaneWidth * 0.50f,_startPosY + _airplaneHeight), new PointF(_startPosX + _airplaneWidth * 0.50f,_startPosY + _airplaneHeight),
new PointF(_startPosX + _airplaneWidth * 0.45f,_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, _startPosY + _airplaneHeight*0.20f),
new PointF(_startPosX + _airplaneWidth*0.85f,_startPosY+_airplaneHeight*0.35f), new PointF(_startPosX + _airplaneWidth*0.85f,_startPosY+_airplaneHeight*0.35f),
new PointF(_startPosX + _airplaneWidth * 0.85f,_startPosY + _airplaneHeight*0.65f), new PointF(_startPosX + _airplaneWidth * 0.85f,_startPosY + _airplaneHeight*0.65f),
new PointF(_startPosX + _airplaneWidth, _startPosY + _airplaneHeight*0.80f) 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); g.DrawRectangle(pen, _startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.45f, _airplaneWidth * 0.9f, _airplaneHeight * 0.1f);
} }
public void ChangeBorders(int width, int height) public void ChangeBorders(int width, int height)
@ -147,5 +149,10 @@ namespace Stormtrooper
_startPosY = _pictureHeight.Value - _airplaneHeight; _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,40 @@
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 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);
}
}
}

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, int crew, Color advColor, bool rockets, bool boosters, bool radar) : base(speed, weight)
{
Airplane = new EntityStormtrooper(speed, weight,crew, 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

@ -14,7 +14,7 @@ namespace Stormtrooper
public float Step => Speed * 25 / Weight; public float Step => Speed * 25 / Weight;
public void Init(int speed, int weight, int crew = 10) public EntityMilitaryAirplane(int speed, int weight, int crew = 10)
{ {
Random random = new Random(); Random random = new Random();
Speed = speed <= 0 ? random.Next(10, 100) : speed; Speed = speed <= 0 ? random.Next(10, 100) : speed;

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;private set; }
/// <summary>
/// Наличие рокет
/// </summary>
public bool Rockets { get; private set; }
/// <summary>
/// Наличие ускорителей
/// </summary>
public bool Booster { get; private set; }
/// <summary>
/// Наличие радара
/// </summary>
public bool Radar { get; private set; }
public EntityStormtrooper(int speed, int weight, int crew, Color advColor, bool rockets, bool boosters, bool radar)
: base(speed, weight, crew)
{
Rockets = rockets;
Booster = boosters;
Radar = radar;
AdvColor = advColor;
}
}
}

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,89 @@
using Cars;
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);
_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}";
toolStripLabelCrew.Text = $"Экипаж: {_airplane.Airplane.Crew}";
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),random.Next(1,100),
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,40 @@
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();
}
}

View File

@ -39,6 +39,7 @@ namespace Stormtrooper
this.buttonDown = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button(); this.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button(); this.buttonRight = new System.Windows.Forms.Button();
this.buttonCreateMod = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit();
this.toolStripStatus.SuspendLayout(); this.toolStripStatus.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -49,7 +50,8 @@ namespace Stormtrooper
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBoxAirplane.BackColor = System.Drawing.Color.White; 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.Name = "pictureBoxAirplane";
this.pictureBoxAirplane.Size = new System.Drawing.Size(1127, 558); this.pictureBoxAirplane.Size = new System.Drawing.Size(1127, 558);
this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
@ -61,9 +63,10 @@ namespace Stormtrooper
// //
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 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.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.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.TabIndex = 1;
this.buttonCreate.Text = "Создать"; this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true; this.buttonCreate.UseVisualStyleBackColor = true;
@ -76,9 +79,9 @@ namespace Stormtrooper
this.toolStripLabelSpeed, this.toolStripLabelSpeed,
this.toolStripLabelWeight, this.toolStripLabelWeight,
this.toolStripLabelCrew}); 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.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.TabIndex = 2;
this.toolStripStatus.Text = "toolStrip1"; this.toolStripStatus.Text = "toolStrip1";
// //
@ -103,9 +106,10 @@ namespace Stormtrooper
// buttonUp // buttonUp
// //
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.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.TabIndex = 3;
this.buttonUp.UseVisualStyleBackColor = true; this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click); this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
@ -113,9 +117,10 @@ namespace Stormtrooper
// buttonDown // buttonDown
// //
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.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.TabIndex = 4;
this.buttonDown.UseVisualStyleBackColor = true; this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click); this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
@ -123,9 +128,10 @@ namespace Stormtrooper
// buttonLeft // buttonLeft
// //
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.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.TabIndex = 5;
this.buttonLeft.UseVisualStyleBackColor = true; this.buttonLeft.UseVisualStyleBackColor = true;
this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click); this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
@ -133,18 +139,30 @@ namespace Stormtrooper
// buttonRight // buttonRight
// //
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.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.TabIndex = 6;
this.buttonRight.UseVisualStyleBackColor = true; this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click); 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);
//
// MainForm // 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.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.buttonCreateMod);
this.Controls.Add(this.buttonRight); this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft); this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonDown); this.Controls.Add(this.buttonDown);
@ -152,6 +170,7 @@ namespace Stormtrooper
this.Controls.Add(this.toolStripStatus); this.Controls.Add(this.toolStripStatus);
this.Controls.Add(this.buttonCreate); this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxAirplane); this.Controls.Add(this.pictureBoxAirplane);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "MainForm"; this.Name = "MainForm";
this.Text = "Form1"; this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit();
@ -174,6 +193,7 @@ namespace Stormtrooper
private System.Windows.Forms.Button buttonDown; private System.Windows.Forms.Button buttonDown;
private System.Windows.Forms.Button buttonLeft; private System.Windows.Forms.Button buttonLeft;
private System.Windows.Forms.Button buttonRight; private System.Windows.Forms.Button buttonRight;
private Button buttonCreateMod;
} }
} }

View File

@ -29,12 +29,9 @@ namespace Stormtrooper
private void buttonCreate_Click(object sender, EventArgs e) private void buttonCreate_Click(object sender, EventArgs e)
{ {
Random random = new Random(); Random random = new Random();
_airplane = new DrawningMilitaryAirplane(); _airplane = new DrawningMilitaryAirplane(10, 50);
_airplane.Init(10, 50);
_airplane.SetPosition(random.Next(100,150), random.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height); _airplane.SetPosition(random.Next(100,150), random.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
toolStripLabelSpeed.Text = $"Скорость: {_airplane.Airplane.Speed}"; SetData();
toolStripLabelWeight.Text = $"Вес: {_airplane.Airplane.Weight}";
toolStripLabelCrew.Text = $"Экипаж: {_airplane.Airplane.Crew}";
Draw(); Draw();
} }
@ -65,5 +62,23 @@ namespace Stormtrooper
} }
Draw(); Draw();
} }
private void SetData()
{
toolStripLabelSpeed.Text = $"Скорость: {_airplane.Airplane.Speed}";
toolStripLabelWeight.Text = $"Вес: {_airplane.Airplane.Weight}";
toolStripLabelCrew.Text = $"Экипаж: {_airplane.Airplane.Crew}";
}
private void buttonCreateMod_Click(object sender, EventArgs e)
{
Random random = new Random();
_airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250),random.Next(1,100),
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();
Draw();
}
} }
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd: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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

@ -16,7 +16,7 @@ namespace Stormtrooper
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm()); Application.Run(new FormMap());
} }
} }
} }

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,50 @@
namespace Cars
{
/// <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

@ -1,86 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<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')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D87DFF83-0536-4E02-BF47-7742AC403580}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>Stormtrooper</RootNamespace> <TargetFramework>net6.0-windows</TargetFramework>
<AssemblyName>Stormtrooper</AssemblyName> <Nullable>enable</Nullable>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <UseWindowsForms>true</UseWindowsForms>
<FileAlignment>512</FileAlignment> <ImplicitUsings>enable</ImplicitUsings>
<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>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Compile Update="FormMap.cs">
<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" />
</ItemGroup>
<ItemGroup>
<Compile Include="Direction.cs" />
<Compile Include="DrawningMilitaryAirplane.cs" />
<Compile Include="EntityMilitaryAirplane.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </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>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>