diff --git a/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs b/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs
index ea02d63..30d189f 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/AbstractMap.cs
@@ -81,7 +81,10 @@ namespace AirplaneWithRadar
{
for (int j = left; j <= right; j++)
{
- if (_map[j, i] == 1) return false;
+ if (_map[j, i] == 1)
+ {
+ return false;
+ }
}
}
return true;
diff --git a/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs b/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs
new file mode 100644
index 0000000..2c920c7
--- /dev/null
+++ b/AirplaneWithRadar/AirplaneWithRadar/BlockMap.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace AirplaneWithRadar
+{
+ internal class BlockMap : AbstractMap
+ {
+ ///
+ /// Цвет участка закрытого
+ ///
+ private readonly Brush barrierColor = new SolidBrush(Color.Beige);
+ ///
+ /// Цвет участка открытого
+ ///
+ private readonly Brush roadColor = new SolidBrush(Color.LightBlue);
+
+ 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 + 1) * (_size_x + 1), (j + 1) * (_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 block = 0;
+ for (int i = 0; i < _map.GetLength(0); i++)
+ {
+ for (int j = 0; j < _map.GetLength(1); j++)
+ {
+ _map[i, j] = _freeRoad;
+ }
+ }
+ int numberBlocks = _random.Next(10, 15);
+ while (block < numberBlocks)
+ {
+ int x = _random.Next(0, 80);
+ int y = _random.Next(0, 80);
+ int blockWidth = _random.Next(0, 19);
+ int blockHeight = _random.Next(0, 19);
+
+ bool isFree = true;
+ for (int i = x; i < x + blockWidth; i++)
+ {
+ for (int j = y; j < y + blockHeight; j++)
+ {
+ if (_map[i, j] != _freeRoad)
+ {
+ isFree = false;
+ break;
+ }
+
+ }
+ }
+ if (isFree)
+ {
+ for (int i = x; i < x + blockWidth; i++)
+ {
+ for (int j = y; j < y + blockHeight; j++)
+ {
+ _map[i, j] = _barrier;
+ }
+ }
+ block++;
+ }
+ }
+ }
+ }
+}
diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs b/AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs
index 977ebcf..aa2bb3e 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/FormMap.Designer.cs
@@ -159,7 +159,8 @@
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта",
- "Собственная карта"});
+ "Карта с линиями",
+ "Карта с блоками"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(182, 33);
diff --git a/AirplaneWithRadar/AirplaneWithRadar/FormMap.cs b/AirplaneWithRadar/AirplaneWithRadar/FormMap.cs
index 9313a2d..49f17cc 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/FormMap.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/FormMap.cs
@@ -93,8 +93,11 @@ namespace AirplaneWithRadar
case "Простая карта":
_abstractMap = new SimpleMap();
break;
- case "Собственная карта":
- _abstractMap = new MyMap();
+ case "Карта с линиями":
+ _abstractMap = new LineMap();
+ break;
+ case "Карта с блоками":
+ _abstractMap = new BlockMap();
break;
}
}
diff --git a/AirplaneWithRadar/AirplaneWithRadar/MyMap.cs b/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs
similarity index 98%
rename from AirplaneWithRadar/AirplaneWithRadar/MyMap.cs
rename to AirplaneWithRadar/AirplaneWithRadar/LineMap.cs
index 06ce687..f26f73d 100644
--- a/AirplaneWithRadar/AirplaneWithRadar/MyMap.cs
+++ b/AirplaneWithRadar/AirplaneWithRadar/LineMap.cs
@@ -9,7 +9,7 @@ namespace AirplaneWithRadar
///
/// Собственная реализация абсрактного класса AbstractMap
///
- internal class MyMap : AbstractMap
+ internal class LineMap : AbstractMap
{
///
/// Цвет участка закрытого