Esempio n. 1
0
    void Update()
    {
        //if we've reached the level bottom by breaking through the gates
        if (player != null && player.position.y < lowestPoint && !done)
        {
            done = true;

            camMovement.yOffset = 2;

            gameOver.SetTrigger("Show");

            //show diamond count and save the new diamonds
            int score = manager.GetScore();
            gameOverDiamonds.text = "+" + score;
            PlayerPrefs.SetInt("Diamonds", PlayerPrefs.GetInt("Diamonds") + score);

            diamondsAnim.SetTrigger("Show");

            //unlock next level
            PlayerPrefs.SetInt("Level", PlayerPrefs.GetInt("Level") + 1);

            //show confetti
            FinishLine finish = GameObject.FindObjectOfType <FinishLine>();
            StartCoroutine(finish.Confetti());

            //disable the game panel and play some sound
            manager.gameOver = true;
            manager.gamePanel.SetBool("Show", false);
            manager.win.Play();

            //if the powerup was active, deactivate it
            Player  player  = GameObject.FindObjectOfType <Player>();
            Powerup powerup = GameObject.FindObjectOfType <Powerup>();

            if (player.bullet)
            {
                powerup.DisableBullet();
            }
        }
    }