예제 #1
0
    /// <summary>
    /// Initializes the entry with best time and level information.
    /// </summary>
    /// <param name="levelInfo">The level to which the entry corresponds.</param>
    /// <param name="bestTimeInfo">The best times with which the player completed the level.</param>
    public void SetInfo(LevelInfo levelInfo, BestTimeInfo bestTimeInfo)
    {
        this.texts[(int)Texts.LevelName].text   = levelInfo.FullName;
        this.texts[(int)Texts.OverallTime].text = BestTimeUIEntry.FormatTime(bestTimeInfo.OverallTime);

        string checkpointTimes = string.Empty;

        if (bestTimeInfo.CheckpointTimes != null && bestTimeInfo.CheckpointTimes.Length > 1)
        {
            checkpointTimes = $"1) {BestTimeUIEntry.FormatTime(bestTimeInfo.CheckpointTimes[0])}";
            for (int i = 1; i < bestTimeInfo.CheckpointTimes.Length; i++)
            {
                checkpointTimes += $"    {i + 1}) {BestTimeUIEntry.FormatTime(bestTimeInfo.CheckpointTimes[i])}";
            }
        }
        this.texts[(int)Texts.Checkpoints].text = checkpointTimes;

        this.level = levelInfo;
    }
예제 #2
0
    /// <summary>
    /// Update the level's saved best times with the current times, if necessary.
    /// </summary>
    private void UpdateBestTimes()
    {
        if (LevelManager.LevelManagerMode == LevelManagerMode.Race &&
            LevelManager.NumPlayers == 1 &&
            this.curKeyPoints[0] > 0 &&
            !Settings.CheatMode)
        {
            BestTimeInfo bestTimeInfo = SavedDataManager.Data.BestTimes[LevelManager.LevelInfo.WinableIndex];

            // Update overall time if we finished the level
            if (this.curKeyPoints[0] == this.keyPoints.Length - 1)
            {
                bestTimeInfo.OverallTime = Mathf.Min(bestTimeInfo.OverallTime, this.totalDuration);
            }

            // Update the times for the checkpoints we completed
            for (int i = 0; i < this.curKeyPoints[0]; i++)
            {
                bestTimeInfo.CheckpointTimes[i] = Mathf.Min(bestTimeInfo.CheckpointTimes[i], this.keyPointDurations[i + 1]);
            }

            SavedDataManager.Save();
        }
    }