Exemple #1
0
        // Pathable

        public void FixPaths()
        {
            for (int i = 0; i < 6; ++i)
            {
                if (NeighborTiles[i] == null)
                {
                    continue;
                }
                // There is a disconnected path.
                if (Configuration.GetPathOverlay(i) != TilePathOverlay.NONE &&
                    NeighborTiles[i].Configuration.GetPathOverlay((i + 3) % 6) == TilePathOverlay.NONE)
                {
                    // Find other tiles disconnected path.
                    var p         = Configuration.GetPathOverlay(i);
                    var otherPath = GetDisconntedNeighbor(p);
                    // Connect them.
                    if (otherPath != null)
                    {
                        SetPathOverlay(i, TilePathOverlay.NONE);
                        SetPathOverlay(otherPath.Item1, p);

                        NeighborTiles[i].SetPathOverlay(otherPath.Item2, TilePathOverlay.NONE);
                        NeighborTiles[i].SetPathOverlay((otherPath.Item1 + 3) % 6, p);
                    }
                    // Could not find another path.
                    else
                    {
                        // Continue in tile on edge.
                        if (NeighborTiles[i].NeighborTiles.Any(j => j == null))
                        {
                            NeighborTiles[i].SetPathOverlay((i + 3) % 6, p);
                            NeighborTiles[i].ContinuePath((i + 3) % 6);
                        }
                        // Otherwise shorten.
                        else
                        {
                            Configuration.SetPathOverlay(i, TilePathOverlay.NONE);
                        }
                    }
                }
            }
        }