/* * Whenever something collides with the player, this method isn't used anymore because * the collider on the player was changed to a trigger. */ void OnCollisionEnter2D(Collision2D col) { if (col.collider.tag == Tags.Ball) { FindObjectOfType <AudioManager>().Play(Audio.Ouch); if (lives < 1) { Debug.Log("HIT!"); manager.ChangeLevel(Levels.Levels_Menu); // So any time the player dies, they get redirected back to the levels menu. } lives--; } }
// Update is called once per frame void Update() { bubbles = GameObject.FindGameObjectsWithTag(Tags.Ball); // Find all of the bubbles in the scene. if (bubbles.Length < 1) // If there are no bubbles left, count the score. { CountScore(); manager.ChangeLevel(Levels.Levels_Menu); // Load the levels menu. } /* * Update the scoreboard UI. */ timeLeft -= Time.deltaTime; timeLeftUI.gameObject.GetComponent <Text>().text = "Time Left: " + (int)timeLeft; playerScoreUI.gameObject.GetComponent <Text>().text = "Lives: " + BubbleMove.lives; if (timeLeft < 0.1f) // If the time runs out. { SceneManager.LoadScene(Levels.Levels_Menu); // Reload the levels menu. } if (isOver == true) { Debug.Log((int)timeLeft); CountScore(); isOver = false; } }
public void MainMenu() { if (IsPaused == true) { IsPaused = false; // Set the IsPaused variable to false so that is the user goes to main menu then exits the game, the level will start as normal next time around. pauseMenuUI.SetActive(false); // De-activate the pause menu. Time.timeScale = 1f; // Return the time scale to normal(1 second at a time). manager.ChangeLevel(Levels.Main_Menu); // Use the level manager to change the view to the main menu. } }
IEnumerator Start() // Use IEnumerator so we can use a co routine. { manager = new LevelsManager(); splashImage.canvasRenderer.SetAlpha(0.0f); // When the scene starts, make the image invisible. FadeIn(); // Wall fade in. yield return(new WaitForSeconds(3.5f)); // Wait 3.5 seconds. FadeOut(); // Call fade out. manager.ChangeLevel(Levels.Main_Menu); // Then load the main menu scene. }
public void Return() { //Return to main menu levelManager.ChangeLevel(Levels.Main_Menu);// Change level when this method is triggered. }
public void PlayGame() { levelManager.ChangeLevel(Levels.Levels_Menu);// Change level when this method is triggered. }
void SwitchScene(string sceneName) // Delegate the navigation of levels to its own method. { levelManager.ChangeLevel(sceneName); // Change scene when this method is triggered. }
private void Play() { manager.ChangeLevel(Levels.Levels_Menu); }