Beispiel #1
0
    private IEnumerator LevelState()
    {
        gameOverPanel.DisableGameOverPanel();
        startTextPanel.SetActive(true);
        yield return(WaitForPlayerInitialInput());

        startTextPanel.SetActive(false);
        FindObjectOfType <AudioHandler>().PlayEffect(4);
        while (IsPlayerAlive() && !IsLevelFinished())
        {
            if (!IsGamePaused())
            {
                player.Action();
            }
            yield return(new WaitForFixedUpdate());
        }
        if (!IsPlayerAlive())
        {
            musicHandler.ChangePitch(gameOverPitch);
            StartCoroutine(gameOverPanel.Appear());
        }
        else if (IsLevelFinished())
        {
            SaveAndLoad.FinishAndSaveLevel(collectedCoins == Coin.totalCoin, collectedCoins == 0);
            player.Stop();
            yield return(new WaitForSeconds(player.timeToFinish));

            endLevelPanel.SetActive(true);
        }
        Coin.ResetTotalCoin();
        collectedCoins = 0;
    }