-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathBoard.cs
56 lines (48 loc) · 1.57 KB
/
Board.cs
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
using HexBoardGame.SharedData;
namespace HexBoardGame.Runtime.GameBoard
{
/// <summary>
/// A board is composed by positions that, by themselves, contain a HexCoordinate.
/// Positions may store the game data. Things like monsters, itens, heroes, etc.
/// </summary>
public class Board : IBoard
{
public Board(BoardController controller, BoardDataShape dataShape, Orientation orientation)
{
Orientation = orientation;
DataShape = dataShape;
Controller = controller;
GeneratePositions();
}
private BoardController Controller { get; }
public BoardDataShape DataShape { get; }
public Orientation Orientation { get; }
public Position[] Positions { get; private set; }
public bool HasPosition(Hex point)
{
return GetPosition(point) != null;
}
public Position GetPosition(Hex point)
{
foreach (var i in Positions)
if (i.Point == point)
return i;
return null;
}
private void GeneratePositions()
{
var points = DataShape.GetHexPoints();
Positions = new Position[points.Length];
for (var index = 0; index < points.Length; index++)
{
var i = points[index];
Positions[index] = new Position(i);
}
OnCreateBoard();
}
private void OnCreateBoard()
{
Controller.DispatchCreateBoard(this);
}
}
}