///<doc>An array containing every Cell in the grid, with the same coordinates as it has on the grid</doc> private void Start() { gridSizeX = MazeProperties.MazeWidth; gridSizeY = MazeProperties.MazeHeight; foreach (Transform wall in outerWalls) { GenerateOuterWall(wall); } string mazeGenerationAlgorithm = MazeProperties.MazeGenerationAlgorithm; if (mazeGenerationAlgorithm.Equals("Binary Tree")) { BinaryTreeAlgorithm algorithm = gameObject.AddComponent <BinaryTreeAlgorithm>(); algorithm.GenerateMaze(cellGameObject, gridSizeX, gridSizeY); } else if (mazeGenerationAlgorithm.Equals("Sidewinder")) { SidewinderAlgorithm algorithm = gameObject.AddComponent <SidewinderAlgorithm>(); algorithm.GenerateMaze(cellGameObject, gridSizeX, gridSizeY); } else if (mazeGenerationAlgorithm.Equals("Recursive Backtracking")) { RecursiveBacktrackingAlgorithm algorithm = gameObject.AddComponent <RecursiveBacktrackingAlgorithm>(); algorithm.GenerateMaze(cellGameObject, gridSizeX, gridSizeY); } }
void UseAlgorithmFromInput(int value) { switch (value) { case 0: // Hunt and Kill hek = new HuntAndKillAlgorithm(); //reset hek.ResetHuntAndKill(grid, this, rows, columns); //Hunt and kill algorithm hek.HuntAndKill(); break; case 1: //Recursive Backtracking rb = new RecursiveBacktrackingAlgorithm(); rb.ResetRecursiveBacktracking(grid, this, rows, columns); rb.RecursiveBacktracking(); break; default: break; } }
private void InitializeGame() { // Display text gameInfo.transform.position = new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.9f, 0f); gameInfo.text = ""; scoreInfo.transform.position = new Vector3((float)Screen.width * 0.85f, (float)Screen.height * 0.5f, 0f); scoreInfo.text = "Score\n" + score; // Game gameOver = false; win = false; // Maze maze = new Maze(rows, columns, wallObject, destructibleWallObject); walls = maze.getWalls(); MazeAlgorithm ma = new RecursiveBacktrackingAlgorithm(walls); ma.CreateMaze(); // Update NavMesh surface.BuildNavMesh(); // Player player = new Player(); // Camera camera = GameObject.Find("Main Camera"); camera.transform.position = new Vector3(0f, 10f, -3f); camera.transform.rotation = Quaternion.Euler(new Vector3(60f, 0f, 0f)); cameraOffset = camera.transform.position - player.player.transform.position; // Enemies enemies = new Enemy[enemyNumber]; for (int i = 0; i < enemyNumber; i++) { enemies[i] = new Enemy(enemyObject, i); } // Coins coins = new List <Coin>(); for (int i = 0; i < coinNumber; i++) { coins.Add(new Coin(i)); } // Score score = 0; }
// Selects the appropriate algorithm based on the options selected in the webplayer (unimplemented) and creates the maze public void LaunchMazeAlgorithm(string selectedAlgorithm, WaitForSeconds delay) // this should be part of the maze manager class! { switch (selectedAlgorithm) { case "RecursvieBacktracking": break; case "HuntAndKill": break; case "RecursiveDivision": break; } RecursiveBacktrackingMaze = new RecursiveBacktrackingAlgorithm(Cells); // add code to deal with selecting the appropriate algorithm for when multiple //HuntAndKillMaze = new HuntAndKillAlgorithm(Cells); -- address issues in class RecursiveBacktrackingMaze.CreateMaze(); // maze classes are available }