1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
namespace Assets.Scripts.Utils
{
public enum TileType
{
Default,
Wall,
Background
}
public class Map
{
#region Fields
public uint Columns { get; set; }
public uint Rows { get; set; }
private TileType[,] _map;
#endregion
#region Ctors
public Map(uint cols, uint rows)
{
Columns = cols;
Rows = rows;
_map = new TileType[Columns, Rows];
for (int x = 0; x < _map.GetLength(0); x++)
{
for (int y = 0; y < _map.GetLength(1); y++)
{
_map[x, y] = TileType.Default;
}
}
}
#endregion
public TileType this[uint x, uint y]
{
get { return _map[x, y]; }
set { _map[x, y] = value; }
}
public override string ToString()
{
string ret = "";
for (int y = 0; y < Rows; y++)
{
for (int x = 0; x < Columns; x++)
{
ret += _map[x, y] + " ";
}
ret += "\n";
}
return ret;
}
}
}