コード例 #1
0
 private MessageFragment(String text, TimeSpanWrapper timeSpanWrapper, OpponentData opponent, FragmentType type)
 {
     this.text = text;
     this.timeSpanWrapper = timeSpanWrapper;
     this.opponent = opponent;
     this.type = type;
 }
コード例 #2
0
 private OpponentData makeTempDriver(String driverName, List<String> rawDriverNames)
 {
     OpponentData opponent = new OpponentData();
     opponent.DriverRawName = driverName;
     rawDriverNames.Add(driverName);
     return opponent;
 }
コード例 #3
0
 public static MessageFragment Opponent(OpponentData opponent)
 {
     return new MessageFragment(null, opponent, FragmentType.Opponent);
 }
コード例 #4
0
 private MessageFragment(String text, OpponentData opponent, FragmentType type)
 {
     this.text = text;
     this.opponent = opponent;
     this.type = type;
 }
コード例 #5
0
 private OpponentData createOpponentData(pCarsAPIParticipantStruct participantStruct, Boolean loadDriverName)
 {
     OpponentData opponentData = new OpponentData();
     opponentData.DriverRawName = participantStruct.mName.Trim();
     if (loadDriverName && CrewChief.enableDriverNames)
     {
         speechRecogniser.addNewOpponentName(opponentData.DriverRawName);
     }
     opponentData.Position = (int)participantStruct.mRacePosition;
     opponentData.UnFilteredPosition = opponentData.Position;
     opponentData.CompletedLaps = (int)participantStruct.mLapsCompleted;
     opponentData.CurrentSectorNumber = (int)participantStruct.mCurrentSector;
     opponentData.WorldPosition = new float[] { participantStruct.mWorldPosition[0], participantStruct.mWorldPosition[2] };
     opponentData.DistanceRoundTrack = participantStruct.mCurrentLapDistance;
     return opponentData;
 }
コード例 #6
0
 private void upateOpponentData(OpponentData opponentData, int racePosition, int completedLaps, int sector, Boolean isInPits,
     float sessionRunningTime, float secondsSinceLastUpdate, float[] currentWorldPosition, float[] previousWorldPosition,
     float previousSpeed, float worldRecordLapTime, float distanceRoundTrack, Boolean isRaining, float trackTemp, float airTemp)
 {
     opponentData.DistanceRoundTrack = distanceRoundTrack;
     float speed;
     Boolean validSpeed = true;
     if ((currentWorldPosition[0] == 0 && currentWorldPosition[1] == 0) || (previousWorldPosition[0] == 0 && previousWorldPosition[1] == 0))
     {
         speed = previousSpeed;
     }
     else
     {
         speed = (float)Math.Sqrt(Math.Pow(currentWorldPosition[0] - previousWorldPosition[0], 2) + Math.Pow(currentWorldPosition[1] - previousWorldPosition[1], 2)) / secondsSinceLastUpdate;
     }
     if (speed > 500)
     {
         // faster than 500m/s (1000+mph) suggests the player has quit to the pit. Might need to reassess this as the data are quite noisy
         validSpeed = false;
         opponentData.Speed = 0;
     }
     else if (speed == 0 && previousSpeed > 5)
     {
         if (previousSpeedReuseCount.ContainsKey(opponentData.DriverRawName))
         {
             if (previousSpeedReuseCount[opponentData.DriverRawName] > 5)
             {
                 // we've reused 5 previous values, reset
                 previousSpeedReuseCount[opponentData.DriverRawName] = 0;
             }
             else
             {
                 speed = previousSpeed;
                 previousSpeedReuseCount[opponentData.DriverRawName] = previousSpeedReuseCount[opponentData.DriverRawName] + 1;
             }
         }
         else
         {
             previousSpeedReuseCount.Add(opponentData.DriverRawName, 1);
             speed = previousSpeed;
         }
     }
     opponentData.Speed = speed;
     opponentData.Position = racePosition;
     opponentData.UnFilteredPosition = racePosition;
     opponentData.WorldPosition = currentWorldPosition;
     opponentData.IsNewLap = false;
     if (opponentData.CurrentSectorNumber != sector)
     {
         if (opponentData.CurrentSectorNumber == 3 && sector == 1)
         {
             // use -1 for provided lap time and let the AddSectorData method calculate it from the game time
             if (opponentData.OpponentLapData.Count > 0)
             {
                 opponentData.CompleteLapWithEstimatedLapTime(racePosition, sessionRunningTime, worldRecordLapTime, validSpeed,
                     isRaining, trackTemp, airTemp);
             }
             opponentData.StartNewLap(completedLaps + 1, racePosition, isInPits, sessionRunningTime, isRaining, trackTemp, airTemp);
             opponentData.IsNewLap = true;
         }
         else if (opponentData.CurrentSectorNumber == 1 && sector == 2 || opponentData.CurrentSectorNumber == 2 && sector == 3)
         {
             opponentData.AddSectorData(racePosition, -1, sessionRunningTime, validSpeed, isRaining, trackTemp, airTemp);
         }
         opponentData.CurrentSectorNumber = sector;
     }
     if (sector == 3 && isInPits)
     {
         opponentData.setInLap();
     }
     opponentData.CompletedLaps = completedLaps;
 }
