Beispiel #1
0
    public void CompleteLap()
    {
        if (isRunning)
        {
            times[lapCounter] = currentTime;
            calculateTotalTime();
            LapTimes.text  = LapTimes.text.Substring(0, LapTimes.text.Length - 9) + string.Format("{0}\nLap {1} : --:--:---", FormatTime(times[lapCounter]), lapCounter + 2);
            lapCounter    += 1;
            LapNumber.text = "Lap " + (lapCounter + 1);
            ResetCurrentTime();

            //If is the last lap calculate and display total time check for highscore.
            if (lapCounter == numberOfLaps)
            {
                calculateTotalTime();
                LapTimes.text   = LapTimes.text.Substring(0, LapTimes.text.Length - 17);
                CurrentLap.text = string.Format("Total Time : {0}", FormatTime(times[lapCounter]));
                TimeUI.text     = string.Format("Total Time\n{0}", FormatTime(times[lapCounter]));
                LapNumber.text  = "FINISHED!";
                CheckHighScore(times[numberOfLaps]);
                isRunning = false;
                levelComplete.DisplayCompleteScreen(GetScoreStringArray(), GetHighScoreString(), isHighscore);
            }
        }
    }