示例#1
0
        public void AddAsBestTime(TimeSpan time, EventDistance distance, Stroke stroke, PoolType course)
        {
            TimeSpan result = GetBestTime(course, stroke, distance);

            if (time > result)
            {
                throw new Exception("Sorry, this is not the best time!");
            }
            else
            {
                BestTimes.Add(time);
            }
        }
示例#2
0
    /// <summary>
    /// Handles crossing the finish line.
    /// </summary>
    /// <param name="level">The level entry to update in BestTimes (if time is recorded for this level).</param>
    public void HandleFinish(BestTimes.Level level = BestTimes.Level.None)
    {
        if (this.isValidRun)
        {
            float time = Time.time - this.startTime;
            this.Hud.ShowSuccessMessage(time);
            this.isValidRun = false;

            if (level != BestTimes.Level.None)
            {
                BestTimes.UpdateBestTime(level, time);
            }
        }
    }
示例#3
0
        public void AddAsBestTime(PoolType poolType, EventDistance eventDistance, Stroke stroke, TimeSpan time)
        {
            TimeSpan bestTime = GetBestTime(poolType, stroke, eventDistance);

            if (bestTime == new TimeSpan(1, 0, 0))
            {
                BestTimes.Add(new BestTime(poolType, eventDistance, stroke, time));
            }
            else if (time < bestTime)
            {
                int      i    = BestTimes.IndexOf(new BestTime(poolType, eventDistance, stroke, bestTime));
                BestTime best = new BestTime(poolType, eventDistance, stroke, time);
                bestTimes[i] = best;
            }
        }
 static BestTimes()
 {
     BestTimes.LoadTimes();
 }
示例#5
0
 /// <summary>
 /// Clear all recorded best times.
 /// </summary>
 public void Clear()
 {
     BestTimes.Clear();
     this.UpdateTexts();
 }
示例#6
0
 /// <summary>
 /// Update text objects displaying best times.
 /// </summary>
 public void UpdateTexts()
 {
     this.texts[Texts.Names.GetHashCode()].text = BestTimes.GetFormattedNames();
     this.texts[Texts.Times.GetHashCode()].text = BestTimes.GetFormattedTimes();
 }