Ejemplo n.º 1
0
        /// Creates vertex that corresponds to Tile if Tile is not null.
        /// Gets all availabile neighbouring tiles of this Tile.
        /// Connects the Vertex of the current Tile with the vertex of each available (for building) neighbouring Tile
        /// if they aren't already connected. This is done by adding an Edge between them.
        public void CreateGraph(BaseTile tile)
        {
            if (tile == null)
            {
                return;
            }
            tile.CreateVertex();

            List <BaseTile> neighbours = GameWorld.Instance.GetAvailableNeighbours(tile);

            foreach (BaseTile neighbour in neighbours)
            {
                if (tile.IsConnected(neighbour))
                {
                    continue;
                }
                neighbour.CreateVertex();
                AddEdge(tile, neighbour, cost);
            }
        }