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); }
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); }