diff --git a/Stormtrooper/Stormtrooper/AbstractMap.cs b/Stormtrooper/Stormtrooper/AbstractMap.cs
new file mode 100644
index 0000000..28d28ad
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/AbstractMap.cs
@@ -0,0 +1,151 @@
+using Stormtrooper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Cars
+{
+ internal abstract class AbstractMap
+ {
+ private IDrawningObject _drawningObject = null;
+ protected int[,] _map = null;
+ protected int _width;
+ protected int _height;
+ protected float _size_x;
+ protected float _size_y;
+ protected readonly Random _random = new();
+ protected readonly int _freeRoad = 0;
+ protected readonly int _barrier = 1;
+
+ public Bitmap CreateMap(int width, int height, IDrawningObject drawningObject)
+ {
+ _width = width;
+ _height = height;
+ _drawningObject = drawningObject;
+ GenerateMap();
+ while (!SetObjectOnMap())
+ {
+ GenerateMap();
+ }
+ return DrawMapWithObject();
+ }
+ public Bitmap MoveObject(Direction direction)
+ {
+ if (CheckCollision(direction))
+ {
+ _drawningObject.MoveObject(direction);
+ }
+ return DrawMapWithObject();
+ }
+ private bool SetObjectOnMap()
+ {
+ if (_drawningObject == null || _map == null)
+ {
+ return false;
+ }
+ int x = _random.Next(0, (int)(_width * 0.9f));
+ int y = _random.Next(0, (int)(_height * 0.8f));
+ _drawningObject.SetObject(x, y, _width, _height);
+
+ while (!CheckCollision(Direction.None))
+ {
+ x = _random.Next(0, (int)(_width * 0.9f));
+ y = _random.Next(0, (int)(_height * 0.8f));
+ _drawningObject.SetObject(x, y, _width, _height);
+ }
+ return true;
+ }
+
+ private bool CheckCollision(Direction dir)
+ {
+ int left = (int)(_drawningObject.GetCurrentPosition().Left / _size_x);
+ int top = (int)(_drawningObject.GetCurrentPosition().Top / _size_y);
+ int bottom = (int)(_drawningObject.GetCurrentPosition().Bottom / _size_y) +1;
+ int right = (int)(_drawningObject.GetCurrentPosition().Right / _size_x) +1;
+ switch (dir)
+ {
+ case Direction.None:
+ break;
+ case Direction.Left:
+ if (left >= 1)
+ {
+ left--;
+ right--;
+ }
+ else return false;
+ break;
+ case Direction.Up:
+ if (top >= 1)
+ {
+ top--;
+ bottom--;
+ }
+ else return false;
+
+ break;
+ case Direction.Down:
+ if (bottom <= 98)
+ {
+ top++;
+ bottom++;
+ }
+ else return false;
+ break;
+ case Direction.Right:
+ if (right <= 98)
+ {
+ left++;
+ right++;
+ }
+ else return false;
+ break;
+ }
+
+ for (int i = left; i < right; i++)
+ {
+ for (int j = top; j < bottom; j++)
+ {
+ if (_map[i, j] == _barrier)
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+
+
+ private Bitmap DrawMapWithObject()
+ {
+ Bitmap bmp = new(_width, _height);
+ if (_drawningObject == null || _map == null)
+ {
+ return bmp;
+ }
+ Graphics gr = Graphics.FromImage(bmp);
+ for (int i = 0; i < _map.GetLength(0); ++i)
+ {
+ for (int j = 0; j < _map.GetLength(1); ++j)
+ {
+ if (_map[i, j] == _freeRoad)
+ {
+ DrawRoadPart(gr, i, j);
+ }
+ else if (_map[i, j] == _barrier)
+ {
+ DrawBarrierPart(gr, i, j);
+ }
+ }
+ }
+ _drawningObject.DrawningObject(gr);
+ return bmp;
+ }
+
+ protected abstract void GenerateMap();
+ protected abstract void DrawRoadPart(Graphics g, int i, int j);
+ protected abstract void DrawBarrierPart(Graphics g, int i, int j);
+ }
+}
\ No newline at end of file
diff --git a/Stormtrooper/Stormtrooper/Direction.cs b/Stormtrooper/Stormtrooper/Direction.cs
index bc5cbbe..f4826fe 100644
--- a/Stormtrooper/Stormtrooper/Direction.cs
+++ b/Stormtrooper/Stormtrooper/Direction.cs
@@ -9,6 +9,7 @@ namespace Stormtrooper
internal enum Direction
{
+ None,
Up,
Down,
Left,
diff --git a/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs b/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs
index 13ba0cd..ac03b92 100644
--- a/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs
+++ b/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs
@@ -130,24 +130,10 @@ namespace Stormtrooper
g.DrawRectangle(pen, _startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.45f, _airplaneWidth * 0.9f, _airplaneHeight * 0.1f);
}
- public void ChangeBorders(int width, int height)
+
+ public (float Left, float Top, float Right, float Bottom) GetCurrentPosition()
{
- _pictureWidth = width;
- _pictureHeight = height;
- if (_pictureWidth <= _airplaneWidth || _pictureHeight <= _airplaneHeight)
- {
- _pictureWidth = null;
- _pictureHeight = null;
- return;
- }
- if (_startPosX + _airplaneWidth > _pictureWidth)
- {
- _startPosX = _pictureWidth.Value - _airplaneWidth;
- }
- if (_startPosY + _airplaneHeight > _pictureHeight)
- {
- _startPosY = _pictureHeight.Value - _airplaneHeight;
- }
+ return (_startPosX, _startPosY, _startPosX + _airplaneWidth, _startPosY + _airplaneHeight);
}
}
}
diff --git a/Stormtrooper/Stormtrooper/DrawningObject.cs b/Stormtrooper/Stormtrooper/DrawningObject.cs
new file mode 100644
index 0000000..13841e1
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/DrawningObject.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Stormtrooper
+{
+ internal class DrawningObject : IDrawningObject
+ {
+ private DrawningMilitaryAirplane _airplane;
+
+ public DrawningObject(DrawningMilitaryAirplane airplane)
+ {
+ _airplane = airplane;
+ }
+
+ public float Step => _airplane?.Airplane?.Step ?? 0;
+
+ public (float Left, float Top, float Right, float Bottom) GetCurrentPosition()
+ {
+ return _airplane?.GetCurrentPosition() ?? default;
+ }
+
+ public void MoveObject(Direction direction)
+ {
+ _airplane?.MoveAirplane(direction);
+ }
+
+ public void SetObject(int x, int y, int width, int height)
+ {
+ _airplane?.SetPosition(x, y, width, height);
+ }
+
+ void IDrawningObject.DrawningObject(Graphics g)
+ {
+ _airplane.DrawAirplane(g);
+ }
+ }
+}
diff --git a/Stormtrooper/Stormtrooper/FormMap.Designer.cs b/Stormtrooper/Stormtrooper/FormMap.Designer.cs
new file mode 100644
index 0000000..bb7609b
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/FormMap.Designer.cs
@@ -0,0 +1,212 @@
+
+namespace Stormtrooper
+{
+ partial class FormMap
+ {
+ ///
+ /// Обязательная переменная конструктора.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Освободить все используемые ресурсы.
+ ///
+ /// истинно, если управляемый ресурс должен быть удален; иначе ложно.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Код, автоматически созданный конструктором форм Windows
+
+ ///
+ /// Требуемый метод для поддержки конструктора — не изменяйте
+ /// содержимое этого метода с помощью редактора кода.
+ ///
+ private void InitializeComponent()
+ {
+ this.pictureBoxAirplane = new System.Windows.Forms.PictureBox();
+ this.buttonCreate = new System.Windows.Forms.Button();
+ this.toolStripStatus = new System.Windows.Forms.ToolStrip();
+ this.toolStripLabelSpeed = new System.Windows.Forms.ToolStripLabel();
+ this.toolStripLabelWeight = new System.Windows.Forms.ToolStripLabel();
+ this.toolStripLabelCrew = new System.Windows.Forms.ToolStripLabel();
+ this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonRight = new System.Windows.Forms.Button();
+ this.buttonCreateMod = new System.Windows.Forms.Button();
+ this.comboBoxMapSelector = new System.Windows.Forms.ComboBox();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit();
+ this.toolStripStatus.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // pictureBoxAirplane
+ //
+ this.pictureBoxAirplane.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.pictureBoxAirplane.BackColor = System.Drawing.Color.White;
+ this.pictureBoxAirplane.Location = new System.Drawing.Point(14, 14);
+ this.pictureBoxAirplane.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.pictureBoxAirplane.Name = "pictureBoxAirplane";
+ this.pictureBoxAirplane.Size = new System.Drawing.Size(1127, 558);
+ this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ this.pictureBoxAirplane.TabIndex = 0;
+ this.pictureBoxAirplane.TabStop = false;
+ //
+ // buttonCreate
+ //
+ this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonCreate.Cursor = System.Windows.Forms.Cursors.Hand;
+ this.buttonCreate.Location = new System.Drawing.Point(31, 598);
+ this.buttonCreate.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(88, 27);
+ this.buttonCreate.TabIndex = 1;
+ this.buttonCreate.Text = "Создать";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
+ //
+ // toolStripStatus
+ //
+ this.toolStripStatus.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.toolStripStatus.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripLabelSpeed,
+ this.toolStripLabelWeight,
+ this.toolStripLabelCrew});
+ this.toolStripStatus.Location = new System.Drawing.Point(0, 678);
+ this.toolStripStatus.Name = "toolStripStatus";
+ this.toolStripStatus.Size = new System.Drawing.Size(1343, 25);
+ this.toolStripStatus.TabIndex = 2;
+ this.toolStripStatus.Text = "toolStrip1";
+ //
+ // toolStripLabelSpeed
+ //
+ this.toolStripLabelSpeed.Name = "toolStripLabelSpeed";
+ this.toolStripLabelSpeed.Size = new System.Drawing.Size(86, 22);
+ this.toolStripLabelSpeed.Text = "toolStripLabel1";
+ //
+ // toolStripLabelWeight
+ //
+ this.toolStripLabelWeight.Name = "toolStripLabelWeight";
+ this.toolStripLabelWeight.Size = new System.Drawing.Size(86, 22);
+ this.toolStripLabelWeight.Text = "toolStripLabel2";
+ //
+ // toolStripLabelCrew
+ //
+ this.toolStripLabelCrew.Name = "toolStripLabelCrew";
+ this.toolStripLabelCrew.Size = new System.Drawing.Size(86, 22);
+ this.toolStripLabelCrew.Text = "toolStripLabel3";
+ //
+ // buttonUp
+ //
+ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUp.Location = new System.Drawing.Point(1203, 556);
+ this.buttonUp.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(35, 35);
+ this.buttonUp.TabIndex = 3;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
+ //
+ // buttonDown
+ //
+ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDown.Location = new System.Drawing.Point(1203, 598);
+ this.buttonDown.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(35, 35);
+ this.buttonDown.TabIndex = 4;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
+ //
+ // buttonLeft
+ //
+ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonLeft.Location = new System.Drawing.Point(1161, 597);
+ this.buttonLeft.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(35, 35);
+ this.buttonLeft.TabIndex = 5;
+ this.buttonLeft.UseVisualStyleBackColor = true;
+ this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
+ //
+ // buttonRight
+ //
+ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonRight.Location = new System.Drawing.Point(1245, 597);
+ this.buttonRight.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(35, 35);
+ this.buttonRight.TabIndex = 6;
+ this.buttonRight.UseVisualStyleBackColor = true;
+ this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
+ //
+ // buttonCreateMod
+ //
+ this.buttonCreateMod.Location = new System.Drawing.Point(162, 598);
+ this.buttonCreateMod.Name = "buttonCreateMod";
+ this.buttonCreateMod.Size = new System.Drawing.Size(104, 27);
+ this.buttonCreateMod.TabIndex = 7;
+ this.buttonCreateMod.Text = "Модификация";
+ this.buttonCreateMod.UseVisualStyleBackColor = true;
+ this.buttonCreateMod.Click += new System.EventHandler(this.buttonCreateMod_Click);
+ //
+ // comboBoxMapSelector
+ //
+ this.comboBoxMapSelector.FormattingEnabled = true;
+ this.comboBoxMapSelector.Items.AddRange(new object[] {
+ "Простая карта"});
+ this.comboBoxMapSelector.Location = new System.Drawing.Point(31, 27);
+ this.comboBoxMapSelector.Name = "comboBoxMapSelector";
+ this.comboBoxMapSelector.Size = new System.Drawing.Size(117, 23);
+ this.comboBoxMapSelector.TabIndex = 8;
+ this.comboBoxMapSelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxMapSelector_SelectedIndexChanged);
+ //
+ // FormMap
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1343, 703);
+ this.Controls.Add(this.comboBoxMapSelector);
+ this.Controls.Add(this.buttonCreateMod);
+ this.Controls.Add(this.buttonRight);
+ this.Controls.Add(this.buttonLeft);
+ this.Controls.Add(this.buttonDown);
+ this.Controls.Add(this.buttonUp);
+ this.Controls.Add(this.toolStripStatus);
+ this.Controls.Add(this.buttonCreate);
+ this.Controls.Add(this.pictureBoxAirplane);
+ this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.Name = "FormMap";
+ this.Text = "Form1";
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit();
+ this.toolStripStatus.ResumeLayout(false);
+ this.toolStripStatus.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.PictureBox pictureBoxAirplane;
+ private System.Windows.Forms.Button buttonCreate;
+ private System.Windows.Forms.ToolStrip toolStripStatus;
+ private System.Windows.Forms.ToolStripLabel toolStripLabelSpeed;
+ private System.Windows.Forms.ToolStripLabel toolStripLabelWeight;
+ private System.Windows.Forms.ToolStripLabel toolStripLabelCrew;
+ private System.Windows.Forms.Button buttonUp;
+ private System.Windows.Forms.Button buttonDown;
+ private System.Windows.Forms.Button buttonLeft;
+ private System.Windows.Forms.Button buttonRight;
+ private Button buttonCreateMod;
+ private ComboBox comboBoxMapSelector;
+ }
+}
+
diff --git a/Stormtrooper/Stormtrooper/FormMap.cs b/Stormtrooper/Stormtrooper/FormMap.cs
new file mode 100644
index 0000000..0719afe
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/FormMap.cs
@@ -0,0 +1,91 @@
+using Cars;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Stormtrooper
+{
+ public partial class FormMap : Form
+ {
+ DrawningMilitaryAirplane _airplane;
+ AbstractMap _abstractMap;
+ public FormMap()
+ {
+ InitializeComponent();
+ _abstractMap = new SimpleMap();
+ }
+ private void Draw()
+ {
+ Bitmap bmp = new Bitmap (pictureBoxAirplane.Width, pictureBoxAirplane.Height);
+ Graphics gr = Graphics.FromImage(bmp);
+ _airplane?.DrawAirplane(gr);
+ pictureBoxAirplane.Image = bmp;
+ }
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ Random random = new Random();
+ _airplane = new DrawningMilitaryAirplane(10, 50);
+ _airplane.SetPosition(random.Next(100,150), random.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
+ SetData();
+ Draw();
+ }
+
+ private void buttonMove_Click(object sender,EventArgs e)
+ {
+ //получаем имя кнопки
+ string name = ((Button)sender)?.Name ?? string.Empty;
+ Direction dir = Direction.None;
+ switch (name)
+ {
+ case "buttonUp":
+ dir = Direction.Up;
+ break;
+ case "buttonDown":
+ dir = Direction.Down;
+ break;
+ case "buttonLeft":
+ dir = Direction.Left;
+ break;
+ case "buttonRight":
+ dir = Direction.Right;
+ break;
+ }
+ pictureBoxAirplane.Image = _abstractMap?.MoveObject(dir);
+ }
+ private void SetData()
+ {
+ toolStripLabelSpeed.Text = $"Скорость: {_airplane.Airplane.Speed}";
+ toolStripLabelWeight.Text = $"Вес: {_airplane.Airplane.Weight}";
+ toolStripLabelCrew.Text = $"Экипаж: {_airplane.Airplane.Crew}";
+ pictureBoxAirplane.Image = _abstractMap.CreateMap(pictureBoxAirplane.Width, pictureBoxAirplane.Height,
+ new DrawningObject(_airplane));
+ }
+
+ private void buttonCreateMod_Click(object sender, EventArgs e)
+ {
+
+ Random random = new Random();
+ _airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250),random.Next(1,100),
+ Color.FromArgb(random.Next(0,256), random.Next(0, 256), random.Next(0, 256)),
+ Convert.ToBoolean(random.Next(0,2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
+ _airplane.SetPosition(random.Next(100, 150), random.Next(100, 150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
+ SetData();
+ }
+
+ private void comboBoxMapSelector_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (comboBoxMapSelector.Text)
+ {
+ case "Простая карта":
+ _abstractMap = new SimpleMap();
+ break;
+ }
+ }
+ }
+}
diff --git a/Stormtrooper/Stormtrooper/FormMap.resx b/Stormtrooper/Stormtrooper/FormMap.resx
new file mode 100644
index 0000000..6eea15f
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/FormMap.resx
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 25
+
+
\ No newline at end of file
diff --git a/Stormtrooper/Stormtrooper/IDrawningObject.cs b/Stormtrooper/Stormtrooper/IDrawningObject.cs
new file mode 100644
index 0000000..08ef54e
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/IDrawningObject.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Stormtrooper
+{
+ internal interface IDrawningObject
+ {
+ ///
+ /// Шаг перемещения объекта
+ ///
+ public float Step { get; }
+ ///
+ /// Установка позиции объекта
+ ///
+ /// Координата X
+ /// Координата Y
+ /// Ширина полотна
+ /// Высота полотна
+ void SetObject(int x, int y, int width, int height);
+ ///
+ /// Изменение направления пермещения объекта
+ ///
+ /// Направление
+ ///
+ void MoveObject(Direction direction);
+ ///
+ /// Отрисовка объекта
+ ///
+ ///
+ void DrawningObject(Graphics g);
+ ///
+ /// Получение текущей позиции объекта
+ ///
+ ///
+ (float Left, float Top, float Right, float Bottom) GetCurrentPosition();
+ }
+}
diff --git a/Stormtrooper/Stormtrooper/Program.cs b/Stormtrooper/Stormtrooper/Program.cs
index 2637065..63f467d 100644
--- a/Stormtrooper/Stormtrooper/Program.cs
+++ b/Stormtrooper/Stormtrooper/Program.cs
@@ -16,7 +16,7 @@ namespace Stormtrooper
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new MainForm());
+ Application.Run(new FormMap());
}
}
}
diff --git a/Stormtrooper/Stormtrooper/SimpleMap.cs b/Stormtrooper/Stormtrooper/SimpleMap.cs
new file mode 100644
index 0000000..82d90fb
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/SimpleMap.cs
@@ -0,0 +1,50 @@
+namespace Cars
+{
+ ///
+ /// Простая реализация абсрактного класса AbstractMap
+ ///
+ internal class SimpleMap : AbstractMap
+ {
+ ///
+ /// Цвет участка закрытого
+ ///
+ private readonly Brush barrierColor = new SolidBrush(Color.Black);
+ ///
+ /// Цвет участка открытого
+ ///
+ private readonly Brush roadColor = new SolidBrush(Color.Gray);
+
+ protected override void DrawBarrierPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(barrierColor, i * _size_x, j * _size_y, (i+1) * _size_x, (j+1) * _size_y);
+ }
+ protected override void DrawRoadPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y);
+ }
+ protected override void GenerateMap()
+ {
+ _map = new int[100, 100];
+ _size_x = (float)_width / _map.GetLength(0);
+ _size_y = (float)_height / _map.GetLength(1);
+ int counter = 0;
+ for (int i = 0; i < _map.GetLength(0); ++i)
+ {
+ for (int j = 0; j < _map.GetLength(1); ++j)
+ {
+ _map[i, j] = _freeRoad;
+ }
+ }
+ while (counter < 100)
+ {
+ int x = _random.Next(0, 100);
+ int y = _random.Next(0, 100);
+ if (_map[x, y] == _freeRoad)
+ {
+ _map[x, y] = _barrier;
+ counter++;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Stormtrooper/Stormtrooper/Stormtrooper.csproj b/Stormtrooper/Stormtrooper/Stormtrooper.csproj
index b57c89e..9ee8484 100644
--- a/Stormtrooper/Stormtrooper/Stormtrooper.csproj
+++ b/Stormtrooper/Stormtrooper/Stormtrooper.csproj
@@ -8,4 +8,10 @@
enable
+
+
+ Form
+
+
+
\ No newline at end of file