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");
        }
    }
Exemple #2
0
    public void Pause()
    {
        if (paused)
        {
            if (sloMo)
            {
                Time.timeScale = 0.35f;
            }
            else
            {
                Time.timeScale = 1;
            }

            spawner.spawning = true;
            paused           = false;
            pauseButton.Pause();
        }
        else
        {
            Time.timeScale   = 0;
            spawner.spawning = false;
            paused           = true;
            pauseButton.Play();
        }
    }