public void SetGameover() { //Set the GameState gameState = GameState.GAMEOVER; //Manage Canvas Groups EnableCG(MENU_CG); DisableCG(GAME_CG); DisableCG(GAMEOVER_CG); //Delete all the objects foreach (GameObject g in GameObject.FindGameObjectsWithTag("Box")) { Destroy(g); } foreach (GameObject g in GameObject.FindGameObjectsWithTag("Snake")) { Destroy(g); } foreach (GameObject g in GameObject.FindGameObjectsWithTag("SimpleBox")) { Destroy(g); } foreach (GameObject g in GameObject.FindGameObjectsWithTag("Bar")) { Destroy(g); } //Spawn the new body parts SM.SpawnBodyParts(); //Reset the previous snake pos to spawn barrier correctly BM.SetPreviousSnakePosAfterGameover(); //Reset the Speed speedAdded = false; SM.speed = 3; //Save the Best Score PlayerPrefs.SetInt("BESTSCORE", BESTSCORE); //Reset the Simple Blocks List BM.SimpleBoxPositions.Clear(); //Increase AdMob Counter AdManager.gameoverCounter++; }
void destroyScence() { //Delete all the objects foreach (GameObject g in GameObject.FindGameObjectsWithTag("Box")) { Destroy(g); } foreach (GameObject g in GameObject.FindGameObjectsWithTag("Snake")) { Destroy(g); } foreach (GameObject g in GameObject.FindGameObjectsWithTag("SimpleBox")) { Destroy(g); } foreach (GameObject g in GameObject.FindGameObjectsWithTag("Bar")) { Destroy(g); } //Spawn the new body parts SM.SpawnBodyParts(); //Reset the previous snake pos to spawn barrier correctly BM.SetPreviousSnakePosAfterGameover(); //Reset the Speed speedAdded = false; SM.speed = 3; // Saving a saved game. MONEY += SCORE; PlayerPrefs.SetInt("MONEY", MONEY); PlayerPrefs.SetInt("BESTSCORE", BESTSCORE); //Reset the Simple Blocks List BM.SimpleBoxPositions.Clear(); }