PIbd-23_Lisov_N.A._AirFight.../AirFighter/NightSkyMap.cs

61 lines
1.6 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirFighter
{
internal class NightSkyMap : AbstractMap
{
Brush ThundercloudColor = new SolidBrush(Color.FromArgb(0, 0, 139));
Brush NightSkyColor = new SolidBrush(Color.Black);
protected override void DrawBarrierPart(Graphics g, int i, int j)
{
g.FillRectangle(ThundercloudColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
}
protected override void DrawRoadPart(Graphics g, int i, int j)
{
g.FillRectangle(NightSkyColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
}
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(10,90);
int y = _random.Next(10,90);
_map[x, y] = _barrier;
_map[x-1,y] = _barrier;
_map[x + 1, y] = _barrier;
_map[x,y - 1] = _barrier;
counter++;
}
}
}
}