private void CreatePassage(MazeCell curCell, MazeCell neighCell, MazeDirection direction) { MazePath passage = Instantiate(this.path) as MazePath; passage.Initialize(curCell, neighCell, direction); passage = Instantiate(this.path) as MazePath; passage.Initialize(neighCell, curCell, direction.GetOpposite()); }
private void GenerateMaze() { AddTopWallPaths(); AddBottomWallPaths(); AddLeftWallPaths(); AddRightWallPaths(); while (PathsActive()) { if (while_control > MAX_ITERATIONS) { Console.WriteLine("Maximum iterations reached: wall paths"); break; } ++while_control; GrowPaths(); } while_control = 0; while (!IsComplete()) { if (while_control > MAX_ITERATIONS) { Console.WriteLine("Maximum iterations reached: branches"); break; } ++while_control; foreach (MazePath path in paths) { if (path.points.Count <= 2) { continue; } MazePath p = path.Branch(); if (PathIsClear(p.GetBranchCheckpoint(), p.direction)) { branches.Add(p); } } foreach (MazePath branch in branches) { paths.Add(branch); } branches.Clear(); while (PathsActive()) { if (while_control > MAX_ITERATIONS) { break; } ++while_control; GrowPaths(); } } }