change MyMap and rename buttons
This commit is contained in:
parent
c60f61ba18
commit
d9446d1c46
4
AirFighter/AirFighter/FormMap.Designer.cs
generated
4
AirFighter/AirFighter/FormMap.Designer.cs
generated
@ -51,7 +51,7 @@
|
||||
this.CreateButton.Name = "CreateButton";
|
||||
this.CreateButton.Size = new System.Drawing.Size(94, 29);
|
||||
this.CreateButton.TabIndex = 0;
|
||||
this.CreateButton.Text = "create";
|
||||
this.CreateButton.Text = "создание";
|
||||
this.CreateButton.UseVisualStyleBackColor = true;
|
||||
this.CreateButton.Click += new System.EventHandler(this.CreateButton_Click);
|
||||
//
|
||||
@ -156,7 +156,7 @@
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(148, 29);
|
||||
this.button1.TabIndex = 7;
|
||||
this.button1.Text = "create modern";
|
||||
this.button1.Text = "модификация";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.CreateModernButton_Click);
|
||||
//
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -13,6 +13,7 @@ namespace AirFighter
|
||||
/// Цвет участка закрытого
|
||||
/// </summary>
|
||||
private readonly Brush barrierColor = new SolidBrush(Color.Black);
|
||||
|
||||
/// <summary>
|
||||
/// Цвет участка открытого
|
||||
/// </summary>
|
||||
@ -27,22 +28,52 @@ namespace AirFighter
|
||||
}
|
||||
protected override void GenerateMap()
|
||||
{
|
||||
_map = new int[10, 10] {
|
||||
{ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 },
|
||||
{ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 },
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
_map = new int[100, 100];
|
||||
_size_x = (float)_width / _map.GetLength(0);
|
||||
_size_y = (float)_height / _map.GetLength(1);
|
||||
|
||||
for (int i = 0; i < _map.GetLength(0); ++i)
|
||||
{
|
||||
for (int j = 0; j < _map.GetLength(1); ++j)
|
||||
{
|
||||
_map[i, j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < 20; ++i)
|
||||
{
|
||||
int x = _random.Next(0, 100);
|
||||
int y = _random.Next(0, 100);
|
||||
|
||||
GenerateMap(x, y, _random.Next(13, 23));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void GenerateMap(int x, int y, int depth)
|
||||
{
|
||||
if (depth <= 0) return;
|
||||
bool check = false;
|
||||
|
||||
while (!check)
|
||||
{
|
||||
int deltaX = _random.Next(-1, 2);
|
||||
int deltaY = _random.Next(-1, 2);
|
||||
|
||||
if (x + deltaX < 0 || x + deltaX >= 100) continue;
|
||||
if (y + deltaY < 0 || y + deltaY >= 100) continue;
|
||||
|
||||
if (_map[y + deltaY, x + deltaX] == _barrier) depth--;
|
||||
x += deltaX;
|
||||
y += deltaY;
|
||||
|
||||
_map[y, x] = _barrier;
|
||||
|
||||
check = true;
|
||||
}
|
||||
|
||||
GenerateMap(x, y, depth - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user