awake todo

This commit is contained in:
ntr committed 2023-08-29 21:26:03 +10:00
1 parent 2980cb9e4e
commit 361e76cc43
3 files changed
+16 -10

No files matched your search

+12 -3
View File
@@ -39,6 +39,9 @@ public class Timing: MonoBehaviour {
Debug.Log("Track Sector Count - " + sectors.Length); Debug.Log("Track Sector Count - " + sectors.Length);
lapService = new LapService(mapName); lapService = new LapService(mapName);
}
void Start() {
StartCoroutine(lapService.GetPb()); StartCoroutine(lapService.GetPb());
} }
@@ -131,9 +134,15 @@ public class Timing: MonoBehaviour {
ui.HideRecentLap(); ui.HideRecentLap();
} }
public Lap PB => lapService.PB; public Lap PB() {
if (lapService == null) {
Debug.LogWarning("null lapservice");
return null;
}
return lapService.PB;
}
public TimingNotice PBSectorDiff(SectorTime s) => PB switch { public TimingNotice PBSectorDiff(SectorTime s) => PB() switch {
Lap pb => pb.Sectors.SingleOrDefault(fls => fls.Sector == s.Sector) switch { Lap pb => pb.Sectors.SingleOrDefault(fls => fls.Sector == s.Sector) switch {
SectorTime fastestSector => (new TimingNotice { Seconds = s.Seconds }).Compare(fastestSector.Seconds), SectorTime fastestSector => (new TimingNotice { Seconds = s.Seconds }).Compare(fastestSector.Seconds),
null => new TimingNotice { Seconds = s.Seconds }, // this one should never happen null => new TimingNotice { Seconds = s.Seconds }, // this one should never happen
@@ -141,7 +150,7 @@ public class Timing: MonoBehaviour {
null => new TimingNotice { Seconds = s.Seconds }, // there is no pb null => new TimingNotice { Seconds = s.Seconds }, // there is no pb
}; };
public TimingNotice PBLapDiff(Lap lap) => PB switch { public TimingNotice PBLapDiff(Lap lap) => PB() switch {
Lap pb => (new TimingNotice { Seconds = lap.TotalTime }).Compare(pb.TotalTime), Lap pb => (new TimingNotice { Seconds = lap.TotalTime }).Compare(pb.TotalTime),
null => new TimingNotice { Seconds = lap.TotalTime }, null => new TimingNotice { Seconds = lap.TotalTime },
}; };
+2 -6
View File
@@ -48,7 +48,7 @@ public class TimingUI : MonoBehaviour {
} }
void FixedUpdate() { void FixedUpdate() {
if (timer == null) { if (timer == null || timing == null) {
Debug.LogWarning("no timer"); Debug.LogWarning("no timer");
Init(); Init();
return; return;
@@ -64,7 +64,7 @@ public class TimingUI : MonoBehaviour {
if (timerSectors == null) if (timerSectors == null)
Debug.LogWarning("null timerSectors"); Debug.LogWarning("null timerSectors");
Lap timerPbLap = timing.PB; Lap timerPbLap = timing.PB();
if (timerPbLap != null) if (timerPbLap != null)
timerPb.text = $"{timerPbLap.ToString()}"; timerPb.text = $"{timerPbLap.ToString()}";
@@ -85,11 +85,7 @@ public class TimingUI : MonoBehaviour {
timer.AddToClassList("hidden"); timer.AddToClassList("hidden");
notice.RemoveFromClassList("hidden"); notice.RemoveFromClassList("hidden");
// fine
noticeTime.text = lap.ToString(); noticeTime.text = lap.ToString();
// should show the diff to the PB
// or - if there is only 1 lap
noticeDiff.Clear(); noticeDiff.Clear();
noticeDiff.Add(timing.PBLapDiff(lap).ToLabel()); noticeDiff.Add(timing.PBLapDiff(lap).ToLabel());
+2 -1
View File
@@ -1,12 +1,13 @@
# SpaceRace! # SpaceRace!
- post times to server - post times to server
- update on scene change
- check time is lower when posting - check time is lower when posting
- return pb and lap record - return pb and lap record
- convert laps to lapDTO? - convert laps to lapDTO?
- include sectors - include sectors
- controls diagram - controls
- mouse / controller sens - mouse / controller sens
- invert y - invert y