From 88b6b488ba2c78054bdd2b0964c4483ec57d5161 Mon Sep 17 00:00:00 2001 From: "Nikolaeva_Y.A" Date: Tue, 25 Oct 2022 00:54:02 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=B2=D1=83=D1=85=20=D0=B4=D0=BE=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=B0=D0=B1=D1=81=D1=82=D1=80=D0=B0=D0=BA=D1=82=D0=BD=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/DrawningObjectAirbus.cs | 2 +- Airbus/Airbus/FormMap.Designer.cs | 4 +- Airbus/Airbus/FormMap.cs | 7 +++ Airbus/Airbus/SecondSimpleMap.cs | 55 ++++++++++++++++++++++++ Airbus/Airbus/SimpleMap.cs | 6 +-- Airbus/Airbus/ThirdSimpleMap.cs | 62 +++++++++++++++++++++++++++ 6 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 Airbus/Airbus/SecondSimpleMap.cs create mode 100644 Airbus/Airbus/ThirdSimpleMap.cs 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++; + } + } + } + } +}