Exemplo n.º 1
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        // ** Boss battle button **

        if (coll.gameObject.tag == "Button")
        {
            buttonController.ButtonDespawn();
        }

        // ** Find out if the player is on the ground **
        if (coll.gameObject.tag == "Ground" || coll.gameObject.tag == "MovingPlatform" || coll.gameObject.tag == "RotatingPlatform" || coll.gameObject.tag == "WallCollider")
        {
            grounded = true;
        }

        // ** Taking damage from enemies and hazards **

        if (coll.gameObject.tag == "Spike" && currentLives == 3 || coll.gameObject.tag == "Enemy" && currentLives == 3 || coll.gameObject.tag == "Destroyplayer" && currentLives == 3)
        {
            PlayerPrefs.SetInt("currentLives", 2);

            SoundManager.instance.PlaySingle(dmgSound);
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }
        else if (coll.gameObject.tag == "Spike" && currentLives == 2 || coll.gameObject.tag == "Enemy" && currentLives == 2 || coll.gameObject.tag == "Destroyplayer" && currentLives == 2)
        {
            PlayerPrefs.SetInt("currentLives", 1);
            currentLives = PlayerPrefs.GetInt("currentLives");
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }
        else if (coll.gameObject.tag == "Spike" && currentLives == 1 || coll.gameObject.tag == "Enemy" && currentLives == 1 || coll.gameObject.tag == "Destroyplayer" && currentLives == 1)
        {
            PlayerPrefs.SetInt("currentLives", 0);
            currentLives = PlayerPrefs.GetInt("currentLives");
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }
        else if (coll.gameObject.tag == "Spike" && currentLives == 0 || coll.gameObject.tag == "Enemy" && currentLives == 0 || coll.gameObject.tag == "Destroyplayer" && currentLives == 0)
        {
            PlayerPrefs.SetInt("currentLives", 3);
            SceneManager.LoadScene("KitchenOverWorld");
            backgroundSounds.Stop();
            //GameObject audioControllerObject = GameObject.FindWithTag("SoundManager");
            //audioControllerObject.GetComponent<AudioSource> ().Stop ();
        }
    }
Exemplo n.º 2
0
 void Delay()
 {
     buttonController.ButtonDespawn();
 }