Merge branch 'hex' into SquareMap

This commit is contained in:
2020-12-10 20:14:40 -07:00
2 changed files with 34 additions and 3 deletions

View File

@@ -1,7 +1,20 @@
namespace ConsoleApp using System;
using System.Collections.Generic;
namespace ConsoleApp.Maps
{ {
public struct HexCell public struct HexCell
{ {
public int Q { get; }
public int R { get; }
public int S { get; }
public HexCell(int q, int r, int s)
{
if (q + r + s != 0) throw new ArgumentException("q + r + s must be 0");
Q = q;
R = r;
S = s;
}
} }
} }

View File

@@ -1,7 +1,25 @@
using System;
using System.Collections.Generic;
namespace ConsoleApp.Maps namespace ConsoleApp.Maps
{ {
public class HexMap public class HexMap
{
private HexCell[,] Map { get; }
public HexMap(int x, int y)
{
for (int r = 0; r < y; r++) {
int r_offset = Convert.ToInt32(Math.Floor(Convert.ToDouble(r)/2));
for (int q = -r_offset; q < x - r_offset; q++) {
Map[r, q] = new HexCell(q, r, -q-r);
}
}
}
public List<HexCell> PossibleMoves(HexCell fromCell, Direction direction, Double orientation)
{ {
} }
} }
}