コード例 #7
0
        private OpponentData createOpponentData(DriverData participantStruct, String driverName, Boolean loadDriverName)
        {
            if (loadDriverName && CrewChief.enableDriverNames)
            {
                speechRecogniser.addNewOpponentName(driverName);
            }
            OpponentData opponentData = new OpponentData();
            opponentData.DriverRawName = driverName;
            opponentData.Position = participantStruct.place;
            opponentData.UnFilteredPosition = opponentData.Position;
            opponentData.CompletedLaps = participantStruct.completed_laps;
            opponentData.CurrentSectorNumber = participantStruct.track_sector;
            opponentData.WorldPosition = new float[] { participantStruct.position.X, participantStruct.position.Z };
            opponentData.DistanceRoundTrack = participantStruct.lap_distance;
            opponentData.CarClass = CarData.getCarClassForRaceRoomId(participantStruct.driver_info.class_id);
            opponentData.CurrentTyres = mapToTyreType(participantStruct.tire_type);
            Console.WriteLine("New driver " + driverName + " is using car class " +
                opponentData.CarClass.carClassEnum + " (class ID " + participantStruct.driver_info.class_id + ")");

            return opponentData;
        }
コード例 #8
0
 private void upateOpponentData(OpponentData opponentData, int racePosition, int unfilteredRacePosition, int completedLaps, int sector, float sectorTime, 
     float completedLapTime, Boolean isInPits, Boolean lapIsValid, float sessionRunningTime, float secondsSinceLastUpdate, float[] currentWorldPosition, 
     float[] previousWorldPosition, float distanceRoundTrack, int tire_type)
 {
     opponentData.DistanceRoundTrack = distanceRoundTrack;
     float speed;
     Boolean validSpeed = true;
     speed = (float)Math.Sqrt(Math.Pow(currentWorldPosition[0] - previousWorldPosition[0], 2) + Math.Pow(currentWorldPosition[1] - previousWorldPosition[1], 2)) / secondsSinceLastUpdate;
     if (speed > 500)
     {
         // faster than 500m/s (1000+mph) suggests the player has quit to the pit. Might need to reassess this as the data are quite noisy
         validSpeed = false;
         opponentData.Speed = 0;
     }
     opponentData.Speed = speed;
     if (opponentData.Position != racePosition)
     {
         opponentData.SessionTimeAtLastPositionChange = sessionRunningTime;
     }
     opponentData.Position = racePosition;
     opponentData.UnFilteredPosition = unfilteredRacePosition;
     opponentData.WorldPosition = currentWorldPosition;
     opponentData.IsNewLap = false;
     if (opponentData.CurrentSectorNumber != sector)
     {
         if (opponentData.CurrentSectorNumber == 3 && sector == 1)
         {
             if (opponentData.OpponentLapData.Count > 0)
             {
                 opponentData.CompleteLapWithProvidedLapTime(racePosition, sessionRunningTime, completedLapTime,
                     lapIsValid && validSpeed, false, 20, 20);
             }
             opponentData.StartNewLap(completedLaps + 1, racePosition, isInPits, sessionRunningTime, false, 20, 20);
             opponentData.IsNewLap = true;
         }
         else if (opponentData.CurrentSectorNumber == 1 && sector == 2 || opponentData.CurrentSectorNumber == 2 && sector == 3)
         {
             opponentData.AddSectorData(racePosition, sectorTime, sessionRunningTime, lapIsValid && validSpeed, false, 20, 20);
             if (sector == 2)
             {
                 opponentData.CurrentTyres = mapToTyreType(tire_type);
             }
         }
         opponentData.CurrentSectorNumber = sector;
     }
     opponentData.CompletedLaps = completedLaps;
     if (sector == 3 && isInPits)
     {
         opponentData.setInLap();
     }
 }