示例#1
0
    public List <WorldTile> GetNeighbors(WorldTile tile)
    {
        List <Vector2Int> neighborDirections = HexUtils.GetNeighborDirections(tile.LocalPlace);

        List <WorldTile> neighbors = new List <WorldTile>();

        foreach (Vector2Int direction in neighborDirections)
        {
            WorldTile currentTile;
            if (tiles.TryGetValue(new Vector3Int(tile.LocalPlace.x + direction.x, tile.LocalPlace.y + direction.y, tile.LocalPlace.z), out currentTile))
            {
                if (currentTile.IsPassable())
                {
                    neighbors.Add(currentTile);
                }
            }
        }

        return(neighbors);
    }