Исправление карты

This commit is contained in:
Katerina881 2022-10-06 12:29:35 +04:00
parent 93af5d6e5a
commit 2308895805

View File

@ -22,7 +22,7 @@ namespace AirplaneWithRadar
protected override void DrawBarrierPart(Graphics g, int i, int j) protected override void DrawBarrierPart(Graphics g, int i, int j)
{ {
g.FillEllipse(barrierColor, i * (_size_x - 1), j * (_size_y - 1), 40, 24); 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) protected override void DrawRoadPart(Graphics g, int i, int j)
{ {
@ -41,16 +41,33 @@ namespace AirplaneWithRadar
_map[i, j] = _freeRoad; _map[i, j] = _freeRoad;
} }
} }
while (counter < 15) while (counter < 10)
{ {
int x = _random.Next(0, 100); int x = _random.Next(0, 100);
int y = _random.Next(0, 100); int y = _random.Next(0, 100);
if (_map[x, y] == _freeRoad) if (x - 2 >=0 && y + 4 < 100 && x + 2 < 100)
{
if (_map[x, y] == _freeRoad && _map[x + 1, y + 1] == _freeRoad && _map[x - 1, y + 1] == _freeRoad && _map[x, y + 2] == _freeRoad && _map[x, y + 1] == _freeRoad
&& _map[x + 2, y + 2] == _freeRoad && _map[x - 2, y + 2] == _freeRoad && _map[x + 1, y + 3] == _freeRoad && _map[x - 1, y + 3] == _freeRoad
&& _map[x, y + 3] == _freeRoad && _map[x, y + 4] == _freeRoad && _map[x + 1, y + 2] == _freeRoad && _map[x - 1, y + 2] == _freeRoad)
{ {
_map[x, y] = _barrier; _map[x, y] = _barrier;
_map[x + 1, y + 1] = _barrier;
_map[x - 1, y + 1] = _barrier;
_map[x + 2, y + 2] = _barrier;
_map[x - 2, y + 2] = _barrier;
_map[x, y + 2] = _barrier;
_map[x, y + 1] = _barrier;
_map[x + 1, y + 3] = _barrier;
_map[x - 1, y + 3] = _barrier;
_map[x, y + 3] = _barrier;
_map[x, y + 4] = _barrier;
_map[x + 1, y + 2] = _barrier;
_map[x - 1, y + 2] = _barrier;
counter++; counter++;
} }
} }
} }
} }
} }
}