IEnumerator RunTimer()
    {
        float t = 0;

        while (!Finished)
        {
            if (!Paused)
            {
                int minutes = (int)(t / 60);
                int seconds = (int)(t % 60);
                Gage.fillAmount   = t / TimeLimit;
                LabelOfTimer.text = minutes.ToString("D2") + ":" + seconds.ToString("D2");

                t += Time.deltaTime;
            }

            yield return(null);
        }

        Color c = _FinishedFade.color;

        c.a = 0.5f;
        _FinishedFade.color = c;
        AudioManager.Instance.Play("TimeRanOut");
        yield return(new WaitForSeconds(0.5f));

        //make sure the player isn't able to hit stuff anymore
        BlobInputProcessing.SetState(false);
        yield return(new WaitForSeconds(1.5f));

        TimerRanOut.Invoke();
    }
Beispiel #2
0
    IEnumerator RunTimer()
    {
        TimeRemaining = TimeLimit;
        float redFade = 0;
        bool  finale  = false;

        while (TimeRemaining > 0)
        {
            if (!Paused)
            {
                int minutes = (int)(TimeRemaining / 60);
                int seconds = (int)(TimeRemaining % 60);
                Gage.fillAmount   = TimeRemaining / TimeLimit;
                LabelOfTimer.text = minutes.ToString("D2") + ":" + seconds.ToString("D2");

                if (TimeRemaining < AlmostFinishedTime)
                {
                    redFade           += Time.deltaTime / AlmostFinishedTime;
                    LabelOfTimer.color = Color.Lerp(_ColourStart, AlmostFinishedColor, redFade);

                    if (!finale)
                    {
                        AudioManager.Instance.Play("TimeRunningOut");
                        finale = true;
                    }
                }

                TimeRemaining -= Time.deltaTime;
            }

            yield return(null);
        }

        TimeRemaining = 0;
        Color c = _FinishedFade.color;

        c.a = 0.5f;
        _FinishedFade.color = c;
        AudioManager.Instance.Play("TimeRanOut");
        yield return(new WaitForSeconds(0.5f));

        //make sure the player isn't able to hit stuff anymore
        BlobInputProcessing.SetState(false);
        yield return(new WaitForSeconds(1.5f));

        TimerRanOut.Invoke();
    }
    void Start()
    {
        //turns on input processing
        BlobInputProcessing.SetState(true);

        //load highscore from file
        if (GlobalGameSettings.GetSetting("Reset Highscore").Equals("No"))
        {
            LoadHighscore();
        }
        else if (GlobalGameSettings.GetSetting("Reset Highscore").Equals(string.Empty))
        {
            if (GlobalGameSettings.GetSetting("Reset HS").Equals("No"))
            {
                LoadHighscore();
            }
        }

        //check if we have all requirements linked
        if (ScoreBarBase == null)
        {
            Debug.LogError("ScoreScreenController | Start | Missing base object for score bars.");
        }
        if (P_Scoring == null)
        {
            Debug.LogError("ScoreScreenController | Start | Missing Link to perant panel.");
        }
        if (ReplayButton == null)
        {
            Debug.LogError("ScoreScreenController | Start | Missing Link to replay button.");
        }

        if (Scores == null)
        {
            Debug.LogError("ScoreScreenController | Start | No scores have been stored in the static Scores list!");
        }
        else
        {
            int numberOf0Scores = 0;
            int highestScore    = 0;
            foreach (int score in Scores)
            {
                if (score == 0 && _Are0ScoresIgnored)
                {
                    numberOf0Scores++;
                }
                if (score > highestScore)
                {
                    highestScore = score;
                }
            }
            //safety check, if we add a level it wount be in the highscore script
            if (_Highscore.Highscores.Count - 1 < _LevelIndex)
            {
                int count = _LevelIndex + 1 - _Highscore.Highscores.Count;
                for (int index = 0; index < count; index++)
                {
                    _Highscore.Highscores.Add(0);
                }
            }
            if (Scores.Count == 0)
            {
                Debug.LogError("ScoreScreenController | Start | No scores have been stored in the static Scores list!");
                return;
            }
            else if (Scores.Count - numberOf0Scores == 1)
            {
                SetupSinglePlayer(Scores.IndexOf(highestScore));
            }
            else if (Scores.Count - numberOf0Scores > 1)
            {
                SetupMultiPlayer(highestScore);
            }
            if (highestScore > _Highscore.Highscores[_LevelIndex])
            {
                _Highscore.Highscores[_LevelIndex] = highestScore;
                SaveHighscore();
            }
        }
        Invoke("EnableReplay", BarRiseAnimationTime + 1f);
    }