コード例 #1
0
    public List <Tile> GetSurroundingTiles(Tile tile)
    {
        if (!tile)
        {
            return(new List <Tile>());
        }

        List <Tile> tiles = new List <Tile>();

        // Loop through neighboring tile coordinates and add them to the current coordinates
        for (int i = 0; i < 6; ++i)
        {
            int[] neighborCoords = HexHelper.GetHexNeighborCoordinates(tile.Y % 2 == 0, i);

            Tile t = tileGrid.GetTile(tile.X + neighborCoords[0], tile.Y + neighborCoords[1]);
            if (t != null)
            {
                tiles.Add(t);
            }
        }

        return(tiles);
    }