diff --git a/Stormtrooper/Stormtrooper/CloudMap.cs b/Stormtrooper/Stormtrooper/CloudMap.cs
new file mode 100644
index 0000000..c4c8170
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/CloudMap.cs
@@ -0,0 +1,61 @@
+using Cars;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Stormtrooper
+{
+ internal class CloudMap: AbstractMap
+ {
+ private readonly Brush barrierColor = new SolidBrush(Color.Gray);
+ ///
+ /// Цвет участка открытого
+ ///
+ private readonly Brush roadColor = new SolidBrush(Color.White);
+
+ protected override void DrawBarrierPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(barrierColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y);
+ }
+ protected override void DrawRoadPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y);
+ }
+ protected override void GenerateMap()
+ {
+ _map = new int[100, 100];
+ _size_x = (float)_width / _map.GetLength(0);
+ _size_y = (float)_height / _map.GetLength(1);
+ for (int i = 0; i < _map.GetLength(0); ++i)
+ {
+ for (int j = 0; j < _map.GetLength(1); ++j)
+ {
+ _map[i, j] = _freeRoad;
+ }
+ }
+
+ for (int c = _random.Next(1, 5); c > 0; c--)
+ {
+ int i = _random.Next(0, 100);
+ int j = _random.Next(0, 100);
+ int wight = _random.Next(0, Math.Min(100 - j, j));
+ int height = _random.Next(0, Math.Min(100 - i,i));
+
+ for (int k = 0; k <= wight; k++, height--)
+ {
+ for(int l = 0; l <= height; l++)
+ {
+ _map[i + l, j + k] = _barrier;
+ _map[i -l, j - k] = _barrier;
+ _map[i - l, j + k] = _barrier;
+ _map[i + l, j - k] = _barrier;
+ }
+ }
+ }
+
+ }
+ }
+}
+
diff --git a/Stormtrooper/Stormtrooper/DangerMap.cs b/Stormtrooper/Stormtrooper/DangerMap.cs
new file mode 100644
index 0000000..31dc977
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/DangerMap.cs
@@ -0,0 +1,52 @@
+using Cars;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Stormtrooper
+{
+ internal class DangerMap : AbstractMap
+ {
+ private readonly Brush barrierColor = new SolidBrush(Color.Red);
+ ///
+ /// Цвет участка открытого
+ ///
+ private readonly Brush roadColor = new SolidBrush(Color.Black);
+
+ protected override void DrawBarrierPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(barrierColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y);
+ }
+ protected override void DrawRoadPart(Graphics g, int i, int j)
+ {
+ g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y);
+ }
+ protected override void GenerateMap()
+ {
+ _map = new int[100, 100];
+ _size_x = (float)_width / _map.GetLength(0);
+ _size_y = (float)_height / _map.GetLength(1);
+ for (int i = 0; i < _map.GetLength(0); ++i)
+ {
+ for (int j = 0; j < _map.GetLength(1); ++j)
+ {
+ _map[i, j] = _freeRoad;
+ }
+ }
+
+ for(int c = _random.Next(1, 10); c > 0; c--)
+ {
+ int i = _random.Next(0, 100);
+ int maxj = _random.Next(30, 70);
+ for (int j = 0; j < maxj; j++)
+ {
+ _map[i, j] = _barrier;
+ }
+
+ }
+
+ }
+ }
+}
diff --git a/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs b/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs
index ac03b92..a59af2b 100644
--- a/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs
+++ b/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs
@@ -130,6 +130,25 @@ 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)
+ {
+ _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;
+ }
+ }
public (float Left, float Top, float Right, float Bottom) GetCurrentPosition()
{
diff --git a/Stormtrooper/Stormtrooper/FormMap.Designer.cs b/Stormtrooper/Stormtrooper/FormMap.Designer.cs
index bb7609b..8c0b1d0 100644
--- a/Stormtrooper/Stormtrooper/FormMap.Designer.cs
+++ b/Stormtrooper/Stormtrooper/FormMap.Designer.cs
@@ -161,7 +161,9 @@ namespace Stormtrooper
//
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);
diff --git a/Stormtrooper/Stormtrooper/FormMap.cs b/Stormtrooper/Stormtrooper/FormMap.cs
index 0719afe..ce5dca7 100644
--- a/Stormtrooper/Stormtrooper/FormMap.cs
+++ b/Stormtrooper/Stormtrooper/FormMap.cs
@@ -20,20 +20,12 @@ namespace Stormtrooper
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)
@@ -85,6 +77,12 @@ namespace Stormtrooper
case "Простая карта":
_abstractMap = new SimpleMap();
break;
+ case "Опасная карта":
+ _abstractMap = new DangerMap();
+ break;
+ case "Облачная карта":
+ _abstractMap = new CloudMap();
+ break;
}
}
}