コード例 #1
0
 public void CompleteLapWithEstimatedLapTime(int position, float gameTimeAtLapEnd, float worldRecordLapTime, float worldRecordS1Time, float worldRecordS2Time, float worldRecordS3Time,
                                             Boolean lapIsValid, Boolean isRaining, float trackTemp, float airTemp, Boolean sessionLengthIsTime, float sessionTimeRemaining)
 {
     AddCumulativeSectorData(position, -1, gameTimeAtLapEnd, lapIsValid, isRaining, trackTemp, airTemp);
     if (OpponentLapData.Count > 0)
     {
         LapData lapData = OpponentLapData[OpponentLapData.Count - 1];
         if (lapData.SectorTimes.Count > 2)
         {
             float estimatedLapTime = lapData.SectorTimes.Sum();
             LastLapValid = lapData.IsValid;
             if (lapData.SectorTimes[0] > worldRecordS1Time - 0.1 && lapData.SectorTimes[1] > worldRecordS2Time - 0.1 && lapData.SectorTimes[2] > worldRecordS2Time - 0.1 &&
                 estimatedLapTime > worldRecordLapTime - 0.1 && estimatedLapTime > 0)
             {
                 lapData.LapTime = estimatedLapTime;
                 LastLapTime     = estimatedLapTime;
                 if (lapData.IsValid && (CurrentBestLapTime == -1 || CurrentBestLapTime > lapData.LapTime))
                 {
                     PreviousBestLapTime = CurrentBestLapTime;
                     CurrentBestLapTime  = lapData.LapTime;
                 }
             }
             else
             {
                 LastLapValid    = false;
                 LastLapTime     = -1;
                 lapData.IsValid = false;
             }
         }
     }
     if (sessionLengthIsTime && sessionTimeRemaining > 0 && CurrentBestLapTime > 0 && sessionTimeRemaining < CurrentBestLapTime - 5)
     {
         isProbablyLastLap = true;
     }
 }
コード例 #2
0
 public void AddSectorData(int position, float thisSectorTime, float gameTimeAtSectorEnd, Boolean lapIsValid, Boolean isRaining, float trackTemp, float airTemp)
 {
     if (OpponentLapData.Count > 0)
     {
         LapData lapData      = OpponentLapData[OpponentLapData.Count - 1];
         int     sectorNumber = 1;
         foreach (float sectorTime in lapData.SectorTimes)
         {
             sectorNumber++;
         }
         lapData.SectorTimes.Add(thisSectorTime);
         if (lapIsValid && thisSectorTime > 0)
         {
             if (sectorNumber == 1 && (bestSector1Time == -1 || thisSectorTime < bestSector1Time))
             {
                 bestSector1Time = thisSectorTime;
             }
             if (sectorNumber == 2 && (bestSector2Time == -1 || thisSectorTime < bestSector2Time))
             {
                 bestSector2Time = thisSectorTime;
             }
             if (sectorNumber == 3 && (bestSector3Time == -1 || thisSectorTime < bestSector3Time))
             {
                 bestSector3Time = thisSectorTime;
             }
         }
         lapData.SectorPositions.Add(position);
         lapData.GameTimeAtSectorEnd.Add(gameTimeAtSectorEnd);
         if (lapData.IsValid && !lapIsValid)
         {
             lapData.IsValid = false;
         }
         lapData.Conditions.Add(new LapConditions(isRaining, trackTemp, airTemp));
     }
 }
コード例 #3
0
 public void CompleteLapWithLastSectorTime(int position, float lastSectorTime, float gameTimeAtLapEnd,
                                           Boolean lapIsValid, Boolean isRaining, float trackTemp, float airTemp, Boolean sessionLengthIsTime, float sessionTimeRemaining)
 {
     AddSectorData(position, lastSectorTime, gameTimeAtLapEnd, lapIsValid, isRaining, trackTemp, airTemp);
     if (OpponentLapData.Count > 0)
     {
         LapData lapData = OpponentLapData[OpponentLapData.Count - 1];
         if (lapData.SectorTimes.Count > 2)
         {
             float lapTime = lapData.SectorTimes.Sum();
             LastLapValid = lapData.IsValid;
             if (LastLapValid)
             {
                 lapData.LapTime = lapTime;
                 LastLapTime     = lapTime;
                 if (lapData.IsValid && (CurrentBestLapTime == -1 || CurrentBestLapTime > lapData.LapTime))
                 {
                     PreviousBestLapTime = CurrentBestLapTime;
                     CurrentBestLapTime  = lapData.LapTime;
                 }
             }
             else
             {
                 LastLapValid    = false;
                 LastLapTime     = -1;
                 lapData.IsValid = false;
             }
         }
     }
     if (sessionLengthIsTime && sessionTimeRemaining > 0 && CurrentBestLapTime > 0 && sessionTimeRemaining < CurrentBestLapTime - 5)
     {
         isProbablyLastLap = true;
     }
 }
