Небольшие изменения в своей карте

This commit is contained in:
Алина Батылкина 2022-10-24 21:53:32 +04:00
parent 822e544eee
commit ca2069d1e2
3 changed files with 20 additions and 8 deletions

View File

@ -172,7 +172,7 @@
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта",
"Карта океана с островами",
"Карта океана с рифами",
"Карта речки c камнями"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(19, 33);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";

View File

@ -34,7 +34,7 @@ namespace WarmlyShip
case "Простая карта":
map = new SimpleMap();
break;
case "Карта океана с островами":
case "Карта океана с рифами":
map = new OceanMap();
break;
case "Карта речки c камнями":

View File

@ -14,7 +14,7 @@ namespace WarmlyShip
/// <summary>
/// Цвет участка закрытого
/// </summary>
private readonly Brush barrierColor = new SolidBrush(Color.DarkGray);
private readonly Brush barrierColor = new SolidBrush(Color.DarkGreen);
/// <summary>
/// Цвет участка открытого
/// </summary>
@ -22,11 +22,11 @@ namespace WarmlyShip
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)
{
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
g.FillRectangle(roadColor, (i * _size_x) - 1, (j * _size_y) - 1, i * (_size_x + 1), j * (_size_y + 1));
}
protected override void GenerateMap()
{
@ -45,10 +45,22 @@ namespace WarmlyShip
{
int x = _random.Next(0, 100);
int y = _random.Next(0, 100);
if (_map[x, y] == _freeRoad)
if (x + 2 < 100 && y + 2 < 100)
{
_map[x, y] = _barrier;
counter++;
if (_map[x, y] == _freeRoad && _map[x, y + 1] == _freeRoad && _map[x, y + 2] == _freeRoad && _map[x + 1, y] == _freeRoad && _map[x + 1, y + 1] == _freeRoad
&& _map[x + 1, y + 2] == _freeRoad && _map[x + 2, y] == _freeRoad && _map[x + 2, y + 1] == _freeRoad && _map[x + 2, y + 2] == _freeRoad)
{
_map[x, y] = _barrier;
_map[x, y + 1] = _barrier;
_map[x, y + 2] = _barrier;
_map[x + 1, y] = _barrier;
_map[x + 1, y + 1] = _barrier;
_map[x + 1, y + 2] = _barrier;
_map[x + 2, y] = _barrier;
_map[x + 2, y + 1] = _barrier;
_map[x + 2, y + 2] = _barrier;
counter++;
}
}
}
}