Beispiel #1
0
    public void CellsInRange(ref HexCell center, int range, List <HexCell> neighbours)
    {
        //Return tiles rnage steps from center, http://www.redblobgames.com/grids/hexagons/#range

        for (int dx = -range; dx <= range; dx++)
        {
            for (int dy = Mathf.Max(-range, -dx - range); dy <= Mathf.Min(range, -dx + range); dy++)
            {
                var o = new HexCubeCoordinate(dx, dy, -dx - dy) + center.coordinates;
                if (grid.TryGetValue(o.ToString(), out var cell))
                {
                    neighbours.Add(cell);
                }
            }
        }
    }
Beispiel #2
0
 public void CellAt(ref HexCubeCoordinate coordinate, out HexCell cell)
 {
     grid.TryGetValue(coordinate.ToString(), out cell);
 }