Exemplo n.º 1
0
    public IEnumerator Death()
    {
        gamePaused            = true;
        playerBall.gamePaused = true;
        pauseButton.Pause();
        if (currentLives > 0)
        {
            //Play Death Sound and Animation
            UpDateLives(-1);
            audioSource.PlayOneShot(death);
            playerAnim.Play("teleportOut");
            levelSpawner.gameGrid.AnimateTileDeath();
            yield return(new WaitForSeconds(death.length + 0.90f));

            levelSpawner.ReloadLevel();
        }
        else
        {
            //GameOver
            //Fade in GameOver Text!
            //Load back to the Main Menu
            gameOverText.gameObject.SetActive(true);
            gameOverText.gameObject.GetComponent <Animator>().Play("gameOver");
            audioSource.PlayOneShot(gameOver);
            playerAnim.Play("teleportOut");
            levelSpawner.gameGrid.AnimateTileDeath();
            yield return(new WaitForSeconds(gameOver.length + 0.90f));

            SceneManager.LoadScene("MainMenu");
        }
    }