This commit is contained in:
HOME 2022-09-12 10:09:08 +04:00
parent e8b6e9e398
commit 33a595e4b2
11 changed files with 5072 additions and 0 deletions

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stormtrooper", "Stormtrooper\Stormtrooper.csproj", "{921570CB-0EBB-4B7A-94D7-6B2E7AC5B34C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{921570CB-0EBB-4B7A-94D7-6B2E7AC5B34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{921570CB-0EBB-4B7A-94D7-6B2E7AC5B34C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{921570CB-0EBB-4B7A-94D7-6B2E7AC5B34C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{921570CB-0EBB-4B7A-94D7-6B2E7AC5B34C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9A70ADC6-A14D-4219-8E7D-3EBA79D2F7AF}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal enum Direction
{
Up = 1,
Down = 2,
Left = 3,
Right = 4
}
}

View File

@ -0,0 +1,292 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stormtrooper
{
internal class DrowningStormtrooper
{
public EntityStormtrooper Stormtrooper { private set; get; }
/// <summary>
/// Левая координата отрисовки автомобиля
/// </summary>
private float _startPosX;
/// <summary>
/// Верхняя кооридната отрисовки автомобиля
/// </summary>
private float _startPosY;
/// <summary>
/// Ширина окна отрисовки
/// </summary>
private int? _pictureWidth = null;
/// <summary>
/// Высота окна отрисовки
/// </summary>
private int? _pictureHeight = null;
/// <summary>
/// Ширина отрисовки автомобиля
/// </summary>
private readonly int _stormtrooperWidth = 90;
/// <summary>
/// Высота отрисовки автомобиля
/// </summary>
private readonly int _stormtrooperHeight = 120;
/// <summary>
/// Инициализация свойств
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес автомобиля</param>
/// <param name="bodyColor">Цвет кузова</param>
public void Init(int speed, float weight, Color bodyColor)
{
Stormtrooper = new EntityStormtrooper();
Stormtrooper.Init(speed, weight, bodyColor);
}
/// <summary>
/// Установка позиции автомобиля
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
public void SetPosition(int x, int y, int width, int height)
{
if(x > 0 && y > 0 && width >= _stormtrooperWidth && height >= _stormtrooperHeight && x + _stormtrooperWidth < width && y + _stormtrooperHeight < height)
{
_startPosX = x;
_startPosY = y;
_pictureWidth = width;
_pictureHeight = height;
}
return;
}
/// <summary>
/// Изменение направления перемещения
/// </summary>
/// <param name="direction">Направление</param>
public void MoveTransport(Direction direction)
{
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
{
return;
}
switch (direction)
{
// вправо
case Direction.Right:
if (_startPosX + _stormtrooperWidth + Stormtrooper.Step < _pictureWidth)
{
_startPosX += Stormtrooper.Step;
}
break;
//влево
case Direction.Left:
if (_startPosX - Stormtrooper.Step > 0)
{
_startPosX -= Stormtrooper.Step;
}
break;
//вверх
case Direction.Up:
if (_startPosY - Stormtrooper.Step > 0)
{
_startPosY -= Stormtrooper.Step;
}
break;
//вниз
case Direction.Down:
if (_startPosY + _stormtrooperHeight + Stormtrooper.Step < _pictureHeight)
{
_startPosY += Stormtrooper.Step;
}
break;
}
}
/// <summary>
/// Отрисовка автомобиля
/// </summary>
/// <param name="g"></param>
public void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
{
return;
}
Pen pen = new(Color.Black);
PointF point1 = new PointF(_startPosX, _startPosY + 30);
PointF point2 = new PointF(_startPosX + 10, _startPosY + 40);
PointF point3 = new PointF(_startPosX + 10, _startPosY + 50);
PointF point4 = new PointF(_startPosX + 30, _startPosY + 50);
PointF point5 = new PointF(_startPosX + 40, _startPosY + 10);
PointF point6 = new PointF(_startPosX + 50, _startPosY);
PointF point7 = new PointF(_startPosX + 50, _startPosY + 10);
PointF point8 = new PointF(_startPosX + 55, _startPosY + 10);
PointF point9 = new PointF(_startPosX + 60, _startPosY + 15);
PointF point10 = new PointF(_startPosX + 55, _startPosY + 20);
PointF point11 = new PointF(_startPosX + 50, _startPosY + 20);
PointF point12 = new PointF(_startPosX + 50, _startPosY + 30);
PointF point13 = new PointF(_startPosX + 55, _startPosY + 30);
PointF point14 = new PointF(_startPosX + 60, _startPosY + 35);
PointF point15 = new PointF(_startPosX + 55, _startPosY + 40);
PointF point16 = new PointF(_startPosX + 50, _startPosY + 40);
PointF point17 = new PointF(_startPosX + 50, _startPosY + 50);
PointF point18 = new PointF(_startPosX + 70, _startPosY + 50);
PointF point19 = new PointF(_startPosX + 80, _startPosY + 60);
PointF point20 = new PointF(_startPosX + 70, _startPosY + 70);
PointF point21 = new PointF(_startPosX + 50, _startPosY + 70);
PointF point22 = new PointF(_startPosX + 50, _startPosY + 80);
PointF point23 = new PointF(_startPosX + 55, _startPosY + 80);
PointF point24 = new PointF(_startPosX + 60, _startPosY + 85);
PointF point25 = new PointF(_startPosX + 55, _startPosY + 90);
PointF point26 = new PointF(_startPosX + 50, _startPosY + 90);
PointF point27 = new PointF(_startPosX + 50, _startPosY + 100);
PointF point28 = new PointF(_startPosX + 55, _startPosY + 100);
PointF point29 = new PointF(_startPosX + 60, _startPosY + 105);
PointF point30 = new PointF(_startPosX + 55, _startPosY + 110);
PointF point31 = new PointF(_startPosX + 50, _startPosY + 110);
PointF point32 = new PointF(_startPosX + 50, _startPosY + 120);
PointF point33 = new PointF(_startPosX + 40, _startPosY + 110);
PointF point34 = new PointF(_startPosX + 30, _startPosY + 70);
PointF point35 = new PointF(_startPosX + 10, _startPosY + 70);
PointF point36 = new PointF(_startPosX + 10, _startPosY + 80);
PointF point37 = new PointF(_startPosX, _startPosY + 90);
PointF[] all_stoormtrooper =
{
point1,
point2,
point3,
point4,
point5,
point6,
point7,
point8,
point9,
point10,
point11,
point12,
point13,
point14,
point15,
point16,
point17,
point18,
point19,
point20,
point21,
point22,
point23,
point24,
point25,
point26,
point27,
point28,
point29,
point30,
point31,
point32,
point33,
point34,
point35,
point36,
point37,
};
g.FillPolygon(Brushes.Black, all_stoormtrooper);
/*g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20);
g.DrawEllipse(pen, _startPosX, _startPosY + 30, 20, 20);
g.DrawEllipse(pen, _startPosX + 70, _startPosY, 20, 20);
g.DrawEllipse(pen, _startPosX + 70, _startPosY + 30, 20, 20);
g.DrawRectangle(pen, _startPosX - 1, _startPosY + 10, 10, 30);
g.DrawRectangle(pen, _startPosX + 80, _startPosY + 10, 10, 30);
g.DrawRectangle(pen, _startPosX + 10, _startPosY - 1, 70, 52);
//задние фары
Brush brRed = new SolidBrush(Color.Red);
g.FillEllipse(brRed, _startPosX, _startPosY, 20, 20);
g.FillEllipse(brRed, _startPosX, _startPosY + 30, 20, 20);
//передние фары
Brush brYellow = new SolidBrush(Color.Yellow);
g.FillEllipse(brYellow, _startPosX + 70, _startPosY, 20, 20);
g.FillEllipse(brYellow, _startPosX + 70, _startPosY + 30, 20, 20);*/
//кузов
Brush br = new SolidBrush(Stormtrooper?.BodyColor ?? Color.Black);
point1 = new PointF(_startPosX + 30, _startPosY + 50);
point2 = new PointF(_startPosX + 40, _startPosY + 10);
point3 = new PointF(_startPosX + 40, _startPosY + 50);
PointF[] up_wing =
{
point1,
point2,
point3,
};
g.FillPolygon(br, up_wing);
point1 = new PointF(_startPosX + 30, _startPosY + 70);
point2 = new PointF(_startPosX + 40, _startPosY + 70);
point3 = new PointF(_startPosX + 40, _startPosY + 110);
PointF[] down_wing =
{
point1,
point2,
point3,
};
g.FillPolygon(br, down_wing);
point1 = new PointF(_startPosX + 72, _startPosY + 52);
point2 = new PointF(_startPosX + 78, _startPosY + 60);
point3 = new PointF(_startPosX + 72, _startPosY + 68);
PointF[] cabin =
{
point1,
point2,
point3,
};
g.FillPolygon(Brushes.Brown, cabin);
/*g.FillRectangle(br, _startPosX, _startPosY + 10, 10, 30);
g.FillRectangle(br, _startPosX + 80, _startPosY + 10, 10, 30);
g.FillRectangle(br, _startPosX + 10, _startPosY, 70, 50);
//стекла
Brush brBlue = new SolidBrush(Color.LightBlue);
g.FillRectangle(brBlue, _startPosX + 60, _startPosY + 5, 5, 40);
g.FillRectangle(brBlue, _startPosX + 20, _startPosY + 5, 5, 40);
g.FillRectangle(brBlue, _startPosX + 25, _startPosY + 3, 35, 2);
g.FillRectangle(brBlue, _startPosX + 25, _startPosY + 46, 35, 2);
//выделяем рамкой крышу
g.DrawRectangle(pen, _startPosX + 25, _startPosY + 5, 35, 40);
g.DrawRectangle(pen, _startPosX + 65, _startPosY + 10, 25, 30);
g.DrawRectangle(pen, _startPosX, _startPosY + 10, 15, 30);*/
}
/// <summary>
/// Смена границ формы отрисовки
/// </summary>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
public void ChangeBorders(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
if (_pictureWidth <= _stormtrooperWidth || _pictureHeight <= _stormtrooperHeight)
{
_pictureWidth = null;
_pictureHeight = null;
return;
}
if (_startPosX + _stormtrooperWidth > _pictureWidth)
{
_startPosX = _pictureWidth.Value - _stormtrooperWidth;
}
if (_startPosY + _stormtrooperHeight > _pictureHeight)
{
_startPosY = _pictureHeight.Value - _stormtrooperHeight;
}
}
}
}

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 EntityStormtrooper
{
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public float Weight { get; private set; }
/// <summary>
/// Цвет кузова
/// </summary>
public Color BodyColor { get; private set; }
/// <summary>
/// Шаг перемещения автомобиля
/// </summary>
public float Step => Speed * 100 / Weight;
/// <summary>
/// Инициализация полей объекта-класса автомобиля
/// </summary>
/// <param name="speed"></param>
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <returns></returns>
public void Init(int speed, float weight, Color bodyColor)
{
Random rnd = new();
Speed = speed <= 0 ? rnd.Next(500, 1500) : speed;
Weight = weight <= 0 ? rnd.Next(4, 7) : weight;
BodyColor = bodyColor;
}
}
}

View File

@ -0,0 +1,184 @@
namespace Stormtrooper
{
partial class FormStormtrooper
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormStormtrooper));
this.pictureBoxStormtrooper = new System.Windows.Forms.PictureBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
this.buttonCreate = new System.Windows.Forms.Button();
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();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxStormtrooper)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// pictureBoxStormtrooper
//
this.pictureBoxStormtrooper.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxStormtrooper.Location = new System.Drawing.Point(0, 0);
this.pictureBoxStormtrooper.Name = "pictureBoxStormtrooper";
this.pictureBoxStormtrooper.Size = new System.Drawing.Size(800, 424);
this.pictureBoxStormtrooper.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxStormtrooper.TabIndex = 0;
this.pictureBoxStormtrooper.TabStop = false;
this.pictureBoxStormtrooper.Resize += new System.EventHandler(this.PictureBoxStormtrooper_Resize);
//
// statusStrip1
//
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelBodyColor});
this.statusStrip1.Location = new System.Drawing.Point(0, 424);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(800, 26);
this.statusStrip1.TabIndex = 1;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabelSpeed
//
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(76, 20);
this.toolStripStatusLabelSpeed.Text = "Скорость:";
this.toolStripStatusLabelSpeed.Click += new System.EventHandler(this.ToolStripStatusLabelSpeed_Click);
//
// toolStripStatusLabelWeight
//
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(36, 20);
this.toolStripStatusLabelWeight.Text = "Вес:";
//
// toolStripStatusLabelBodyColor
//
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(45, 20);
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
//
// 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(31, 364);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(94, 29);
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 = ((System.Drawing.Image)(resources.GetObject("buttonUp.BackgroundImage")));
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonUp.Location = new System.Drawing.Point(713, 328);
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);
//
// buttonDown
//
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonDown.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonDown.BackgroundImage")));
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonDown.Location = new System.Drawing.Point(713, 364);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(30, 30);
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.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonLeft.BackgroundImage")));
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonLeft.Location = new System.Drawing.Point(677, 365);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
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.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonRight.BackgroundImage")));
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.buttonRight.Location = new System.Drawing.Point(749, 364);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(30, 30);
this.buttonRight.TabIndex = 6;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// FormStormtrooper
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxStormtrooper);
this.Controls.Add(this.statusStrip1);
this.Name = "FormStormtrooper";
this.Text = "Военный самолёт";
this.Click += new System.EventHandler(this.ButtonMove_Click);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxStormtrooper)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox pictureBoxStormtrooper;
private StatusStrip statusStrip1;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
private Button buttonCreate;
private Button buttonUp;
private Button buttonDown;
private Button buttonLeft;
private Button buttonRight;
}
}

