55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AirplaneWithRadar
|
|
{
|
|
internal class MyMap : AbstractMap
|
|
{
|
|
/// <summary>
|
|
/// Цвет участка закрытого
|
|
/// </summary>
|
|
private readonly Brush barrierColor = new SolidBrush(Color.Brown);
|
|
/// <summary>
|
|
/// Цвет участка открытого
|
|
/// </summary>
|
|
private readonly Brush roadColor = new SolidBrush(Color.BlueViolet);
|
|
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
|
{
|
|
g.FillRectangle(barrierColor, 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 < 20)
|
|
{
|
|
int x = _random.Next(0, _map.GetLength(0));
|
|
int y = _random.Next(0, _map.GetLength(1));
|
|
int len = _random.Next(3, 10);
|
|
for (int i = x; i < _map.GetLength(0) && i < len + x; i++)
|
|
{
|
|
|
|
_map[i, y] = _barrier;
|
|
}
|
|
counter++;
|
|
}
|
|
}
|
|
}
|
|
}
|