コード例 #1
0
        private void Start()
        {
            Stop(containingObject);
            if (!startTime.HasValue)
            {
                return;
            }

            var estimatedLapTime = race.EstimatedLaps != null
                ? race.EstimatedLaps.Select(l => new TimeSpan?(l.LapTime)).FirstOrDefault()
                : new TimeSpan?();

            var openingLapLength = calculator.LapPassedLength(race.Distance, 1);
            var speed            = estimatedLapTime.HasValue
                ? openingLapLength / estimatedLapTime.Value.TotalSeconds
                : DefaultSpeed;

            Duration = TimeSpan.FromSeconds(openingLapLength);
            Begin(containingObject, true);
            Seek(containingObject, TimeSpan.FromSeconds(speed * (DateTime.Now - startTime.Value).TotalSeconds), TimeSeekOrigin.BeginTime);
            SetSpeedRatio(containingObject, speed);
        }
コード例 #2
0
 public static RaceLapIndex LapIndex(this IDistanceDisciplineCalculator calculator, Distance distance, int index)
 {
     return(new RaceLapIndex(index, calculator.Rounds(distance, index + 1), calculator.RoundsToGo(distance, index + 1), calculator.LapPassedLength(distance, index + 1)));
 }
 public static LapRound LapRound(this IDistanceDisciplineCalculator calculator, IDistance distance, int lap)
 {
     return(new LapRound(calculator.Rounds(distance, lap), calculator.RoundsToGo(distance, lap), calculator.LapPassedLength(distance, lap)));
 }