//function that is called that instantiates all of the entities in the game private void BeginGame() { mazeInstance = Instantiate(mazePrefab) as Maze; //yield return StartCoroutine(mazeInstance.Generate()); //StartCoroutine starts an internal clock determins the time it takes to create the map mazeInstance.Generate(); playerInstance = Instantiate(playerPrefab) as Player; playerInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates)); for (int x = 0; x < numbBatteries; x++) { BatteriesInstance = Instantiate(BatteriesPreFab) as UsableItem; while (itemPlaced == false) { itemPlaced = BatteriesInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates)); } itemPlaced = false; } GhostInstance = Instantiate(GhostPreFab) as GhostAi; while (ghostPlaced == false) { ghostPlaced = GhostInstance.SetLocation(mazeInstance.GetCell(mazeInstance.RandomCoordinates)); } }
//function to set the ghosts is on the cell public void setGhost(GhostAi ghost) { Ghost = ghost; }