Esempio n. 1
0
    IEnumerator WaitForMeltAnimation()
    {
        if (levelComplete.levelIsCompleted && !melted)
        {
            melted = true;
            if (SoundEffects.instance != null)
            {
                Debug.Log("Playing DeathWin!");
                SoundEffects.instance.DeathWin();
            }
            Debug.Log("Waiting for the animation...");
            playerController.body.constraints = RigidbodyConstraints2D.FreezeAll;
            playerController.anim.SetTrigger("Melt");
            yield return(new WaitForSeconds(playerController.meltAnimation.length));

            Debug.Log("Done waiting for the animation!");
            levelComplete.FinishLevel();
        }
        else if (!levelComplete.levelIsCompleted && !melted)
        {
            melted = true;
            if (SoundEffects.instance != null)
            {
                Debug.Log("Playing DeathWin!");
                SoundEffects.instance.DeathWin();
            }
            Debug.Log("Waiting for the animation...");
            playerController.body.constraints = RigidbodyConstraints2D.FreezeAll;
            playerController.anim.SetTrigger("Melt");
            yield return(new WaitForSeconds(playerController.meltAnimation.length));

            Debug.Log("Done waiting for the animation!");
            GameOver();
        }
    }