Esempio n. 1
0
    private void RebuildMaze(VertexLinker builder)
    {
        Debug.Log("rebuilding " + builder.ToString());

        WeaveRectGrid maze = (WeaveRectGrid)target;

        maze.ClearTunnels();
        maze.Graph.ClearLinks();
        builder.Build(new WeaveRectGridLinkerHelper(maze));
        EditorUtility.SetDirty(maze);

        /*BreadthFirst bf = new BreadthFirst(maze.Graph, maze.BottomLeftVertex);
         * bf.Run();
         * int[] distances = bf.Distances;
         * float maxDistance = (float)bf.MaxDistance;
         * Color nearColor = Color.red;
         * Color farColor = Color.black;
         *
         * Color[] distanceColors = System.Array.ConvertAll<int, Color>(
         *  distances, distance => Color.Lerp(nearColor, farColor, (distance / maxDistance))
         * );
         * image.Draw(maze, distanceColors);*/

        image.Draw(maze);
    }
Esempio n. 2
0
        /// <summary>
        /// Removes all references of faces or vertices to the given edge
        /// </summary>
        /// <param name="edge"></param>
        private void RemoveReferences(HalfEdge edge)
        {
            // make sure origin does not point to this
            if (edge.Origin.Outgoing == edge)
            {
                VertexLinker.TryShiftOutgoing(edge.Origin);
            }

            // face might already be unlinked
            if (edge.Face == null)
            {
                return;
            }

            // make sure face does not point to this
            if (edge.Face.Start == edge)
            {
                FaceLinker.TryShiftStart(edge.Face);
            }
        }
    private void RebuildMaze(VertexLinker builder)
    {
        Debug.Log("rebuilding " + builder.ToString());

        PolarGrid maze = (PolarGrid)target;

        maze.Graph.ClearLinks();
        builder.Build(new VertexLinkerHelper(maze.Graph, maze.AdjacentGraph));
        EditorUtility.SetDirty(maze);

        BreadthFirst bf = new BreadthFirst(maze.Graph, 0);

        bf.Run();
        int[] distances   = bf.Distances;
        float maxDistance = (float)bf.MaxDistance;
        Color nearColor   = Color.red;
        Color farColor    = Color.black;

        Color[] distanceColors = System.Array.ConvertAll <int, Color>(
            distances, distance => Color.Lerp(nearColor, farColor, (distance / maxDistance))
            );
        image.Draw(maze, distanceColors);
    }