recent lap
This commit is contained in:
1 parent
daa84c8a9d
commit
69a97e3c76
6 files changed
+71
-39
No files matched your search
+23
-4
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -9,6 +10,9 @@ using UnityEditor;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Timing: MonoBehaviour {
|
||||
[SerializeField]
|
||||
TimingUI ui;
|
||||
|
||||
public List<SectorTime> sectorTimes;
|
||||
public bool timerEnabled;
|
||||
|
||||
@@ -16,7 +20,7 @@ public class Timing: MonoBehaviour {
|
||||
public double sectorTime;
|
||||
public double lapTime;
|
||||
public Sector[] sectors;
|
||||
public LapJSON recentLap;
|
||||
public Lap recentLap = null;
|
||||
|
||||
double sectorStart;
|
||||
double lapStart;
|
||||
@@ -33,6 +37,7 @@ public class Timing: MonoBehaviour {
|
||||
Debug.Log("Track Sector Count - " + sectors.Length);
|
||||
|
||||
LapStorageService.GetPlayerLaps(mapName);
|
||||
recentLap = null;
|
||||
}
|
||||
|
||||
void Update() {
|
||||
@@ -107,7 +112,19 @@ public class Timing: MonoBehaviour {
|
||||
Debug.Log($"Ending lap Sectors={sectorTimes.Count} Name={mapName}");
|
||||
Lap l = new Lap { Map = mapName, Sectors = sectorTimes };
|
||||
Debug.Log($"EndLap {l}");
|
||||
|
||||
LapStorageService.PersistLap(l);
|
||||
StartCoroutine(RecentLapLifecycle(l));
|
||||
}
|
||||
|
||||
IEnumerator RecentLapLifecycle(Lap l) {
|
||||
ui.ShowRecentLap(l);
|
||||
yield return new WaitForSeconds(3);
|
||||
ui.HideRecentLap();
|
||||
}
|
||||
|
||||
public Lap PB() {
|
||||
return LapStorageService.PB(mapName);
|
||||
}
|
||||
|
||||
public double PBSectorDiff(SectorTime s) => PB() switch {
|
||||
@@ -118,8 +135,10 @@ public class Timing: MonoBehaviour {
|
||||
null => -1d,
|
||||
};
|
||||
|
||||
public Lap PB() {
|
||||
return LapStorageService.PB(mapName);
|
||||
}
|
||||
public double PBLapDiff(Lap lap) => PB() switch {
|
||||
Lap pb => lap.TotalTime() - pb.TotalTime(),
|
||||
null => -1d,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user