Пример #1
0
 public void EndLevel()
 {
     LevelEndScript.CreateEndLevelObj(UnityEngine.SceneManagement.SceneManager.GetActiveScene
                                          ().name, Completion.DIED);
     LevelEndScript.SpawnEndAnim(Color.black);
     StartCoroutine(WorldSelectBanner.AnimateValue(0f, 1f, 0.8f, null,
                                                   (float value) => {
         if (value == 1f)
         {
             UnityEngine.SceneManagement.SceneManager.LoadScene("DeathScreen");
         }
     }));
 }
Пример #2
0
    void OnCollisionEnter2D(Collision2D collider)
    {
        // Reset gravity bool if player hits a platform
        if (collider.gameObject.tag == "Platform")
        {
            //Debug.Log("Player hit a platform!");
            canChangeGravity = true;
            SoundManager.instance.PlaySingle((int)Sounds.FLOORHIT3);
        }

        // Damage player
        if (collider.gameObject.tag == "Damage")
        {
            SoundManager.instance.PlaySingle((int)Sounds.DAMAGE);
            Debug.Log("Player took damage");
            hit = true;
            canChangeGravity = true;
        }

        // Damage player
        if (collider.gameObject.tag == "Death")
        {
            SoundManager.instance.PlaySingle((int)Sounds.DAMAGE);
            Debug.Log("Player took damage");
            hit             = true;
            invulnerability = false;
        }

        // Player reaches the end of the level. Change level.
        if (collider.gameObject.tag == "LevelEnd")
        {
            Debug.Log("Level end point");
            //GameManager gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
            //gameManager.LoadNextLevel();
            SoundManager.instance.PlaySingle((int)Sounds.LEVELEND);
            LevelEndScript endScreen = GameObject.Find("EndScreen").GetComponent <LevelEndScript>();
            endScreen.openEndScreen();
        }

        if (collider.gameObject.tag == "GravityLock")
        {
            SoundManager.instance.PlaySingle((int)Sounds.FLOORHIT2);
            Debug.Log("Gravity locked");
            canChangeGravity = false;
        }
    }