Ejemplo n.º 1
0
    IEnumerator LoseTime()
    {
        while (!isPaused)
        {
            yield return(new WaitForSeconds(0.5f));

            ScoreKeeper.timeLeft--;
            if (ScoreKeeper.timeLeft == 100)
            {
                bgMusic.LowTime();
            }

            if (ScoreKeeper.timeLeft == 0)
            {
                ScoreKeeper.livesLeft -= 1;
                SoundFXScript.playDeathSound();
                yield return(new WaitForSeconds(3));

                LevelManager.ReloadScene();
            }

            // Stops timer when player finishes level or dies
            if (ScoreKeeper.isFinished || ScoreKeeper.isDead)
            {
                ScoreKeeper.isFinished = false;
                ScoreKeeper.isDead     = false;
                yield break;
            }
        }

        while (isPaused)
        {
            yield return(null);
        }
    }
Ejemplo n.º 2
0
    public IEnumerator DIE()
    {
        if (bonus == false)
        {
            health = health - 1;
            ScoreKeeper.livesLeft = health;
            Power_up.power_type   = 0;
        }

        if (health >= 1)
        {
            if (!gameObject.name.Contains("BonusExit"))
            {
                SoundFXScript.playDeathSound();
                yield return(new WaitForSeconds(3));
            }
            ScoreKeeper.resetTimer();
            Application.LoadLevel(respawn);
            yield return(null);
        }
        if (health <= 0)
        {
            yield return(new WaitForSeconds(3));

            LoadLevelScript.loadNewGame();
            Application.LoadLevel(DEAD);
            yield return(null);
        }
    }