public IMazeGenerator GetGenerator(MazeGenerationAlgorithm algorithm, IMap map, Random rng = null) { switch (algorithm) { case MazeGenerationAlgorithm.GrowingTree: return(new GrowingTreeMazeGenerator(map, rng)); case MazeGenerationAlgorithm.Kruskal: return(new KruskalMazeGenerator(map, rng)); case MazeGenerationAlgorithm.RecursiveDivision: return(new RecursiveDivisionMazeGenerator(map, rng)); case MazeGenerationAlgorithm.BinaryTree: return(new BinaryTreeMazeGenerator(map, rng)); case MazeGenerationAlgorithm.AldousBroder: return(new AldousBroderMazeGenerator(map, rng)); default: throw new ArgumentOutOfRangeException(nameof(algorithm), algorithm, null); } }
public void aaa(int Columns, int Rows, bool FullRandom, int RandomSeed, MazeGenerationAlgorithm Algorithm, BasicMazeGenerator mazeGenerator, float CellWidth, float CellHeight, bool AddGaps, GameObject Floor, GameObject Wall, GameObject Pillar, GameObject goalPrefabs) { if (!FullRandom) { Random.seed = RandomSeed; } switch (Algorithm) { case MazeGenerationAlgorithm.PureRecursive: mMazeGenerator = new RecursiveMazeGenerator(Rows, Columns); break; case MazeGenerationAlgorithm.RecursiveTree: mMazeGenerator = new RecursiveTreeMazeGenerator(Rows, Columns); break; case MazeGenerationAlgorithm.RandomTree: mMazeGenerator = new RandomTreeMazeGenerator(Rows, Columns); break; case MazeGenerationAlgorithm.OldestTree: mMazeGenerator = new OldestTreeMazeGenerator(Rows, Columns); break; case MazeGenerationAlgorithm.RecursiveDivision: mMazeGenerator = new DivisionMazeGenerator(Rows, Columns); break; } mMazeGenerator.GenerateMaze(); for (int row = 0; row < Rows; row++) { for (int column = 0; column < Columns; column++) { float x = column * (CellWidth + (AddGaps ? .2f : 0)); float z = row * (CellHeight + (AddGaps ? .2f : 0)); MazeCell cell = mMazeGenerator.GetMazeCell(row, column); GameObject tmp; tmp = Instantiate(Floor, new Vector3(x, 0, z), Quaternion.Euler(0, 0, 0)) as GameObject; tmp.transform.parent = transform; if (cell.WallRight) { tmp = Instantiate(Wall, new Vector3(x + CellWidth / 2, 0, z) + Wall.transform.position, Quaternion.Euler(0, 90, 0)) as GameObject;// right tmp.transform.parent = transform; } if (cell.WallFront) { tmp = Instantiate(Wall, new Vector3(x, 0, z + CellHeight / 2) + Wall.transform.position, Quaternion.Euler(0, 0, 0)) as GameObject;// front tmp.transform.parent = transform; } if (cell.WallLeft) { tmp = Instantiate(Wall, new Vector3(x - CellWidth / 2, 0, z) + Wall.transform.position, Quaternion.Euler(0, 270, 0)) as GameObject;// left tmp.transform.parent = transform; } if (cell.WallBack) { tmp = Instantiate(Wall, new Vector3(x, 0, z - CellHeight / 2) + Wall.transform.position, Quaternion.Euler(0, 180, 0)) as GameObject;// back tmp.transform.parent = transform; } if (cell.IsGoal && GoalPrefab != null) { tmp = Instantiate(GoalPrefab, new Vector3(x, 1, z), Quaternion.Euler(0, 0, 0)) as GameObject; tmp.transform.parent = transform; } } } if (Pillar != null) { for (int row = 0; row < Rows + 1; row++) { for (int column = 0; column < Columns + 1; column++) { float x = column * (CellWidth + (AddGaps ? .2f : 0)); float z = row * (CellHeight + (AddGaps ? .2f : 0)); GameObject tmp = Instantiate(Pillar, new Vector3(x - CellWidth / 2, 0, z - CellHeight / 2), Quaternion.identity) as GameObject; tmp.transform.parent = transform; } } } }