ajout du boardlayout et de la commande getmatch
This commit was merged in pull request #8.
This commit is contained in:
@@ -1,16 +1,41 @@
|
||||
|
||||
namespace Giants.Infrastructure;
|
||||
|
||||
using Giants.Core;
|
||||
using Giants.Core.Interfaces;
|
||||
|
||||
using HexagonalLib;
|
||||
using HexagonalLib.Coordinates;
|
||||
|
||||
public class HexagonalGridImpl : IHexagonalGrid
|
||||
{
|
||||
private readonly HexagonalGrid _grid;
|
||||
private HexagonalGrid _grid;
|
||||
|
||||
public HexagonalGridImpl()
|
||||
/// <inheritdoc/>
|
||||
public void Init(IHexagonalGrid.HexStyle style = IHexagonalGrid.HexStyle.PointyOdd)
|
||||
{
|
||||
_grid = new HexagonalGrid(HexagonalGridType.PointyEven, 1.0f);
|
||||
_grid = new HexagonalGrid(ConvertGridType(style), 1.0f);
|
||||
}
|
||||
|
||||
public ICollection<AxialCoords> GetNeighbours(AxialCoords coords)
|
||||
{
|
||||
var result = new List<AxialCoords>();
|
||||
foreach (var hex in _grid.GetNeighbors(new Axial(coords.Q, coords.R)))
|
||||
{
|
||||
result.Add(new AxialCoords(hex.Q, hex.R));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private HexagonalGridType ConvertGridType(IHexagonalGrid.HexStyle style)
|
||||
{
|
||||
return style switch
|
||||
{
|
||||
IHexagonalGrid.HexStyle.PointyEven => HexagonalGridType.PointyEven,
|
||||
IHexagonalGrid.HexStyle.FlatEven => HexagonalGridType.FlatEven,
|
||||
IHexagonalGrid.HexStyle.PointyOdd => HexagonalGridType.PointyOdd,
|
||||
IHexagonalGrid.HexStyle.FlatOdd => HexagonalGridType.FlatOdd,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(style), $"Unexpected grid style : {style}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user