View File

@ -0,0 +1,78 @@
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 FormStormtrooper : Form
{
private DrowningStormtrooper _stormtrooper;
public FormStormtrooper()
{
InitializeComponent();
}
private void ToolStripStatusLabelSpeed_Click(object sender, EventArgs e)
{
}
private void Draw()
{
Bitmap bmp = new(pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
Graphics gr = Graphics.FromImage(bmp);
_stormtrooper?.DrawTransport(gr);
pictureBoxStormtrooper.Image = bmp;
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_stormtrooper = new DrowningStormtrooper();
_stormtrooper.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_stormtrooper.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
toolStripStatusLabelSpeed.Text = $"Скорость: {_stormtrooper.Stormtrooper.Speed}";
toolStripStatusLabelWeight.Text = $"Вес: {_stormtrooper.Stormtrooper.Weight}";
toolStripStatusLabelBodyColor.Text = $"Цвет:{ _stormtrooper.Stormtrooper.BodyColor.Name}";
Draw();
}
private void ButtonMove_Click(object sender, EventArgs e)
{
//получаем имя кнопки
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_stormtrooper?.MoveTransport(Direction.Up);
break;
case "buttonDown":
_stormtrooper?.MoveTransport(Direction.Down);
break;
case "buttonLeft":
_stormtrooper?.MoveTransport(Direction.Left);
break;
case "buttonRight":
_stormtrooper?.MoveTransport(Direction.Right);
break;
}
Draw();
}
private void PictureBoxStormtrooper_Resize(object sender, EventArgs e)
{
_stormtrooper?.ChangeBorders(pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
Draw();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
namespace Stormtrooper
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormStormtrooper());
}
}
}

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Stormtrooper.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("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

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

View File

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</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>