Compare commits
7 Commits
c204aa9488
...
1de451c0e1
Author | SHA1 | Date | |
---|---|---|---|
1de451c0e1 | |||
b2870dd48f | |||
231751cad6 | |||
fd00315caa | |||
6e9d2caf06 | |||
0776eb1254 | |||
cbf0ed1e2f |
@ -8,4 +8,19 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
179
AirFighter/AirFighterForm.Designer.cs
generated
Normal file
179
AirFighter/AirFighterForm.Designer.cs
generated
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
partial class AirFighterForm
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
((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;
|
||||||
|
this.pictureBoxAirFighter.Resize += new System.EventHandler(this.pictureBoxAirFighter_Resize);
|
||||||
|
//
|
||||||
|
// 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);
|
||||||
|
//
|
||||||
|
// AirFighterForm
|
||||||
|
//
|
||||||
|
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.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 = "AirFighterForm";
|
||||||
|
this.Text = "AirFighter";
|
||||||
|
((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;
|
||||||
|
}
|
||||||
|
}
|
69
AirFighter/AirFighterForm.cs
Normal file
69
AirFighter/AirFighterForm.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
public partial class AirFighterForm : Form
|
||||||
|
{
|
||||||
|
private DrawingAircraft _aircraft;
|
||||||
|
|
||||||
|
public AirFighterForm()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Draw()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_aircraft?.DrawTransport(gr);
|
||||||
|
pictureBoxAirFighter.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
toolStripStatusSpeed.Text = $"Speed: {_aircraft.Plane.Speed}";
|
||||||
|
toolStripStatusWeight.Text = $"Weight: {_aircraft.Plane.Weight}";
|
||||||
|
toolStripStatusBodyColor.Text = $"BodyColor: {_aircraft.Plane.BodyColor.Name}";
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
{
|
||||||
|
_aircraft?.MoveTransport(Direction.Up);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "buttonDown":
|
||||||
|
{
|
||||||
|
_aircraft?.MoveTransport(Direction.Down);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "buttonLeft":
|
||||||
|
{
|
||||||
|
_aircraft?.MoveTransport(Direction.Left);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "buttonRight":
|
||||||
|
{
|
||||||
|
_aircraft?.MoveTransport(Direction.Right);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pictureBoxAirFighter_Resize(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_aircraft?.ChangeBorders(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
63
AirFighter/AirFighterForm.resx
Normal file
63
AirFighter/AirFighterForm.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>
|
20
AirFighter/Direction.cs
Normal file
20
AirFighter/Direction.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal enum Direction
|
||||||
|
{
|
||||||
|
Up =1,
|
||||||
|
Down = 2,
|
||||||
|
Left = 3,
|
||||||
|
Right = 4,
|
||||||
|
UpLeft = 5,
|
||||||
|
DownLeft = 6,
|
||||||
|
UpRight = 7,
|
||||||
|
DownRight = 8
|
||||||
|
}
|
||||||
|
}
|
239
AirFighter/DrawingAircraft.cs
Normal file
239
AirFighter/DrawingAircraft.cs
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal class DrawingAircraft
|
||||||
|
{
|
||||||
|
public EntityAircraft Plane { get; private set; }
|
||||||
|
|
||||||
|
private float _startPosX;
|
||||||
|
|
||||||
|
private float _startPosY;
|
||||||
|
|
||||||
|
private int? _pictureWidth = null;
|
||||||
|
private int? _pictureHeight = null;
|
||||||
|
|
||||||
|
protected readonly int _aircraftWidth = 100;
|
||||||
|
protected readonly int _aircraftHeight = 100;
|
||||||
|
|
||||||
|
public void Init(int speed, float weight, Color bodyColor)
|
||||||
|
{
|
||||||
|
Plane = new EntityAircraft();
|
||||||
|
Plane.Init(speed, weight, bodyColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (x + _aircraftWidth > width || x < 0 || y + _aircraftHeight > height || y < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveTransport(Direction direction)
|
||||||
|
{
|
||||||
|
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case Direction.Right:
|
||||||
|
{
|
||||||
|
if (_startPosX + _aircraftWidth + Plane.Step < _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX += Plane.Step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Direction.Left:
|
||||||
|
{
|
||||||
|
if (_startPosX - Plane.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosX -= Plane.Step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Direction.Up:
|
||||||
|
{
|
||||||
|
if (_startPosY - Plane.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosY -= Plane.Step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Direction.Down:
|
||||||
|
{
|
||||||
|
if (_startPosY + _aircraftHeight + Plane.Step < _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY += Plane.Step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Direction.UpRight:
|
||||||
|
{
|
||||||
|
if (_startPosY - Plane.Step > 0 && _startPosX + _aircraftWidth + Plane.Step < _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosY -= Plane.Step;
|
||||||
|
_startPosX += Plane.Step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Direction.UpLeft:
|
||||||
|
{
|
||||||
|
if (_startPosY - Plane.Step > 0 && _startPosX - Plane.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosX -= Plane.Step;
|
||||||
|
_startPosY -= Plane.Step;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Direction.DownRight:
|
||||||
|
{
|
||||||
|
if (_startPosY + _aircraftHeight + Plane.Step < _pictureHeight && _startPosX + _aircraftWidth + Plane.Step < _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosY += Plane.Step;
|
||||||
|
_startPosX += Plane.Step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Direction.DownLeft:
|
||||||
|
{
|
||||||
|
if (_startPosY + _aircraftHeight + Plane.Step < _pictureHeight && _startPosX - Plane.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosY += Plane.Step;
|
||||||
|
_startPosX -= Plane.Step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Aircraft Body
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
Brush brWhite = new SolidBrush(Plane.BodyColor);
|
||||||
|
|
||||||
|
g.FillRectangle(brWhite, _startPosX + 20, _startPosY + 45, 80, 14);
|
||||||
|
g.DrawRectangle(pen,_startPosX + 20, _startPosY + 45, 80, 14);
|
||||||
|
|
||||||
|
//Wings
|
||||||
|
|
||||||
|
GraphicsPath pathWing1 = new GraphicsPath();
|
||||||
|
|
||||||
|
Point point1B = new Point((int)(_startPosX + 50), (int)(_startPosY + 45));
|
||||||
|
Point point2B = new Point(point1B.X, point1B.Y - 40);
|
||||||
|
Point point3B = new Point(point2B.X + 6, point2B.Y);
|
||||||
|
Point point4B = new Point(point3B.X + 27, point1B.Y);
|
||||||
|
Point[] pointsWings = new Point[] { point1B, point2B, point3B, point4B };
|
||||||
|
|
||||||
|
pathWing1.AddLines(pointsWings);
|
||||||
|
g.DrawPath(pen, pathWing1);
|
||||||
|
g.FillPath(brWhite, pathWing1);
|
||||||
|
|
||||||
|
|
||||||
|
GraphicsPath pathWing2 = new GraphicsPath();
|
||||||
|
|
||||||
|
Point point1B2 = new Point((int)(_startPosX + 50), (int)(_startPosY + 60));
|
||||||
|
Point point2B2 = new Point(point1B2.X, point1B2.Y + 40);
|
||||||
|
Point point3B2 = new Point(point2B2.X + 6, point2B2.Y);
|
||||||
|
Point point4B2 = new Point(point3B2.X + 27, point1B2.Y);
|
||||||
|
Point[] pointsWings2 = new Point[] { point1B2, point2B2, point3B2, point4B2 };
|
||||||
|
|
||||||
|
pathWing2.AddLines(pointsWings2);
|
||||||
|
g.DrawPath(pen, pathWing2);
|
||||||
|
g.FillPath(brWhite, pathWing2);
|
||||||
|
|
||||||
|
|
||||||
|
//BackWings
|
||||||
|
GraphicsPath pathBackWing1 = new GraphicsPath();
|
||||||
|
|
||||||
|
Point point1W = new Point((int)(_startPosX + 85), (int)(_startPosY + 45));
|
||||||
|
Point point2W = new Point(point1W.X, point1W.Y - 7);
|
||||||
|
Point point3W = new Point(point2W.X + 15, point2W.Y - 16);
|
||||||
|
Point point4W = new Point(point3W.X, point1W.Y);
|
||||||
|
Point[] pointsBackWing1 = new Point[] { point1W, point2W, point3W, point4W };
|
||||||
|
|
||||||
|
pathBackWing1.AddLines(pointsBackWing1);
|
||||||
|
g.DrawPath(pen, pathBackWing1);
|
||||||
|
g.FillPath(brWhite, pathBackWing1);
|
||||||
|
|
||||||
|
GraphicsPath pathBackWing2 = new GraphicsPath();
|
||||||
|
|
||||||
|
Point point1W2 = new Point((int)(_startPosX + 85), (int)(_startPosY + 60));
|
||||||
|
Point point2W2 = new Point(point1W2.X, point1W2.Y + 7);
|
||||||
|
Point point3W2 = new Point(point2W2.X + 15, point2W2.Y +16);
|
||||||
|
Point point4W2 = new Point(point3W2.X, point1W2.Y);
|
||||||
|
Point[] pointsBackWing2 = new Point[] { point1W2, point2W2, point3W2, point4W2 };
|
||||||
|
|
||||||
|
pathBackWing2.AddLines(pointsBackWing2);
|
||||||
|
g.DrawPath(pen,pathBackWing2);
|
||||||
|
g.FillPath(brWhite,pathBackWing2);
|
||||||
|
|
||||||
|
Brush brBlack = new SolidBrush(Color.Black);
|
||||||
|
|
||||||
|
//Nose
|
||||||
|
GraphicsPath pathBoseBody = new GraphicsPath();
|
||||||
|
|
||||||
|
Point point1N = new Point((int)(_startPosX + 20), (int)(_startPosY + 45));
|
||||||
|
Point point2N = new Point(point1N.X - 15 ,point1N.Y + 7);
|
||||||
|
Point point3N = new Point(point1N.X, point1N.Y + 15);
|
||||||
|
|
||||||
|
Point[] pointsBoseBody = new Point[] { point1N,point2N,point3N};
|
||||||
|
|
||||||
|
pathBoseBody.AddLines(pointsBoseBody);
|
||||||
|
g.FillPath(brBlack,pathBoseBody);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeBorders(int width, int height)
|
||||||
|
{
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
|
||||||
|
if (_pictureWidth <= _aircraftWidth || _pictureHeight <= _aircraftHeight)
|
||||||
|
{
|
||||||
|
_pictureHeight = null;
|
||||||
|
_pictureWidth = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_startPosX + _aircraftWidth > _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX = _pictureWidth.Value - _aircraftWidth;
|
||||||
|
}
|
||||||
|
if (_startPosY + _aircraftHeight > _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY = _pictureHeight.Value - _aircraftHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
AirFighter/EntityAircraft.cs
Normal file
41
AirFighter/EntityAircraft.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal class EntityAircraft
|
||||||
|
{
|
||||||
|
public int Speed
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float Weight
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color BodyColor
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=> оператор подобный return
|
||||||
|
public float Step => Speed * 100 / Weight;
|
||||||
|
|
||||||
|
|
||||||
|
public void Init(int speed, float weight, Color bodyColor)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
39
AirFighter/Form1.Designer.cs
generated
39
AirFighter/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
|||||||
namespace AirFighter
|
|
||||||
{
|
|
||||||
partial class Form1
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.components = new System.ComponentModel.Container();
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
|
||||||
this.Text = "Form1";
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace AirFighter
|
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ namespace AirFighter
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new Form1());
|
Application.Run(new AirFighterForm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
103
AirFighter/Properties/Resources.Designer.cs
generated
Normal file
103
AirFighter/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace AirFighter.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||||
|
/// </summary>
|
||||||
|
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||||
|
// с помощью такого средства, как ResGen или Visual Studio.
|
||||||
|
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||||
|
// с параметром /str или перестройте свой проект VS.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AirFighter.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||||
|
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap ArrowDown {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("ArrowDown", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap ArrowLeft {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("ArrowLeft", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap ArrowRight {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("ArrowRight", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap ArrowUp {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("ArrowUp", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -117,4 +117,17 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="ArrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\ArrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="ArrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\ArrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="ArrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\ArrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="ArrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\ArrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
BIN
AirFighter/Resources/ArrowDown.png
Normal file
BIN
AirFighter/Resources/ArrowDown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 87 KiB |
BIN
AirFighter/Resources/ArrowLeft.png
Normal file
BIN
AirFighter/Resources/ArrowLeft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 KiB |
BIN
AirFighter/Resources/ArrowRight.png
Normal file
BIN
AirFighter/Resources/ArrowRight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 81 KiB |
BIN
AirFighter/Resources/ArrowUp.png
Normal file
BIN
AirFighter/Resources/ArrowUp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 KiB |
Loading…
Reference in New Issue
Block a user