private IEnumerator BeginGame() { mazeInstance = Instantiate(mazePrefab) as Maze; yield return(StartCoroutine(mazeInstance.Generate())); inGameCanvasInstance = Instantiate(inGameCanvasPrefab) as Canvas; Destroy(GameObject.Find("Camera")); playerInstance = Instantiate(playerPrefab) as Player; playerInstance.SetLocation(mazeInstance.GetCell(mazeInstance.startCoords)); yield return(0); endInstance = Instantiate(endPrefab) as End; endInstance.SetLocation(mazeInstance.GetCell(mazeInstance.endCoords)); yield return(0); trapInstance = Instantiate(trapPrefab) as Traps; trapInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates)); yield return(0); cupInstance = Instantiate(cupPrefab) as Cup; cupInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates)); yield return(0); for (int i = 0; i < cheeseInstance.Length; i++) { cheeseInstance[i] = Instantiate(cheesePrefab) as Cheese; cheeseInstance[i].SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates)); } yield return(0); for (int i = 0; i < bombInstance.Length; i++) { bombInstance[i] = Instantiate(bombPrefab) as Bombs; } bombInstance[0].SetLocation(mazeInstance.GetCell(new IntVector2(0, 0))); bombInstance[1].SetLocation(mazeInstance.GetCell(new IntVector2(0, mazeInstance.size.z - 1))); bombInstance[2].SetLocation(mazeInstance.GetCell(new IntVector2(mazeInstance.size.x - 1, 0))); bombInstance[3].SetLocation(mazeInstance.GetCell(new IntVector2(mazeInstance.size.x - 1, mazeInstance.size.z - 1))); yield return(0); gameState = GameState.NewPlay; }