Merge pull request 'Lisov N.A. Lab_work2' (#2) from LabWork02 into LabWork01
Reviewed-on: http://student.git.athene.tech/1yuee/PIbd-23_Lisov_N.A._AirFighter._Base/pulls/2
This commit is contained in:
commit
68ba51cf80
221
AirFighter/AbstractMap.cs
Normal file
221
AirFighter/AbstractMap.cs
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal abstract class AbstractMap
|
||||||
|
{
|
||||||
|
private IDrawingObject _drawingObject = 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, IDrawingObject drawingObject)
|
||||||
|
{
|
||||||
|
_width = width;
|
||||||
|
_height = height;
|
||||||
|
_drawingObject = drawingObject;
|
||||||
|
GenerateMap();
|
||||||
|
|
||||||
|
while (!SetObjectOnMap())
|
||||||
|
{
|
||||||
|
GenerateMap();
|
||||||
|
}
|
||||||
|
return DrawMapWithObject();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap MoveObject(Direction direction)
|
||||||
|
{
|
||||||
|
int CollisionFlag = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Size objSize1 = new Size(100,100);
|
||||||
|
|
||||||
|
//COLLISION CHECK
|
||||||
|
if (direction == Direction.Up)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < _map.GetLength(0); i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _map.GetLength(1); j++)
|
||||||
|
{
|
||||||
|
if (_map[i, j] == _barrier)
|
||||||
|
{
|
||||||
|
Point LeftTop = new Point((int)_drawingObject.GetCurrentPosition().Left, (int)(_drawingObject.GetCurrentPosition().Top - _drawingObject.Step));
|
||||||
|
Rectangle objectRect = new Rectangle(LeftTop, objSize1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle rectBarrier = new Rectangle((int)(i * _size_x), (int)(j * _size_y), (int)_size_x, (int)_size_y);
|
||||||
|
|
||||||
|
if (objectRect.IntersectsWith(rectBarrier))
|
||||||
|
{
|
||||||
|
CollisionFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (direction == Direction.Down)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _map.GetLength(0); i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _map.GetLength(1); j++)
|
||||||
|
{
|
||||||
|
if (_map[i, j] == _barrier)
|
||||||
|
{
|
||||||
|
Point LeftTop = new Point((int)_drawingObject.GetCurrentPosition().Left, (int)(_drawingObject.GetCurrentPosition().Top + _drawingObject.Step));
|
||||||
|
Rectangle objectRect = new Rectangle(LeftTop, objSize1);
|
||||||
|
|
||||||
|
Rectangle rectBarrier = new Rectangle((int)(i * _size_x), (int)(j * _size_y),(int) _size_x,(int) _size_y);
|
||||||
|
|
||||||
|
if (objectRect.IntersectsWith(rectBarrier))
|
||||||
|
{
|
||||||
|
CollisionFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (direction == Direction.Left)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _map.GetLength(0); i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _map.GetLength(1); j++)
|
||||||
|
{
|
||||||
|
if (_map[i, j] == _barrier)
|
||||||
|
{
|
||||||
|
|
||||||
|
Point LeftTop = new Point((int)(_drawingObject.GetCurrentPosition().Left - _drawingObject.Step), (int)_drawingObject.GetCurrentPosition().Top);
|
||||||
|
Rectangle objectRect = new Rectangle(LeftTop, objSize1);
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle rectBarrier = new Rectangle((int)(i * _size_x), (int)(j * _size_y), (int)_size_x, (int)_size_y);
|
||||||
|
|
||||||
|
if (objectRect.IntersectsWith(rectBarrier))
|
||||||
|
{
|
||||||
|
CollisionFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (direction == Direction.Right)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _map.GetLength(0); i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _map.GetLength(1); j++)
|
||||||
|
{
|
||||||
|
if (_map[i, j] == _barrier)
|
||||||
|
{
|
||||||
|
Point LeftTop = new Point((int)(_drawingObject.GetCurrentPosition().Left + _drawingObject.Step), (int)_drawingObject.GetCurrentPosition().Top);
|
||||||
|
Rectangle objectRect = new Rectangle(LeftTop, objSize1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle rectBarrier = new Rectangle((int)(i * _size_x), (int)(j * _size_y), (int)_size_x, (int)_size_y);
|
||||||
|
|
||||||
|
|
||||||
|
if (objectRect.IntersectsWith(rectBarrier))
|
||||||
|
{
|
||||||
|
CollisionFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollisionFlag != 1)
|
||||||
|
{
|
||||||
|
_drawingObject.MoveObject(direction);
|
||||||
|
_drawingObject.DoSomething();
|
||||||
|
}
|
||||||
|
return DrawMapWithObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool SetObjectOnMap()
|
||||||
|
{
|
||||||
|
if (_drawingObject == null || _map == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int x = _random.Next(0, 10);
|
||||||
|
int y = _random.Next(0,10);
|
||||||
|
_drawingObject.SetObject(x, y, _width, _height);
|
||||||
|
|
||||||
|
Rectangle rectObject = new Rectangle(x, y, 100, 100);
|
||||||
|
|
||||||
|
for (int i = 0; i < _map.GetLength(0); i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _map.GetLength(1); j++)
|
||||||
|
{
|
||||||
|
if (_map[i, j] == _barrier)
|
||||||
|
{
|
||||||
|
Rectangle rectBarrier = new Rectangle((int)(i * _size_x), (int)(j * _size_y), (int)_size_x, (int)_size_y);
|
||||||
|
if (rectObject.IntersectsWith(rectBarrier))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap DrawMapWithObject()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(_width, _height);
|
||||||
|
if (_drawingObject == 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_drawingObject.DrawingObject(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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
13
AirFighter/AirFighterForm.Designer.cs
generated
13
AirFighter/AirFighterForm.Designer.cs
generated
@ -38,6 +38,7 @@
|
|||||||
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.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCreateModification = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).BeginInit();
|
||||||
this.statusStripAircraft.SuspendLayout();
|
this.statusStripAircraft.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -141,11 +142,22 @@
|
|||||||
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);
|
||||||
//
|
//
|
||||||
|
// buttonCreateModification
|
||||||
|
//
|
||||||
|
this.buttonCreateModification.Location = new System.Drawing.Point(103, 389);
|
||||||
|
this.buttonCreateModification.Name = "buttonCreateModification";
|
||||||
|
this.buttonCreateModification.Size = new System.Drawing.Size(110, 23);
|
||||||
|
this.buttonCreateModification.TabIndex = 7;
|
||||||
|
this.buttonCreateModification.Text = "Modification";
|
||||||
|
this.buttonCreateModification.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreateModification.Click += new System.EventHandler(this.buttonCreateModification_Click);
|
||||||
|
//
|
||||||
// AirFighterForm
|
// AirFighterForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
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(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.buttonCreateModification);
|
||||||
this.Controls.Add(this.buttonDown);
|
this.Controls.Add(this.buttonDown);
|
||||||
this.Controls.Add(this.buttonRight);
|
this.Controls.Add(this.buttonRight);
|
||||||
this.Controls.Add(this.buttonLeft);
|
this.Controls.Add(this.buttonLeft);
|
||||||
@ -175,5 +187,6 @@
|
|||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
|
private Button buttonCreateModification;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,16 +18,23 @@ namespace AirFighter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void SetData()
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
_aircraft = new DrawingAircraft();
|
|
||||||
_aircraft.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|
||||||
_aircraft.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
_aircraft.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
toolStripStatusSpeed.Text = $"Speed: {_aircraft.Plane.Speed}";
|
toolStripStatusSpeed.Text = $"Speed: {_aircraft.Plane.Speed}";
|
||||||
toolStripStatusWeight.Text = $"Weight: {_aircraft.Plane.Weight}";
|
toolStripStatusWeight.Text = $"Weight: {_aircraft.Plane.Weight}";
|
||||||
toolStripStatusBodyColor.Text = $"BodyColor: {_aircraft.Plane.BodyColor.Name}";
|
toolStripStatusBodyColor.Text = $"BodyColor: {_aircraft.Plane.BodyColor.Name}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
_aircraft = new DrawingAircraft(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,5 +72,17 @@ namespace AirFighter
|
|||||||
_aircraft?.ChangeBorders(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
_aircraft?.ChangeBorders(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonCreateModification_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
_aircraft = new DrawingMilitaryAircraft(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||||
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||||
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||||
|
Convert.ToBoolean(rnd.Next(0,2)),Convert.ToBoolean(rnd.Next(0,2)));
|
||||||
|
|
||||||
|
SetData();
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ namespace AirFighter
|
|||||||
{
|
{
|
||||||
internal enum Direction
|
internal enum Direction
|
||||||
{
|
{
|
||||||
|
None = 0,
|
||||||
Up =1,
|
Up =1,
|
||||||
Down = 2,
|
Down = 2,
|
||||||
Left = 3,
|
Left = 3,
|
||||||
|
@ -11,22 +11,28 @@ namespace AirFighter
|
|||||||
{
|
{
|
||||||
internal class DrawingAircraft
|
internal class DrawingAircraft
|
||||||
{
|
{
|
||||||
public EntityAircraft Plane { get; private set; }
|
public EntityAircraft Plane { get; protected set; }
|
||||||
|
|
||||||
private float _startPosX;
|
protected float _startPosX;
|
||||||
|
|
||||||
private float _startPosY;
|
protected float _startPosY;
|
||||||
|
|
||||||
private int? _pictureWidth = null;
|
private int? _pictureWidth = null;
|
||||||
private int? _pictureHeight = null;
|
private int? _pictureHeight = null;
|
||||||
|
|
||||||
protected readonly int _aircraftWidth = 100;
|
private readonly int _aircraftWidth = 100;
|
||||||
protected readonly int _aircraftHeight = 100;
|
private readonly int _aircraftHeight = 100;
|
||||||
|
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public DrawingAircraft(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Plane = new EntityAircraft();
|
Plane = new EntityAircraft(speed, weight, bodyColor);
|
||||||
Plane.Init(speed, weight, bodyColor);
|
}
|
||||||
|
|
||||||
|
protected DrawingAircraft(int speed, float weight, Color bodyColor, int aircraftWidth, int aircraftHeight) : this(speed, weight,bodyColor)
|
||||||
|
{
|
||||||
|
|
||||||
|
_aircraftHeight = aircraftHeight;
|
||||||
|
_aircraftWidth = aircraftWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPosition(int x, int y, int width, int height)
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
@ -127,7 +133,7 @@ namespace AirFighter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawTransport(Graphics g)
|
public virtual void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||||
{
|
{
|
||||||
@ -235,5 +241,10 @@ namespace AirFighter
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public (float Left, float Top, float Right, float Bottom) GetCurrentPosition()
|
||||||
|
{
|
||||||
|
return (_startPosX, _startPosY, _startPosX + _aircraftWidth - 1, _startPosY + _aircraftHeight - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
98
AirFighter/DrawingMilitaryAircraft.cs
Normal file
98
AirFighter/DrawingMilitaryAircraft.cs
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal class DrawingMilitaryAircraft : DrawingAircraft
|
||||||
|
{
|
||||||
|
public DrawingMilitaryAircraft(int speed, float weight, Color bodyColor, Color extraColor, bool rockets, bool extraWings) : base(speed,weight,bodyColor, 100, 100)
|
||||||
|
{
|
||||||
|
Plane = new EntityMilitaryAircraft(speed, weight, bodyColor, extraColor, rockets, extraWings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (Plane is not EntityMilitaryAircraft militaryAircraft)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
Brush extraBrush = new SolidBrush(militaryAircraft.ExtraColor);
|
||||||
|
|
||||||
|
base.DrawTransport(g);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (militaryAircraft.ExtraWings)
|
||||||
|
{
|
||||||
|
GraphicsPath pathExtraWing1 = new GraphicsPath();
|
||||||
|
|
||||||
|
Point point1W1 = new Point((int)(_startPosX + 30), (int)(_startPosY + 45));
|
||||||
|
Point point2W1 = new Point(point1W1.X , point1W1.Y - 40);
|
||||||
|
Point point3W1 = new Point(point2W1.X + 10,point1W1.Y);
|
||||||
|
|
||||||
|
Point[] pointsExtraWing1 = new Point[] { point1W1,point2W1,point3W1};
|
||||||
|
|
||||||
|
pathExtraWing1.AddLines(pointsExtraWing1);
|
||||||
|
g.DrawPath(pen, pathExtraWing1);
|
||||||
|
g.FillPath(extraBrush, pathExtraWing1);
|
||||||
|
|
||||||
|
GraphicsPath pathExtraWing2 = new GraphicsPath();
|
||||||
|
|
||||||
|
Point point1W2 = new Point((int)(_startPosX + 30),(int)(_startPosY + 60));
|
||||||
|
Point point2W2 = new Point(point1W2.X , point1W2.Y + 40);
|
||||||
|
Point point3W3 = new Point(point2W2.X + 10,point1W2.Y);
|
||||||
|
|
||||||
|
Point[] pointsExtraWing2 = new Point[] {point1W2,point2W2,point3W3};
|
||||||
|
pathExtraWing2.AddLines(pointsExtraWing2);
|
||||||
|
g.DrawPath(pen, pathExtraWing2);
|
||||||
|
g.FillPath(extraBrush, pathExtraWing2);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (militaryAircraft.Rockets)
|
||||||
|
{
|
||||||
|
g.DrawRectangle(pen, _startPosX + 50, _startPosY + 30,17,4);
|
||||||
|
|
||||||
|
GraphicsPath pathRocketHead1 = new GraphicsPath();
|
||||||
|
|
||||||
|
Point point1R1 = new Point((int)(_startPosX + 50),(int)(_startPosY + 30));
|
||||||
|
Point point2R1 = new Point(point1R1.X - 5,point1R1.Y + 2);
|
||||||
|
Point point3R1 = new Point(point1R1.X , point1R1.Y + 4);
|
||||||
|
|
||||||
|
Point[] pointsExtraRocketHead1 = new Point[] { point1R1, point2R1, point3R1 };
|
||||||
|
pathRocketHead1.AddLines(pointsExtraRocketHead1);
|
||||||
|
g.DrawPath(pen, pathRocketHead1);
|
||||||
|
g.FillPath(extraBrush, pathRocketHead1);
|
||||||
|
|
||||||
|
|
||||||
|
g.DrawRectangle(pen, _startPosX + 50, _startPosY + 70, 17, 4);
|
||||||
|
|
||||||
|
GraphicsPath pathRocketHead2 = new GraphicsPath();
|
||||||
|
|
||||||
|
Point point1R2 = new Point((int)(_startPosX + 50),(int)(_startPosY + 70));
|
||||||
|
Point point2R2 = new Point(point1R2.X - 5,point1R2.Y + 2);
|
||||||
|
Point point3R2 = new Point(point1R2.X, point1R2.Y + 4);
|
||||||
|
|
||||||
|
Point[] pointsExtraRocketHead2 = new Point[] { point1R2, point2R2, point3R2 };
|
||||||
|
pathRocketHead2.AddLines(pointsExtraRocketHead2);
|
||||||
|
g.DrawPath(pen, pathRocketHead2);
|
||||||
|
g.FillPath(extraBrush, pathRocketHead2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
48
AirFighter/DrawingObjectAircraft.cs
Normal file
48
AirFighter/DrawingObjectAircraft.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal class DrawingObjectAircraft : IDrawingObject
|
||||||
|
{
|
||||||
|
private DrawingAircraft _aircraft = null;
|
||||||
|
|
||||||
|
public DrawingObjectAircraft(DrawingAircraft aircraft)
|
||||||
|
{
|
||||||
|
_aircraft = aircraft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float Step => _aircraft.Plane?.Step ?? 0;
|
||||||
|
|
||||||
|
public (float Left, float Top, float Right, float Bottom) GetCurrentPosition()
|
||||||
|
{
|
||||||
|
return _aircraft?.GetCurrentPosition() ?? default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveObject(Direction direction)
|
||||||
|
{
|
||||||
|
_aircraft.MoveTransport(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetObject(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
_aircraft.SetPosition(x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IDrawingObject.DrawingObject(Graphics g)
|
||||||
|
{
|
||||||
|
_aircraft.DrawTransport(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void DoSomething()
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
int x = rnd.Next(0, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -30,7 +30,7 @@ namespace AirFighter
|
|||||||
public float Step => Speed * 100 / Weight;
|
public float Step => Speed * 100 / Weight;
|
||||||
|
|
||||||
|
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public EntityAircraft(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Speed = speed;
|
Speed = speed;
|
||||||
Weight = weight;
|
Weight = weight;
|
||||||
|
26
AirFighter/EntityMilitaryAircraft.cs
Normal file
26
AirFighter/EntityMilitaryAircraft.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal class EntityMilitaryAircraft : EntityAircraft
|
||||||
|
{
|
||||||
|
public Color ExtraColor { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
public bool Rockets { get; private set; }
|
||||||
|
|
||||||
|
public bool ExtraWings { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
public EntityMilitaryAircraft(int speed, float weight, Color bodyColor, Color extraColor, bool rockets, bool extraWings) : base(speed, weight, bodyColor)
|
||||||
|
{
|
||||||
|
ExtraColor = extraColor;
|
||||||
|
Rockets = rockets;
|
||||||
|
ExtraWings = extraWings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
207
AirFighter/FormMap.Designer.cs
generated
Normal file
207
AirFighter/FormMap.Designer.cs
generated
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
partial class FormMap
|
||||||
|
{
|
||||||
|
/// <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.pictureBoxAirFighter = new System.Windows.Forms.PictureBox();
|
||||||
|
this.statusStripAircraft = new System.Windows.Forms.StatusStrip();
|
||||||
|
this.toolStripStatusSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
this.toolStripStatusWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
this.toolStripStatusBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
this.buttonCreate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCreateModification = new System.Windows.Forms.Button();
|
||||||
|
this.comboBoxMapSelection = new System.Windows.Forms.ComboBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).BeginInit();
|
||||||
|
this.statusStripAircraft.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureBoxAirFighter
|
||||||
|
//
|
||||||
|
this.pictureBoxAirFighter.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pictureBoxAirFighter.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.pictureBoxAirFighter.Name = "pictureBoxAirFighter";
|
||||||
|
this.pictureBoxAirFighter.Size = new System.Drawing.Size(800, 428);
|
||||||
|
this.pictureBoxAirFighter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
|
this.pictureBoxAirFighter.TabIndex = 0;
|
||||||
|
this.pictureBoxAirFighter.TabStop = false;
|
||||||
|
//
|
||||||
|
// statusStripAircraft
|
||||||
|
//
|
||||||
|
this.statusStripAircraft.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.toolStripStatusSpeed,
|
||||||
|
this.toolStripStatusWeight,
|
||||||
|
this.toolStripStatusBodyColor});
|
||||||
|
this.statusStripAircraft.Location = new System.Drawing.Point(0, 428);
|
||||||
|
this.statusStripAircraft.Name = "statusStripAircraft";
|
||||||
|
this.statusStripAircraft.Size = new System.Drawing.Size(800, 22);
|
||||||
|
this.statusStripAircraft.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// toolStripStatusSpeed
|
||||||
|
//
|
||||||
|
this.toolStripStatusSpeed.Name = "toolStripStatusSpeed";
|
||||||
|
this.toolStripStatusSpeed.Size = new System.Drawing.Size(42, 17);
|
||||||
|
this.toolStripStatusSpeed.Text = "Speed:";
|
||||||
|
//
|
||||||
|
// toolStripStatusWeight
|
||||||
|
//
|
||||||
|
this.toolStripStatusWeight.Name = "toolStripStatusWeight";
|
||||||
|
this.toolStripStatusWeight.Size = new System.Drawing.Size(48, 17);
|
||||||
|
this.toolStripStatusWeight.Text = "Weight:";
|
||||||
|
//
|
||||||
|
// toolStripStatusBodyColor
|
||||||
|
//
|
||||||
|
this.toolStripStatusBodyColor.Name = "toolStripStatusBodyColor";
|
||||||
|
this.toolStripStatusBodyColor.Size = new System.Drawing.Size(66, 17);
|
||||||
|
this.toolStripStatusBodyColor.Text = "BodyColor:";
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.buttonCreate.Location = new System.Drawing.Point(12, 389);
|
||||||
|
this.buttonCreate.Name = "buttonCreate";
|
||||||
|
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCreate.TabIndex = 2;
|
||||||
|
this.buttonCreate.Text = "Create";
|
||||||
|
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonUp.BackgroundImage = global::AirFighter.Properties.Resources.ArrowUp;
|
||||||
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonUp.Location = new System.Drawing.Point(702, 346);
|
||||||
|
this.buttonUp.Name = "buttonUp";
|
||||||
|
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonUp.TabIndex = 3;
|
||||||
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUp.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.BackgroundImage = global::AirFighter.Properties.Resources.ArrowLeft;
|
||||||
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonLeft.Location = new System.Drawing.Point(666, 382);
|
||||||
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
|
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonLeft.TabIndex = 4;
|
||||||
|
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.BackgroundImage = global::AirFighter.Properties.Resources.ArrowRight;
|
||||||
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonRight.Location = new System.Drawing.Point(738, 382);
|
||||||
|
this.buttonRight.Name = "buttonRight";
|
||||||
|
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonRight.TabIndex = 5;
|
||||||
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRight.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.BackgroundImage = global::AirFighter.Properties.Resources.ArrowDown;
|
||||||
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonDown.Location = new System.Drawing.Point(702, 382);
|
||||||
|
this.buttonDown.Name = "buttonDown";
|
||||||
|
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonDown.TabIndex = 6;
|
||||||
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonCreateModification
|
||||||
|
//
|
||||||
|
this.buttonCreateModification.Location = new System.Drawing.Point(103, 389);
|
||||||
|
this.buttonCreateModification.Name = "buttonCreateModification";
|
||||||
|
this.buttonCreateModification.Size = new System.Drawing.Size(110, 23);
|
||||||
|
this.buttonCreateModification.TabIndex = 7;
|
||||||
|
this.buttonCreateModification.Text = "Modification";
|
||||||
|
this.buttonCreateModification.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreateModification.Click += new System.EventHandler(this.buttonCreateModification_Click);
|
||||||
|
//
|
||||||
|
// comboBoxMapSelection
|
||||||
|
//
|
||||||
|
this.comboBoxMapSelection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxMapSelection.FormattingEnabled = true;
|
||||||
|
this.comboBoxMapSelection.Items.AddRange(new object[] {
|
||||||
|
"1. Simple map",
|
||||||
|
"2. NightSky map"});
|
||||||
|
this.comboBoxMapSelection.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.comboBoxMapSelection.Name = "comboBoxMapSelection";
|
||||||
|
this.comboBoxMapSelection.Size = new System.Drawing.Size(121, 23);
|
||||||
|
this.comboBoxMapSelection.TabIndex = 8;
|
||||||
|
this.comboBoxMapSelection.SelectedIndexChanged += new System.EventHandler(this.comboBoxMapSelection_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// FormMap
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.comboBoxMapSelection);
|
||||||
|
this.Controls.Add(this.buttonCreateModification);
|
||||||
|
this.Controls.Add(this.buttonDown);
|
||||||
|
this.Controls.Add(this.buttonRight);
|
||||||
|
this.Controls.Add(this.buttonLeft);
|
||||||
|
this.Controls.Add(this.buttonUp);
|
||||||
|
this.Controls.Add(this.buttonCreate);
|
||||||
|
this.Controls.Add(this.pictureBoxAirFighter);
|
||||||
|
this.Controls.Add(this.statusStripAircraft);
|
||||||
|
this.Name = "FormMap";
|
||||||
|
this.Text = "Map";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).EndInit();
|
||||||
|
this.statusStripAircraft.ResumeLayout(false);
|
||||||
|
this.statusStripAircraft.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private PictureBox pictureBoxAirFighter;
|
||||||
|
private StatusStrip statusStripAircraft;
|
||||||
|
private ToolStripStatusLabel toolStripStatusSpeed;
|
||||||
|
private ToolStripStatusLabel toolStripStatusWeight;
|
||||||
|
private ToolStripStatusLabel toolStripStatusBodyColor;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonCreateModification;
|
||||||
|
private ComboBox comboBoxMapSelection;
|
||||||
|
}
|
||||||
|
}
|
102
AirFighter/FormMap.cs
Normal file
102
AirFighter/FormMap.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
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 AirFighter
|
||||||
|
{
|
||||||
|
public partial class FormMap : Form
|
||||||
|
{
|
||||||
|
private AbstractMap _abstractMap;
|
||||||
|
public FormMap()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_abstractMap = new SimpleMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetData(DrawingAircraft plane)
|
||||||
|
{
|
||||||
|
toolStripStatusSpeed.Text = $"Speed: {plane.Plane.Speed}";
|
||||||
|
toolStripStatusWeight.Text = $"Weight: {plane.Plane.Weight}";
|
||||||
|
toolStripStatusBodyColor.Text = $"BodyColor: {plane.Plane.BodyColor.Name}";
|
||||||
|
pictureBoxAirFighter.Image = _abstractMap.CreateMap(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height, new DrawingObjectAircraft(plane) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
var plane = new DrawingAircraft(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
|
SetData(plane);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
pictureBoxAirFighter.Image = _abstractMap?.MoveObject(dir);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void buttonCreateModification_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
var plane = new DrawingMilitaryAircraft(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||||
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||||
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||||
|
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
|
|
||||||
|
SetData(plane);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxMapSelection_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
switch (comboBoxMapSelection.Text)
|
||||||
|
{
|
||||||
|
case "1. Simple map":
|
||||||
|
{
|
||||||
|
_abstractMap = new SimpleMap();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "2. NightSky map":
|
||||||
|
{
|
||||||
|
_abstractMap = new NightSkyMap();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
63
AirFighter/FormMap.resx
Normal file
63
AirFighter/FormMap.resx
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<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="statusStripAircraft.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
23
AirFighter/IDrawingObject.cs
Normal file
23
AirFighter/IDrawingObject.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal interface IDrawingObject
|
||||||
|
{
|
||||||
|
public float Step { get; }
|
||||||
|
void SetObject(int x, int y, int width, int height);
|
||||||
|
|
||||||
|
void MoveObject(Direction direction);
|
||||||
|
|
||||||
|
void DrawingObject(Graphics g);
|
||||||
|
|
||||||
|
void DoSomething();
|
||||||
|
|
||||||
|
(float Left, float Top, float Right, float Bottom) GetCurrentPosition();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
60
AirFighter/NightSkyMap.cs
Normal file
60
AirFighter/NightSkyMap.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal class NightSkyMap : AbstractMap
|
||||||
|
{
|
||||||
|
Brush ThundercloudColor = new SolidBrush(Color.FromArgb(0, 0, 139));
|
||||||
|
|
||||||
|
Brush NightSkyColor = new SolidBrush(Color.Black);
|
||||||
|
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
|
g.FillRectangle(ThundercloudColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
|
g.FillRectangle(NightSkyColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
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 < 20)
|
||||||
|
{
|
||||||
|
int x = _random.Next(10,90);
|
||||||
|
int y = _random.Next(10,90);
|
||||||
|
|
||||||
|
_map[x, y] = _barrier;
|
||||||
|
_map[x-1,y] = _barrier;
|
||||||
|
_map[x + 1, y] = _barrier;
|
||||||
|
_map[x,y - 1] = _barrier;
|
||||||
|
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,7 +11,7 @@ namespace AirFighter
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new AirFighterForm());
|
Application.Run(new FormMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
50
AirFighter/SimpleMap.cs
Normal file
50
AirFighter/SimpleMap.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal class SimpleMap : AbstractMap
|
||||||
|
{
|
||||||
|
Brush barrierColor = new SolidBrush(Color.Black);
|
||||||
|
|
||||||
|
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 * (_size_x + 1), j * (_size_y + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
|
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
if (_random.Next(0, 90) == 5)
|
||||||
|
{
|
||||||
|
_map[i, j] = _barrier;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_map[i, j] = _freeRoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user