コード例 #4
0
        public void StartNewLap(int lapNumber, int position, Boolean inPits, float gameTimeAtStart, Boolean isRaining, float trackTemp, float airTemp)
        {
            LapData thisLapData = new LapData();

            thisLapData.Conditions.Add(new LapConditions(isRaining, trackTemp, airTemp));
            thisLapData.GameTimeAtLapStart = gameTimeAtStart;
            thisLapData.OutLap             = inPits;
            thisLapData.PositionAtStart    = position;
            thisLapData.LapNumber          = lapNumber;
            OpponentLapData.Add(thisLapData);
        }
コード例 #5
0
 public void setInLap()
 {
     if (OpponentLapData.Count > 0)
     {
         OpponentLapData[OpponentLapData.Count - 1].InLap = true;
     }
     else
     {
         LapData lapData = new LapData();
         lapData.InLap = true;
         OpponentLapData.Add(lapData);
     }
 }
コード例 #6
0
        public float getLastLapTime()
        {
            LapData lastLap = getLastLapData();

            if (lastLap != null)
            {
                return(lastLap.LapTime);
            }
            else
            {
                return(-1);
            }
        }
コード例 #7
0
 public void CompleteLapWithProvidedLapTime(int position, float gameTimeAtLapEnd, float providedLapTime,
                                            Boolean lapIsValid, Boolean isRaining, float trackTemp, float airTemp, Boolean sessionLengthIsTime, float sessionTimeRemaining)
 {
     if (OpponentLapData.Count > 0)
     {
         LapData lapData = OpponentLapData[OpponentLapData.Count - 1];
         AddCumulativeSectorData(position, providedLapTime, gameTimeAtLapEnd, lapIsValid, isRaining, trackTemp, airTemp);
         lapData.LapTime = providedLapTime;
         LastLapTime     = providedLapTime;
         if (lapData.IsValid && (CurrentBestLapTime == -1 || CurrentBestLapTime > lapData.LapTime))
         {
             PreviousBestLapTime = CurrentBestLapTime;
             CurrentBestLapTime  = lapData.LapTime;
         }
         LastLapValid = lapData.IsValid;
     }
     if (sessionLengthIsTime && sessionTimeRemaining > 0 && CurrentBestLapTime > 0 && sessionTimeRemaining < CurrentBestLapTime - 5)
     {
         isProbablyLastLap = true;
     }
 }
コード例 #8
0
 public float[] getTimeAndSectorsForBestLapInWindow(int lapsToCheck)
 {
     float[] bestLapTimeAndSectorsSectors = new float[] { -1, -1, -1, -1 };
     if (OpponentLapData.Count > 1)
     {
         if (lapsToCheck == -1)
         {
             lapsToCheck = OpponentLapData.Count;
         }
         // count-2 because we're not interested in the current lap
         for (int i = OpponentLapData.Count - 2; i >= OpponentLapData.Count - lapsToCheck - 1 && i >= 0; i--)
         {
             LapData thisLapTime = OpponentLapData[i];
             if (thisLapTime.IsValid)
             {
                 if (bestLapTimeAndSectorsSectors[0] == -1 ||
                     (thisLapTime.LapTime > 0 && thisLapTime.LapTime < bestLapTimeAndSectorsSectors[0]))
                 {
                     bestLapTimeAndSectorsSectors[0] = thisLapTime.LapTime;
                     int sectorCount = thisLapTime.SectorTimes.Count();
                     if (sectorCount > 0)
                     {
                         bestLapTimeAndSectorsSectors[1] = thisLapTime.SectorTimes[0];
                     }
                     if (sectorCount > 1)
                     {
                         bestLapTimeAndSectorsSectors[2] = thisLapTime.SectorTimes[1];
                     }
                     if (sectorCount > 2)
                     {
                         bestLapTimeAndSectorsSectors[3] = thisLapTime.SectorTimes[2];
                     }
                 }
             }
         }
     }
     return(bestLapTimeAndSectorsSectors);
 }
コード例 #9
0
        public Boolean isExitingPits()
        {
            LapData currentLap = getCurrentLapData();

            return(currentLap != null && currentLap.OutLap);
        }
コード例 #10
0
        public Boolean isEnteringPits()
        {
            LapData currentLap = getCurrentLapData();

            return(currentLap != null && currentLap.InLap);
        }