changed maps but lighting fked

This commit is contained in:
ntr committed 2023-09-11 13:12:08 +10:00
1 parent 6e9d834cfd
commit 7e0703975d
54 files changed
+75740 -8208

No files matched your search

+5 -2
View File
@@ -21,6 +21,9 @@ public class LapService {
public Lap Pb;
public Lap LapRecord;
// static string apiEndpoint = "https://spacerace.systems/api";
static string apiEndpoint = "http://localhost:40080";
public string Position => _pb switch {
PbDTO pb => pb.Position.ToString(),
null => "-",
@@ -37,7 +40,7 @@ public class LapService {
}
public IEnumerator GetLapTimes() {
string uri = $"https://spacerace.systems/api/LapTimes?userId={_player.Id}&mapName={_mapName}";
string uri = $"{apiEndpoint}/LapTimes?userId={_player.Id}&mapName={_mapName}";
using (UnityWebRequest req = UnityWebRequest.Get(uri)) {
yield return req.SendWebRequest();
@@ -90,7 +93,7 @@ public class LapService {
Debug.Log($"Posting lap: {JsonConvert.SerializeObject(dto)}");
using (UnityWebRequest req = UnityWebRequest.Post("https://spacerace.systems/api/Lap", JsonConvert.SerializeObject(dto), "application/json")) {
using (UnityWebRequest req = UnityWebRequest.Post($"{apiEndpoint}/Lap", JsonConvert.SerializeObject(dto), "application/json")) {
yield return req.SendWebRequest();
if (req.result != UnityWebRequest.Result.Success) {
+2 -2
View File
@@ -29,7 +29,7 @@ public class TimingNotice {
public Label ToLabel() {
Label l = Category switch {
NoticeCategory.Initial => new Label($"{TimeSpan.FromSeconds(Seconds):m\\:ss\\.fff}"),
NoticeCategory.Slower => new Label($"+{Seconds:0.000}"),
NoticeCategory.Slower => new Label($"-{Seconds:0.000}"),
NoticeCategory.Faster => new Label($"-{Seconds:0.000}"),
NoticeCategory.Fastest => new Label($"-{Seconds:0.000}"),
_ => new Label($"-{Seconds:0.000}"),
@@ -37,7 +37,7 @@ public class TimingNotice {
string colourClass = Category switch {
NoticeCategory.Initial => "",
NoticeCategory.Slower => "yellow",
NoticeCategory.Slower => "green",
NoticeCategory.Faster => "green",
NoticeCategory.Fastest => "purple",
_ => "",
+11 -6
View File
@@ -26,8 +26,6 @@ public class Timing: MonoBehaviour {
IEnumerator noticeLifecycle;
public string Position => $"{lapService.Position} / {lapService.Completions}";
void Awake() {
ui = GetComponent<TimingUI>();
sectorTimes = new List<SectorTime>();
@@ -49,6 +47,12 @@ public class Timing: MonoBehaviour {
}
void Update() {
// hmr
if (lapService == null) {
Awake();
Start();
}
if (timerEnabled) {
sectorTime = Time.timeAsDouble - sectorStart;
lapTime = Time.timeAsDouble - lapStart;
@@ -127,8 +131,7 @@ public class Timing: MonoBehaviour {
if (noticeLifecycle != null) StopCoroutine(noticeLifecycle);
noticeLifecycle = RecentLapLifecycle(l);
StartCoroutine(noticeLifecycle);
StartCoroutine(lapService.PostLap(l));
StartCoroutine(lapService?.PostLap(l));
}
IEnumerator RecentLapLifecycle(Lap l) {
@@ -137,8 +140,10 @@ public class Timing: MonoBehaviour {
ui.HideRecentLap();
}
public Lap LapRecord => lapService.LapRecord;
public Lap Pb => lapService.Pb;
// these can be null after HMR
public Lap LapRecord => lapService?.LapRecord;
public Lap Pb => lapService?.Pb;
public string Position => $"{lapService?.Position} / {lapService?.Completions}";
public TimingNotice CompareLap(Lap lap) {
double? lrSeconds = LapRecord != null ? LapRecord.TotalTime : null;
+1 -1
View File
@@ -6,7 +6,7 @@
<ui:VisualElement name="Bottom" class="bottom">
<ui:VisualElement name="notice" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0);">
<ui:VisualElement name="timerDesc" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-direction: row; justify-content: space-between; align-items: auto; width: auto; align-self: stretch; flex-shrink: 0; font-size: 14px; color: rgb(245, 245, 245);">
<ui:Label tabindex="-1" display-tooltip-when-elided="true" name="msg" style="align-self: flex-end; align-items: auto;" />
<ui:Label tabindex="-1" display-tooltip-when-elided="true" name="noticeMsg" style="align-self: flex-end; align-items: auto;" />
<ui:Label tabindex="-1" display-tooltip-when-elided="true" name="noticePosition" text="5 / 128" />
</ui:VisualElement>
<ui:VisualElement name="noticeLap" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-direction: row; justify-content: space-between; align-items: auto; width: auto; align-self: stretch; flex-shrink: 0;">
+21 -1
View File
@@ -21,9 +21,18 @@ public class TimingUI : MonoBehaviour {
VisualElement notice;
VisualElement noticeSectors;
VisualElement noticeDiff;
Label noticeMsg;
Label noticeTime;
Label noticePosition;
static string[] completionMsgs = {
"smooth",
"very fast",
"well done",
"ナイス",
"(⌐▨_▨)",
};
void OnEnable() {
Init();
}
@@ -38,6 +47,7 @@ public class TimingUI : MonoBehaviour {
timer = uiDocument.rootVisualElement.Q<VisualElement>("timer");
timerSectors = uiDocument.rootVisualElement.Q<VisualElement>("timerSectors");
noticeMsg = uiDocument.rootVisualElement.Q<Label>("noticeMsg");
noticeTime = uiDocument.rootVisualElement.Q<Label>("noticeTime");
noticeDiff = uiDocument.rootVisualElement.Q<VisualElement>("noticeDiff");
@@ -68,8 +78,15 @@ public class TimingUI : MonoBehaviour {
}
public void UpdateUI() {
if (timerSectors == null)
if (timerSectors == null) {
Debug.LogWarning("null timerSectors");
return;
}
if (timing == null) {
Debug.LogWarning("null timing");
return;
}
Lap timerPbLap = timing.Pb;
if (timerPbLap != null)
@@ -100,6 +117,9 @@ public class TimingUI : MonoBehaviour {
noticeDiff.Clear();
noticeDiff.Add(timing.CompareLap(lap).ToLabel());
int msgIndex = UnityEngine.Random.Range(0, completionMsgs.Length);
noticeMsg.text = completionMsgs[msgIndex];
noticeSectors.Clear();
foreach (SectorTime sector in lap.Sectors) {
Label l = timing.CompareSector(sector).ToLabel();