IEnumerator GenerateSteps() { if (randomPosition) { startPosition = new Vector2Int(Random.Range(0, size.x), Random.Range(0, size.y)); } var growingTree = new GrowingTree(size, startPosition, nextCandidate); growingTree.OnVisit += (pos) => { blocks[pos.x, pos.y].sharedMaterial = (startPosition == pos ? startMaterial : candidateMaterial); }; growingTree.OnDeadEnd += (pos) => blocks[pos.x, pos.y].sharedMaterial = corridorMaterial; growingTree.OnCarvePassage += RemoveWall; growingTree.Start(); while (!growingTree.Finished) { growingTree.Step(); yield return(stepWait); } maze = growingTree.Maze; generator = null; btnWalk.interactable = true; btnStart.interactable = true; }
static G RandomAlgorithm <G, T>(Grid grid, Algorithm algorithm) where G : Grid where T : Cell { switch (algorithm) { case Algorithm.AldousBroder: return(AldousBroder.CreateMaze <G, T>(grid as G)); case Algorithm.BinaryTree: return(BinaryTree.CreateMaze(grid) as G); case Algorithm.HuntAndKill: return(HuntAndKill.CreateMaze <G, T>(grid as G)); case Algorithm.RecursiveBacktracker: return(RecursiveBacktracker.CreateMaze <G, T>(grid as G)); case Algorithm.Sidewinder: return(Sidewinder.CreateMaze(grid) as G); case Algorithm.Wilsons: return(Wilsons.CreateMaze <G, T>(grid as G)); case Algorithm.Kruskals: return(Kruskals.CreateMaze(grid) as G); case Algorithm.Prims: return(Prims.CreateMaze <G, T>(grid as G)); case Algorithm.TruePrims: return(TruePrims.CreateMaze <G, T>(grid as G)); case Algorithm.GrowingTree: return(GrowingTree.CreateMaze <G, T>(grid as G)); case Algorithm.RecursiveDivision: return(RecursiveDivision.CreateMaze(grid) as G); case Algorithm.Ellers: return(Ellers.CreateMaze(grid) as G); case Algorithm.Houstons: return(Houstons.CreateMaze <G, T>(grid as G)); } return(null); }
public static Dictionary <GridPosition, MazeNode> Create(EGTVariant Variant, GridPosition Origin, int Width, int Height) { GrowingTree Generator = new GrowingTree(Variant, Origin, Width, Height); Generator.BuildMaze(); return(Generator.m_NodeList); }
public void TestGrowingTreeColored() { var coloredGrid = new ColoredGrid(25, 25); GrowingTree.On(coloredGrid); coloredGrid.Distances = coloredGrid.GetCenterCell().Distances; coloredGrid.ToBitmap().Save("growingtree-colored.png"); }
public void StartGame(int inputRows, int inputCols) { size.r = inputRows; size.c = inputCols; mazeInstance = Instantiate(mazePrefab) as GrowingTree; StartCoroutine(mazeInstance.InstatiateMaze()); }
private void Generate() { Debug.Log(m_Origin.ToString()); switch (m_Algorithm) { case EMazeAlgorithm.CELLULAR_AUTOMATA: m_NodeMap = CellularAutomata.Create(m_Origin, m_Width, m_Height); break; case EMazeAlgorithm.GROWING_TREE: m_NodeMap = GrowingTree.Create(m_Origin, m_Width, m_Height); break; case EMazeAlgorithm.SIMPLE: m_NodeMap = CreateSimpleSector(); break; } }
public void TestGrowingTree() { var grid = new Grid(5, 5); GrowingTree.On(grid).ToBitmap().Save("growingtree.png"); }