protected void NotifyData(LapData data) { foreach (var observer in _lapDataObservers) { observer.OnNext(data); } }
// Token: 0x06001F05 RID: 7941 RVA: 0x000BF3C8 File Offset: 0x000BD5C8 public void RestoreEndLap(long timestamp, float distance, float elvation, float ridingTime, float lapDrop, float calerie, float maxCadence, float maxHeartRate, float maxPower, float maxSpeed) { if (!this.lapDataDic.ContainsKey(this.lapCount)) { return; } LapData lapData = this.lapDataDic[this.lapCount]; lapData.listCount = this.powerlst.Count; lapData.lapDistance = (this.lapDataDic.ContainsKey(this.lapCount - 1) ? (this.lapDataDic[this.lapCount - 1].lapDistance + distance) : distance); lapData.netTime = timestamp - lapData.netTime; lapData.lapElvation = (this.lapDataDic.ContainsKey(this.lapCount - 1) ? (this.lapDataDic[this.lapCount - 1].lapElvation + elvation) : elvation); lapData.lapRidingTime = (this.lapDataDic.ContainsKey(this.lapCount - 1) ? (this.lapDataDic[this.lapCount - 1].lapRidingTime + ridingTime) : ridingTime); lapData.lapDrop = (this.lapDataDic.ContainsKey(this.lapCount - 1) ? (this.lapDataDic[this.lapCount - 1].lapDrop + lapDrop) : (this.lapDataDic.ContainsKey(this.lapCount - 1) ? (this.lapDataDic[this.lapCount - 1].lapRidingTime + ridingTime) : ridingTime)); lapData.calerie = (this.lapDataDic.ContainsKey(this.lapCount - 1) ? (this.lapDataDic[this.lapCount - 1].calerie + calerie) : calerie); lapData.preListCount = (this.lapDataDic.ContainsKey(this.lapCount - 1) ? this.lapDataDic[this.lapCount - 1].listCount : 0); lapData.lapMaxCadence = maxCadence; lapData.lapMaxHeartRate = maxHeartRate; lapData.lapMaxPower = maxPower; lapData.lapMaxSpeed = maxSpeed; this.lapDataDic[this.lapCount] = lapData; this.lapMaxCadence = -2.14748365E+09f; this.lapMaxHeartRate = -2.14748365E+09f; this.lapMaxPower = -2.14748365E+09f; this.lapMaxSpeed = -2.14748365E+09f; }
/// <summary> /// Reset all player entries for restarting a game. /// In derived classes reset all the variables we need to reset for /// a new game there (e.g. car speed in CarController or /// cameraWobbel in ChaseCamera). /// </summary> public virtual void Reset() { //*** Initialize the high scores Highscores.Initialize(); levelNum = TrackSelection.SelectedTrackNumber; isGameOver = false; alreadyUploadedHighscore = false; currentGameTimeMilliseconds = 0; bestLapTimeMilliseconds = 0; lap = 0; victory = false; zoomInTime = StartGameZoomTimeMilliseconds; firstFrame = true; m_LapId = Guid.NewGuid().ToString(); CurrentLapData = new LapData() { PlayerName = GameSettings.Default.PlayerName, CarType = RacingGameManager.currentCarNumber, LapId = m_LapId, GameStartTime = DateTime.UtcNow, Level = levelNum }; }
// Token: 0x06001F04 RID: 7940 RVA: 0x000BF260 File Offset: 0x000BD460 public void EndLap(long timeStamp) { if (this.lapDataDic.ContainsKey(this.lapCount)) { LapData lapData = this.lapDataDic[this.lapCount]; lapData.listCount = this.powerlst.Count; try { lapData.lapDistance = this.distancelst[this.distancelst.Count - 1]; } catch (Exception) { lapData.lapDistance = 0f; } lapData.netTime = timeStamp - lapData.netTime; lapData.lapElvation = this.totalElevation; lapData.lapRidingTime = this.ridingTime; lapData.lapDrop = this.totalDrop; lapData.calerie = this.calorie; lapData.preListCount = (this.lapDataDic.ContainsKey(this.lapCount - 1) ? this.lapDataDic[this.lapCount - 1].listCount : 0); lapData.lapMaxCadence = this.lapMaxCadence; lapData.lapMaxHeartRate = this.lapMaxHeartRate; lapData.lapMaxPower = this.lapMaxPower; lapData.lapMaxSpeed = this.lapMaxSpeed; this.lapDataDic[this.lapCount] = lapData; this.lapMaxCadence = -2.14748365E+09f; this.lapMaxHeartRate = -2.14748365E+09f; this.lapMaxPower = -2.14748365E+09f; this.lapMaxSpeed = -2.14748365E+09f; } }
// Token: 0x06001F03 RID: 7939 RVA: 0x000BF214 File Offset: 0x000BD414 public void StartLap(long timeStamp) { GameController.manager.trainingMan.stepStart = false; this.lapCount++; LapData lapData = new LapData(); lapData.netTime = timeStamp; this.lapDataDic[this.lapCount] = lapData; }
public void TestGetLapTimeFromString() { string lapTimeString = "1:32.554 "; float lapTime; var lapData = new LapData(); lapTime = lapData.GetLapTime(lapTimeString); Assert.AreEqual(92.554F, lapTime); }
private static IPacket Lap(PacketHeader packetHeader, BinaryReader reader) { var packetLapData = new PacketLapData(packetHeader); for (int i = 0; i < MaxNumberOfCarsOnTrack; i++) { var lapData = new LapData(); lapData.SessionUID = packetHeader.SessionUID; lapData.SessionTime = packetHeader.SessionTime; lapData.LastLapTime = reader.ReadSingle(); lapData.CurrentLapTime = reader.ReadSingle(); lapData.Sector1TimeInMS = reader.ReadUInt16(); lapData.Sector2TimeInMS = reader.ReadUInt16(); lapData.BestLapTime = reader.ReadSingle(); lapData.BestLapNum = reader.ReadByte(); lapData.BestLapSector1TimeInMS = reader.ReadUInt16(); lapData.BestLapSector2TimeInMS = reader.ReadUInt16(); lapData.BestLapSector3TimeInMS = reader.ReadUInt16(); lapData.BestOverallSector1TimeInMS = reader.ReadUInt16(); lapData.BestOverallSector1LapNum = reader.ReadByte(); lapData.BestOverallSector2TimeInMS = reader.ReadUInt16(); lapData.BestOverallSector2LapNum = reader.ReadByte(); lapData.BestOverallSector3TimeInMS = reader.ReadUInt16(); lapData.BestOverallSector3LapNum = reader.ReadByte(); lapData.LapDistance = reader.ReadSingle(); lapData.TotalDistance = reader.ReadSingle(); lapData.SafetyCarDelta = reader.ReadSingle(); lapData.CarPosition = reader.ReadByte(); lapData.CurrentLapNum = reader.ReadByte(); lapData.PitStatus = (PitStatus)reader.ReadByte(); lapData.Sector = reader.ReadByte(); lapData.CurrentLapInvalid = reader.ReadByte(); lapData.Penalties = reader.ReadByte(); lapData.GridPosition = reader.ReadByte(); lapData.DriverStatus = (DriverStatus)reader.ReadByte(); lapData.ResultStatus = (ResultStatus)reader.ReadByte(); packetLapData.LapData[i] = lapData; } return(packetLapData); }
public void CheckFastestLap(LapData lap) { if (fastestLap == null) { fastestLap = lap; return; } if (fastestLap.laptime > lap.laptime) { fastestLap = lap; } }
public LapData Read(Span <byte> input, PacketHeader packetHeader) { var output = new LapData { Header = packetHeader }; for (var i = 0; i < 20; i++) { output.CarLaps[i] = ReadCarLap(input); } return(output); }
public void InsertRankedTime(LapData lapData) { Debug.WriteLine(">>LapDataTable.InsertRankedTime"); //// Get a reference to the rankings table //CloudTable table = m_TableClient.GetTableReference // (Settings.RankingLapTimesTableName); //// Create the partition key and row key for the entity //string partitionKey = // Settings.RankingLapTimesPartitionKeyPrefix + lapData.Level; //string rowKey = // lapData.LapTimeMs.ToString().PadLeft(8, '0') + "-" + // Utils.GetAscendingRowKey(lapData.GameStartTime); //// Create a new dynamic entity //DynamicTableEntity sectorTimesEntity = new // DynamicTableEntity(partitionKey, rowKey); //// Add properties for the driver lap //sectorTimesEntity.Properties.Add // ("PlayerName", new EntityProperty(lapData.PlayerName)); //sectorTimesEntity.Properties.Add // ("LapStartTime", new EntityProperty(lapData.GameStartTime)); //sectorTimesEntity.Properties.Add // ("Level", new EntityProperty(lapData.Level)); //sectorTimesEntity.Properties.Add // ("CarType", new EntityProperty(lapData.CarType)); //sectorTimesEntity.Properties.Add // ("Dammage", new EntityProperty(lapData.Dammage)); //sectorTimesEntity.Properties.Add // ("LapId", new EntityProperty(lapData.LapId)); //sectorTimesEntity.Properties.Add // ("LapTimeMs", new EntityProperty(lapData.LapTimeMs)); //// Add properties for the sector data //int sector = 1; //foreach (int sectorTime in lapData.SectorTimesMs) //{ // sectorTimesEntity.Properties.Add // ("Sector" + sector.ToString().PadLeft(2, '0'), // new EntityProperty(sectorTime)); // sector++; //} //// Insert the entity in the table. //TableOperation insertOp = // TableOperation.Insert(sectorTimesEntity); //table.Execute(insertOp); }
public void InsertOrReplaceDriverLapData(LapData lapData) { Debug.WriteLine(">>LapDataTable.InsertOrReplaceDriverLapData"); try { // CloudTable table = m_TableClient.GetTableReference // (GetPlayerLapTableName(lapData.Level)); // DynamicTableEntity sectorTimesEntity = // new DynamicTableEntity(lapData.PlayerName, // Utils.GetDescendingRowKey(lapData.GameStartTime)); // sectorTimesEntity.Properties.Add // ("PlayerName", new EntityProperty(lapData.PlayerName)); // sectorTimesEntity.Properties.Add // ("LapStartTime", new EntityProperty(lapData.GameStartTime)); // sectorTimesEntity.Properties.Add // ("Level", new EntityProperty(lapData.Level)); // sectorTimesEntity.Properties.Add // ("CarType", new EntityProperty(lapData.CarType)); // sectorTimesEntity.Properties.Add // ("Dammage", new EntityProperty(lapData.Dammage)); // sectorTimesEntity.Properties.Add // ("LapId", new EntityProperty(lapData.LapId)); // sectorTimesEntity.Properties.Add // ("LapTimeMs", new EntityProperty(lapData.LapTimeMs)); // int sector = 1; // foreach (int sectorTime in lapData.SectorTimesMs) // { // sectorTimesEntity.Properties.Add // ("Sector" + sector.ToString().PadLeft(2, '0'), // new EntityProperty(sectorTime)); // sector++; // } // TableOperation insertOrReplaceOp = // TableOperation.InsertOrReplace(sectorTimesEntity); // table.BeginExecute(insertOrReplaceOp, null, null); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public void ProcessArguments(string argument) { switch (argument) { case "Trigger": if (currentLap != null) { currentLap.laptime = CurrentLapDiff; laps.Add(currentLap); CheckFastestLap(currentLap); } currentLap = new LapData(control, ingameTime); currentLapStartTime = ingameTime.Time; break; } }
private void FillTimingInfo(DriverInfo driverInfo, LapData rawLapData, int driverIndex) { driverInfo.Timing.CurrentSector = rawLapData.MSector + 1; driverInfo.Timing.LastSector1Time = TimeSpan.FromSeconds(driverInfo.Timing.CurrentSector == 1 ? rawLapData.MCurrentLapTime : rawLapData.MSector1Time); driverInfo.Timing.LastSector2Time = TimeSpan.FromSeconds(rawLapData.MCurrentLapTime - rawLapData.MSector1Time); if (driverInfo.Timing.CurrentSector == 3) { _sector2TimeCache[driverIndex] = rawLapData.MSector2Time; _lapTimeCache[driverIndex] = rawLapData.MCurrentLapTime; } driverInfo.Timing.CurrentLapTime = TimeSpan.FromSeconds(rawLapData.MCurrentLapTime); driverInfo.Timing.LastSector3Time = TimeSpan.FromSeconds(driverInfo.Timing.CurrentSector == 3 ? rawLapData.MCurrentLapTime - rawLapData.MSector2Time : _lapTimeCache[driverIndex] - _sector2TimeCache[driverIndex]); driverInfo.Timing.LastLapTime = TimeSpan.FromSeconds(driverInfo.Timing.CurrentSector == 3 ? rawLapData.MLastLapTime : _lapTimeCache[driverIndex]); driverInfo.Timing.BestLapTime = TimeSpan.FromSeconds(rawLapData.MBestLapTime); }
private void CheckLapFinish() { // Collide with half lap collider first, avoid multiple laps while being still if (halfLap) { halfLap = false; LapData lapData = new LapData { lap_id = currentLap, time = (DateTime.Now - lapStart) }; EventManager.OnLap(lapData); lapStart = DateTime.Now; currentLap++; } }
public override void LoadBytes(byte[] bytes) { ByteArrayManager BAM = new ByteArrayManager(bytes); //Get header base.LoadBytes(BAM.NextBytes(24)); //Get the next 20 data packages List <LapData> LDs = new List <LapData>(); int t = 1; for (t = 1; t <= 22; t++) { LDs.Add(LapData.Create(BAM.NextBytes(53))); } FieldLapData = LDs.ToArray(); }
void F1Manager_LapPacketReceived(object sender, PacketReceivedEventArgs <PacketLapData> e) { l = e.Packet.GetPlayerLapData(); Debug.Log("lap packet"); }
public PacketLapData(int a) { m_header = new PacketHeader(); m_lapData = new LapData[20]; }
public static LapData Create(byte[] bytes) { LapData ReturnInstance = new LapData(); ByteArrayManager BAM = new ByteArrayManager(bytes); ReturnInstance.LastLapTime = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.CurrentLapTime = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.Sector1TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.Sector2TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestLapTimeSeconds = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.BestLapNumber = BAM.NextByte(); ReturnInstance.BestLapSector1TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestLapSector2TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestLapSector3TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestOverallSector1TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestOverallSector1TimeLapNumber = BAM.NextByte(); ReturnInstance.BestOverallSector2TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestOverallSector2TimeLapNumber = BAM.NextByte(); ReturnInstance.BestOverallSector3TimeMilliseconds = BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BestOverallSector3TimeLapNumber = BAM.NextByte(); ReturnInstance.LapDistance = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.TotalDistance = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.SafetyCarDelta = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.CarPosition = BAM.NextByte(); ReturnInstance.CurrentLapNumber = BAM.NextByte(); //Get pit status byte nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.CurrentPitStatus = PitStatus.OnTrack; } else if (nb == 1) { ReturnInstance.CurrentPitStatus = PitStatus.PitLane; } else if (nb == 2) { ReturnInstance.CurrentPitStatus = PitStatus.PitArea; } //Get sector ReturnInstance.Sector = System.Convert.ToByte(BAM.NextByte() + 1); //Get current lap invalid nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.CurrentLapInvalid = false; } else if (nb == 1) { ReturnInstance.CurrentLapInvalid = true; } //Get penalties ReturnInstance.Penalties = BAM.NextByte(); //Get grid position ReturnInstance.StartingGridPosition = BAM.NextByte(); //Get driver status nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.CurrentDriverStatus = DriverStatus.InGarage; } else if (nb == 1) { ReturnInstance.CurrentDriverStatus = DriverStatus.FlyingLap; } else if (nb == 2) { ReturnInstance.CurrentDriverStatus = DriverStatus.InLap; } else if (nb == 3) { ReturnInstance.CurrentDriverStatus = DriverStatus.OutLap; } else if (nb == 4) { ReturnInstance.CurrentDriverStatus = DriverStatus.OnTrack; } //Get result status nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.FinalResultStatus = ResultStatus.Invalid; } else if (nb == 1) { ReturnInstance.FinalResultStatus = ResultStatus.Inactive; } else if (nb == 2) { ReturnInstance.FinalResultStatus = ResultStatus.Active; } else if (nb == 3) { ReturnInstance.FinalResultStatus = ResultStatus.Finished; } else if (nb == 4) { ReturnInstance.FinalResultStatus = ResultStatus.Disqualified; } else if (nb == 5) { ReturnInstance.FinalResultStatus = ResultStatus.NotClassified; } else if (nb == 6) { ReturnInstance.FinalResultStatus = ResultStatus.Retired; } return(ReturnInstance); }
public List <LapData> GetTopLapTimes(int level, int number, bool bestLapOnly) { Debug.WriteLine(">>LapDataTable.GetTopLapTimes"); return(new List <LapData>()); CloudTable table = m_TableClient.GetTableReference(Settings.RankingLapTimesTableName); IQueryable <DynamicTableEntity> query; if (bestLapOnly) { query = (from q in table.CreateQuery <DynamicTableEntity>() where q.PartitionKey.Equals(Settings.RankingLapTimesPartitionKeyPrefix + level) select q); } else { query = (from q in table.CreateQuery <DynamicTableEntity>() where q.PartitionKey.Equals(Settings.RankingLapTimesPartitionKeyPrefix + level) select q).Take(number); } List <LapData> topTimes = new List <LapData>(); List <string> driverNames = new List <string>(); int fastestTime = 0; int ranking = 1; foreach (DynamicTableEntity entity in query) { bool addLap = true; if (bestLapOnly) { string driverName = entity.Properties["PlayerName"].StringValue; if (driverNames.Contains(driverName)) { addLap = false; } else { driverNames.Add(driverName); } } if (addLap) { LapData lapData = new LapData(entity); if (ranking == 1) { fastestTime = lapData.LapTimeMs; } lapData.LapDelta = lapData.LapTimeMs - fastestTime; lapData.Ranking = ranking; topTimes.Add(lapData); ranking++; } } return(topTimes); return(new List <LapData>()); }
public void ReadStandings(string ip, int port, string displayName, string connectionPassword, string commandPassword) { TextWriterTraceListener listener = new TextWriterTraceListener(this.outFileName + ".Trace"); Debug.Listeners.Add(listener); Debug.WriteLine("Starting UDP Client..."); bool done = false; bool firstRun = true; while (!done) { ACCUdpRemoteClient client = new ACCUdpRemoteClient(ip, port, displayName, connectionPassword, commandPassword, 100); client.MessageHandler.OnRealtimeUpdate += OnRealtimeUpdate; client.MessageHandler.OnTrackDataUpdate += OnTrackDataUpdate; client.MessageHandler.OnEntrylistUpdate += OnEntryListUpdate; client.MessageHandler.OnRealtimeCarUpdate += OnRealtimeCarUpdate; client.MessageHandler.OnBroadcastingEvent += OnBroadcastingEvent; if (firstRun) { firstRun = false; int retries = 3; while (retries > 0) { int count = Cars.Count; Thread.Sleep(500); if (Cars.Count == count) { retries -= 1; } else { retries = 1; } } } int requests = 0; while (!done && (requests < 5)) { try { Debug.Flush(); listener.Flush(); if (File.Exists(cmdFileName)) { // requests += 1; StreamReader cmdStream = new StreamReader(cmdFileName); string command = cmdStream.ReadLine(); if (command == "Exit") { done = true; } else if (command == "Read") { StreamWriter outStream = new StreamWriter(outFileName, false, Encoding.Unicode); outStream.WriteLine("[Position Data]"); outStream.Write("Car.Count="); outStream.WriteLine(Cars.Count); int index = 1; foreach (CarData car in Cars) { outStream.Write("Car."); outStream.Write(index); outStream.Write(".ID="); outStream.WriteLine(car.CarIndex); outStream.Write("Car."); outStream.Write(index); outStream.Write(".Nr="); outStream.WriteLine(car.RaceNumber); outStream.Write("Car."); outStream.Write(index); outStream.Write(".Position="); outStream.WriteLine(car.Position); outStream.Write("Car."); outStream.Write(index); outStream.Write(".Lap="); outStream.WriteLine(car.Laps); outStream.Write("Car."); outStream.Write(index); outStream.Write(".Lap.Running="); outStream.WriteLine(car.SplinePosition); LapData lastLap = car.LastLap; outStream.Write("Car."); outStream.Write(index); outStream.Write(".Lap.Valid="); outStream.WriteLine(lastLap != null ? (lastLap.IsValid ? "true" : "false") : "true"); outStream.Write("Car."); outStream.Write(index); outStream.Write(".Time="); outStream.WriteLine(lastLap != null ? (lastLap.LaptimeMS != null ? lastLap.LaptimeMS : 0) : 0); outStream.Write("Car."); outStream.Write(index); outStream.Write(".Delta="); outStream.WriteLine(car.Delta); outStream.Write("Car."); outStream.Write(index); if (lastLap != null) { string split1MS = lastLap.Split1MS + ""; string split2MS = lastLap.Split2MS + ""; string split3MS = lastLap.Split3MS + ""; if (split1MS.Length == 0) { split1MS = "0"; } if (split2MS.Length == 0) { split2MS = "0"; } if (split3MS.Length == 0) { split3MS = "0"; } outStream.Write(".Time.Sectors="); outStream.WriteLine(split1MS + "," + split2MS + "," + split3MS); } else { outStream.WriteLine(".Time.Sectors=0,0,0"); } outStream.Write("Car."); outStream.Write(index); outStream.Write(".Car="); outStream.WriteLine(car.CarModelEnum); DriverData currentDriver = car.CurrentDriver; if (currentDriver != null) { outStream.Write("Car."); outStream.Write(index); outStream.Write(".Driver.Forname="); outStream.WriteLine(currentDriver.FirstName); outStream.Write("Car."); outStream.Write(index); outStream.Write(".Driver.Surname="); outStream.WriteLine(currentDriver.LastName); outStream.Write("Car."); outStream.Write(index); outStream.Write(".Driver.Nickname="); outStream.WriteLine(currentDriver.ShortName); } CarLocationEnum location = car.CarLocation; bool inPitLane = false; if (location == CarLocationEnum.Pitlane) { inPitLane = true; } outStream.Write("Car."); outStream.Write(index); outStream.Write(".InPitlane="); outStream.WriteLine(inPitLane ? "true" : "false"); index += 1; } outStream.Close(); } cmdStream.Close(); File.Delete(cmdFileName); } else { Thread.Sleep(100); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } } client.MessageHandler.OnRealtimeUpdate -= OnRealtimeUpdate; client.MessageHandler.OnTrackDataUpdate -= OnTrackDataUpdate; client.MessageHandler.OnEntrylistUpdate -= OnEntryListUpdate; client.MessageHandler.OnRealtimeCarUpdate -= OnRealtimeCarUpdate; client.MessageHandler.OnBroadcastingEvent -= OnBroadcastingEvent; client.Shutdown(); } }