diff --git a/Airbus/Airbus/DrawningObjectAirbus.cs b/Airbus/Airbus/DrawningObjectAirbus.cs index 5903969..10cfb51 100644 --- a/Airbus/Airbus/DrawningObjectAirbus.cs +++ b/Airbus/Airbus/DrawningObjectAirbus.cs @@ -19,7 +19,7 @@ namespace Airbus void IDrawningObject.DrawningObject(Graphics g) { - //ДОДУМАТЬ ЛОГИКУ ЭТОГО МЕТОДА + _airbus.DrawTransport(g); } public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() diff --git a/Airbus/Airbus/FormMap.Designer.cs b/Airbus/Airbus/FormMap.Designer.cs index 4366f3c..473c6d9 100644 --- a/Airbus/Airbus/FormMap.Designer.cs +++ b/Airbus/Airbus/FormMap.Designer.cs @@ -168,7 +168,9 @@ this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxSelectorMap.FormattingEnabled = true; this.comboBoxSelectorMap.Items.AddRange(new object[] { - "Простая карта"}); + "Простая карта", + "Пустыня", + "Космос"}); this.comboBoxSelectorMap.Location = new System.Drawing.Point(10, 9); this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; diff --git a/Airbus/Airbus/FormMap.cs b/Airbus/Airbus/FormMap.cs index a4a38c9..91592d8 100644 --- a/Airbus/Airbus/FormMap.cs +++ b/Airbus/Airbus/FormMap.cs @@ -78,6 +78,13 @@ namespace Airbus case "Простая карта": _abstractMap = new SimpleMap(); break; + case "Пустыня": + _abstractMap = new SecondSimpleMap(); + break; + case "Космос": + + _abstractMap = new ThirdSimpleMap(); + break; } } } diff --git a/Airbus/Airbus/SecondSimpleMap.cs b/Airbus/Airbus/SecondSimpleMap.cs new file mode 100644 index 0000000..888d07a --- /dev/null +++ b/Airbus/Airbus/SecondSimpleMap.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Airbus +{ + internal class SecondSimpleMap: AbstractMap + { + //цвет закрытого участка + Brush barriedColor = new SolidBrush(Color.DarkRed); + + //цвет открытого участка + Brush roadColor = new SolidBrush(Color.DarkOrange); + + protected override void DrawBarrierPart(Graphics g, int i, int j) + { + g.FillEllipse(barriedColor, i * _size_x, j * _size_y, _size_x, _size_x); + } + + protected override void DrawRoadPart(Graphics g, int i, int j) + { + g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _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 < 50) + { + int x = _random.Next(0, 100); + int y = _random.Next(0, 100); + + if (_map[x, y] == _freeRoad) + { + _map[x, y] = _barrier; + counter++; + } + } + } + } +} diff --git a/Airbus/Airbus/SimpleMap.cs b/Airbus/Airbus/SimpleMap.cs index 2f43295..e38da60 100644 --- a/Airbus/Airbus/SimpleMap.cs +++ b/Airbus/Airbus/SimpleMap.cs @@ -8,7 +8,7 @@ namespace Airbus { internal class SimpleMap: AbstractMap { - //цвет закрытого уастка + //цвет закрытого участка Brush barriedColor = new SolidBrush(Color.Black); //цвет открытого участка @@ -16,12 +16,12 @@ namespace Airbus protected override void DrawBarrierPart(Graphics g, int i, int j) { - g.FillRectangle(barriedColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + g.FillRectangle(barriedColor, i * _size_x, j * _size_y, _size_x, _size_y); } protected override void DrawRoadPart(Graphics g, int i, int j) { - g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y); } protected override void GenerateMap() diff --git a/Airbus/Airbus/ThirdSimpleMap.cs b/Airbus/Airbus/ThirdSimpleMap.cs new file mode 100644 index 0000000..8b0d653 --- /dev/null +++ b/Airbus/Airbus/ThirdSimpleMap.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Airbus +{ + internal class ThirdSimpleMap: AbstractMap + { + Random rnd = new Random(); + + //цвет выстрела из лазера + Color randomColor = new Color(); + + //цвет закрытого участка + Brush barriedColor; + + //цвет открытого участка + Brush roadColor = new SolidBrush(Color.DarkBlue); + + protected override void DrawBarrierPart(Graphics g, int i, int j) + { + randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256)); + barriedColor = new SolidBrush(randomColor); + g.FillRectangle(barriedColor, i * _size_x, j * _size_y, _size_x, _size_y); + } + + protected override void DrawRoadPart(Graphics g, int i, int j) + { + g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _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 < 50) + { + int x = _random.Next(0, 100); + int y = _random.Next(0, 100); + + if (_map[x, y] == _freeRoad) + { + _map[x, y] = _barrier; + counter++; + } + } + } + } +}