public Intersection[] GetAllIntersections()
{
if (allIntersections == null)
{
List <Intersection> result = new List <Intersection>(22);
for (int r = 0; r < 7; r++)
{
for (int c = 0; c < Board.GetRowLength(r); c++)
{
Intersection south = null;
Intersection southeast = null;
if (r % 2 == 0)
{
if (r + 1 < 7 && c + 1 < Board.GetRowLength(r + 1))
{
south = new Intersection(GetTerrainIndex(r, c), GetTerrainIndex(r + 1, c), GetTerrainIndex(r + 1, c + 1));
}
if (r + 1 < 7 && c + 1 < Board.GetRowLength(r))
{
southeast = new Intersection(GetTerrainIndex(r, c), GetTerrainIndex(r, c + 1), GetTerrainIndex(r + 1, c + 1));
}
}
else
{
if (r + 1 < 7 && c - 1 >= 0 && c < 6)
{
south = new Intersection(GetTerrainIndex(r, c), GetTerrainIndex(r + 1, c - 1), GetTerrainIndex(r + 1, c));
}
if (r + 1 < 7 && c < 6)
{
southeast = new Intersection(GetTerrainIndex(r, c), GetTerrainIndex(r, c + 1), GetTerrainIndex(r + 1, c));
}
}
if (south != null && (GetTile(south.FirstTile).Terrain != Terrain.Water || GetTile(south.SecondTile).Terrain != Terrain.Water))
{
result.Add(south);
}
if (southeast != null && (GetTile(southeast.FirstTile).Terrain != Terrain.Water || GetTile(southeast.SecondTile).Terrain != Terrain.Water))
{
result.Add(southeast);
}
}
}
allIntersections = result.ToArray();
}
return(allIntersections.ToArray());
}