From 1e83e26657c07cb35386b8f6c19a198ddeae1840 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Mon, 3 Oct 2022 09:00:42 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=B2=D0=B5=20=D1=81=D0=BE=D0=B1=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B5=D0=BD=D0=BD=D1=8B=D0=B5=20=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BA=D0=B0=D1=80?= =?UTF-8?q?=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArmoredCar/ArmoredCar/MyMapLabirinth.cs | 73 +++++++++++++++++++++++++ ArmoredCar/ArmoredCar/MyMapWooden.cs | 54 ++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 ArmoredCar/ArmoredCar/MyMapLabirinth.cs create mode 100644 ArmoredCar/ArmoredCar/MyMapWooden.cs diff --git a/ArmoredCar/ArmoredCar/MyMapLabirinth.cs b/ArmoredCar/ArmoredCar/MyMapLabirinth.cs new file mode 100644 index 0000000..fc30914 --- /dev/null +++ b/ArmoredCar/ArmoredCar/MyMapLabirinth.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace ArmoredCar +{ + internal class MyMapLabirinth : AbstractMap + { + /// + /// Цвет участка закрытого + /// + private readonly Brush barrierTreeColor = new SolidBrush(Color.Lime); + /// + /// Цвет участка открытого + /// + private readonly Brush roadColor = new SolidBrush(Color.SandyBrown); + protected override void DrawBarrierPart(Graphics g, int i, int j) + { + g.FillRectangle(barrierTreeColor, i * _size_x, j * _size_y, _size_x * 2, _size_y * 2); + } + protected override void DrawRoadPart(Graphics g, int i, int j) + { + g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x * 2, _size_y * 2); + } + protected override void GenerateMap() + { + _map = new int[50, 50]; + _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 < 20) + { + int x = _random.Next(0, 50); + int y = _random.Next(0, 50); + int number = _random.Next(1, 15); + if (counter < 5) { + if (number + x > _map.GetLength(0)) + { + number = _map.GetLength(0) - x - 1; + } + for (int i = x; i < x + number; ++i) + { + _map[i, y] = _barrier; + } + } else + { + if (number + y > _map.GetLength(1)) + { + number = _map.GetLength(1) - y - 1; + } + for (int i = y; i < y + number; ++i) + { + _map[x, i] = _barrier; + } + } + counter++; + + } + } + } +} diff --git a/ArmoredCar/ArmoredCar/MyMapWooden.cs b/ArmoredCar/ArmoredCar/MyMapWooden.cs new file mode 100644 index 0000000..6951040 --- /dev/null +++ b/ArmoredCar/ArmoredCar/MyMapWooden.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace ArmoredCar +{ + internal class MyMapWooden : AbstractMap + { + /// + /// Цвет участка закрытого + /// + private readonly Brush barrierTreeColor = new SolidBrush(Color.LightGreen); + /// + /// Цвет участка открытого + /// + private readonly Brush roadColor = new SolidBrush(Color.Brown); + protected override void DrawBarrierPart(Graphics g, int i, int j) + { + g.FillRectangle(barrierTreeColor, i * _size_x, j * _size_y, _size_x * 2, _size_y * 2); + } + protected override void DrawRoadPart(Graphics g, int i, int j) + { + g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x * 2, _size_y * 2 ); + } + protected override void GenerateMap() + { + _map = new int[50, 50]; + _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 < 25) + { + int x = _random.Next(0, 50); + int y = _random.Next(0, 50); + if (_map[x, y] == _freeRoad) + { + _map[x, y] = _barrier; + counter++; + } + } + } + } +}