crosshair wip
This commit is contained in:
1 parent
c611014b88
commit
42fcc9fe1b
35 files changed
+1328
-1688
No files matched your search
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using System.IO;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public enum SectorColour {
|
||||
Green,
|
||||
Purple,
|
||||
White,
|
||||
Yellow,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct SectorTime {
|
||||
public int Sector;
|
||||
public double Seconds;
|
||||
public override string ToString() => $"{Seconds:0.000}";
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct Lap {
|
||||
public string Map;
|
||||
public int Number;
|
||||
public List<SectorTime> Sectors;
|
||||
|
||||
// 0:1:39
|
||||
public override string ToString() {
|
||||
return $"{TimeSpan.FromSeconds(TotalTime()):m\\:ss\\.fff}";
|
||||
}
|
||||
|
||||
public double TotalTime() {
|
||||
return Sectors.Sum(s => s.Seconds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class LapJSON {
|
||||
public string Map;
|
||||
public List<Lap> Laps = new();
|
||||
}
|
||||
|
||||
// We can't save a dictionary with the Unity JSONUtility
|
||||
// so we use this to hold a list of maps
|
||||
public class LapStorage {
|
||||
public List<LapJSON> Laps = new();
|
||||
}
|
||||
|
||||
static class LapStorageService {
|
||||
static Dictionary<string, LapJSON> lapsByMap = new();
|
||||
static string lapStoragePath = Path.Combine(Application.persistentDataPath, "lapStorage.json");
|
||||
|
||||
static LapStorageService() {
|
||||
LapStorage lapStorage = new LapStorage();
|
||||
|
||||
try {
|
||||
string json = File.ReadAllText(lapStoragePath);
|
||||
JsonUtility.FromJsonOverwrite(json, lapStorage);
|
||||
} catch {
|
||||
Debug.Log("No existing lapStorage.json");
|
||||
}
|
||||
|
||||
lapsByMap = lapStorage.Laps.ToDictionary((lapJson) => lapJson.Map);
|
||||
}
|
||||
|
||||
public static LapJSON GetPlayerLaps(string mapName) {
|
||||
LapJSON currentLaps;
|
||||
bool found = lapsByMap.TryGetValue(mapName, out currentLaps);
|
||||
if (!found)
|
||||
return new LapJSON { Map = mapName, Laps = new List<Lap>() };
|
||||
return currentLaps;
|
||||
}
|
||||
|
||||
static void Persist() {
|
||||
LapStorage lapStorage = new LapStorage { Laps = lapsByMap.Values.ToList() };
|
||||
File.WriteAllText(lapStoragePath, JsonUtility.ToJson(lapStorage));
|
||||
}
|
||||
|
||||
// laps.count
|
||||
public static int NumberOfCompletions() { return 0; }
|
||||
|
||||
// finds your PB in all completions
|
||||
public static int Rank() { return 1; }
|
||||
|
||||
public static void PersistLap(Lap lap) {
|
||||
LapJSON lapJson;
|
||||
bool found = lapsByMap.TryGetValue(lap.Map, out lapJson);
|
||||
if (!found)
|
||||
lapJson = new LapJSON { Map = lap.Map, Laps = new List<Lap>() };
|
||||
|
||||
// Add lap and persist
|
||||
lapJson.Laps.Add(lap);
|
||||
lapsByMap[lap.Map] = lapJson;
|
||||
Persist();
|
||||
}
|
||||
|
||||
public static Lap PB(string mapName) {
|
||||
return lapsByMap[mapName].Laps
|
||||
.MinBy(l => l.TotalTime());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f401855ddbefe813696eb36e638217df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+4
-91
@@ -8,97 +8,6 @@ using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public enum SectorColour {
|
||||
Green,
|
||||
Purple,
|
||||
White,
|
||||
Yellow,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct SectorTime {
|
||||
public int Sector;
|
||||
public double Seconds;
|
||||
public override string ToString() => $"{Seconds:0.000}";
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct Lap {
|
||||
public string Map;
|
||||
public int Number;
|
||||
public List<SectorTime> Sectors;
|
||||
|
||||
// 0:1:39
|
||||
public override string ToString() {
|
||||
return $"{TimeSpan.FromSeconds(TotalTime()):m\\:ss\\.fff}";
|
||||
}
|
||||
|
||||
public double TotalTime() {
|
||||
return Sectors.Sum(s => s.Seconds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class LapJSON {
|
||||
public string Map;
|
||||
public List<Lap> Laps = new();
|
||||
}
|
||||
|
||||
public class LapStorage {
|
||||
public List<LapJSON> Laps = new();
|
||||
}
|
||||
|
||||
static class LapStorageService {
|
||||
// static Dictionary<string, LapJSON> lapsByMap = new Dictionary<string, LapJSON>();
|
||||
static Dictionary<string, LapJSON> lapsByMap = new();
|
||||
static string lapStoragePath = Path.Combine(Application.persistentDataPath, "lapStorage.json");
|
||||
|
||||
static LapStorageService() {
|
||||
LapStorage lapStorage = new LapStorage();
|
||||
|
||||
try {
|
||||
string json = File.ReadAllText(lapStoragePath);
|
||||
JsonUtility.FromJsonOverwrite(json, lapStorage);
|
||||
} catch {
|
||||
Debug.Log("No existing lapStorage.json");
|
||||
}
|
||||
|
||||
lapsByMap = lapStorage.Laps.ToDictionary((lapJson) => lapJson.Map);
|
||||
}
|
||||
|
||||
public static LapJSON GetPlayerLaps(string mapName) {
|
||||
LapJSON currentLaps;
|
||||
bool found = lapsByMap.TryGetValue(mapName, out currentLaps);
|
||||
if (!found)
|
||||
return new LapJSON { Map = mapName, Laps = new List<Lap>() };
|
||||
return currentLaps;
|
||||
}
|
||||
|
||||
static void Persist() {
|
||||
LapStorage lapStorage = new LapStorage { Laps = lapsByMap.Values.ToList() };
|
||||
File.WriteAllText(lapStoragePath, JsonUtility.ToJson(lapStorage));
|
||||
}
|
||||
|
||||
// laps.count
|
||||
public static int NumberOfCompletions() { return 0; }
|
||||
|
||||
// finds your PB in all completions
|
||||
public static int Rank() { return 1; }
|
||||
|
||||
public static void PersistLap(Lap lap) {
|
||||
LapJSON lapJson;
|
||||
bool found = lapsByMap.TryGetValue(lap.Map, out lapJson);
|
||||
if (!found)
|
||||
lapJson = new LapJSON { Map = lap.Map, Laps = new List<Lap>() };
|
||||
|
||||
// Add lap and persist
|
||||
lapJson.Laps.Add(lap);
|
||||
lapsByMap[lap.Map] = lapJson;
|
||||
Persist();
|
||||
}
|
||||
}
|
||||
|
||||
public class Timing: MonoBehaviour {
|
||||
[SerializeField]
|
||||
public List<Lap> lapTimes;
|
||||
@@ -220,5 +129,9 @@ public class Timing: MonoBehaviour {
|
||||
false => SectorColour.Yellow,
|
||||
};
|
||||
}
|
||||
|
||||
public Lap PB() {
|
||||
return LapStorageService.PB(mapName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<Style src="project://database/Assets/Src/UI/TimingUi.uss?fileID=7433441132597879392&guid=cf92f075876ddf7ffb4cd5c59633ad7b&type=3#ShipUi" />
|
||||
<ui:VisualElement name="VisualElement" style="-unity-font: url('project://database/Assets/UI%20Toolkit/Fonts/Jura-Medium.otf?fileID=12800000&guid=65648a14640996362a6b0929c723b6e4&type=3#Jura-Medium'); -unity-font-definition: initial; flex-direction: row; flex-grow: 1;">
|
||||
<ui:VisualElement name="left" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); justify-content: center; align-items: center;" />
|
||||
<ui:VisualElement name="middle" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); justify-content: center; align-items: center;">
|
||||
<ui:Label tabindex="-1" text="128 u/s" display-tooltip-when-elided="true" name="speed" style="translate: 0 500%;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="right" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); justify-content: center; align-items: center;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0634235ba7ac8c449247dcb52927cd6
|
||||
guid: d5de5c7af6c565fbc9f4a345b0fddfd0
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class ControlsUI : MonoBehaviour {
|
||||
[SerializeField]
|
||||
ShipControls ship;
|
||||
|
||||
UIDocument uiDocument;
|
||||
Label speed;
|
||||
|
||||
void OnEnable() {
|
||||
Init();
|
||||
}
|
||||
|
||||
void Init() {
|
||||
uiDocument = GetComponent<UIDocument>();
|
||||
speed = uiDocument.rootVisualElement.Q<Label>("speed");
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
if (speed == null) {
|
||||
Debug.LogWarning("no speed");
|
||||
Init();
|
||||
return;
|
||||
}
|
||||
|
||||
speed.text = $"{ship.Speed():0} u/s";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8401c141ee093632d847505914412cee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,6 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<Style src="project://database/Assets/Src/UI/TimingUi.uss?fileID=7433441132597879392&guid=cf92f075876ddf7ffb4cd5c59633ad7b&type=3#ShipUi" />
|
||||
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); align-items: center; justify-content: center;">
|
||||
<ui:Label tabindex="-1" text="✛" display-tooltip-when-elided="true" style="opacity: 0.5; position: relative; -unity-text-align: middle-center; -unity-font: url('project://database/Assets/UI%20Toolkit/Fonts/Jura-Medium.otf?fileID=12800000&guid=65648a14640996362a6b0929c723b6e4&type=3#Jura-Medium'); -unity-font-definition: initial;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49cd8988c7a839e05b3f1bf56cd61792
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -1,5 +0,0 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<Style src="ShipUi.uss" />
|
||||
<ui:VisualElement name="lap-time-entry">
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,26 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<Style src="project://database/Assets/Src/UI/ShipUi.uss?fileID=7433441132597879392&guid=cf92f075876ddf7ffb4cd5c59633ad7b&type=3#ShipUi" />
|
||||
<ui:VisualElement name="Menu" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); -unity-font: url('project://database/Assets/UI%20Toolkit/Fonts/Jura-Medium.otf?fileID=12800000&guid=65648a14640996362a6b0929c723b6e4&type=3#Jura-Medium'); -unity-font-definition: initial; font-size: 38px; letter-spacing: 24px;">
|
||||
<ui:VisualElement name="header" style="flex-grow: 0; background-color: rgba(0, 0, 0, 0);" />
|
||||
<ui:VisualElement name="main" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); justify-content: flex-start; flex-direction: row; align-items: flex-start;">
|
||||
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0);">
|
||||
<ui:Label tabindex="-1" text="TRACK" display-tooltip-when-elided="true" name="Track" style="-unity-font: url('project://database/Assets/UI%20Toolkit/Fonts/Jura-DemiBold.otf?fileID=12800000&guid=1d103e83da4f14189b3e8b0b865eca3d&type=3#Jura-DemiBold');" />
|
||||
<ui:VisualElement name="tracks" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); justify-content: flex-start;">
|
||||
<ui:Button text="sr_junglism" display-tooltip-when-elided="true" />
|
||||
<ui:Button text="sr_silverstorage" display-tooltip-when-elided="true" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="settings" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-direction: column; align-self: auto; align-items: flex-end; display: flex; visibility: hidden;">
|
||||
<ui:Label tabindex="-1" text="SETTINGS" display-tooltip-when-elided="true" style="-unity-font: url('project://database/Assets/UI%20Toolkit/Fonts/Jura-DemiBold.otf?fileID=12800000&guid=1d103e83da4f14189b3e8b0b865eca3d&type=3#Jura-DemiBold');" />
|
||||
<ui:VisualElement name="controls" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); font-size: 24px;">
|
||||
<ui:Toggle label="Invert Y" name="Toggle" tooltip="NYI" />
|
||||
<ui:FloatField label="View Sensitivity" value="42.2" tooltip="NYI" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="footer" style="flex-grow: 0; background-color: rgba(0, 0, 0, 0); flex-direction: row; align-items: center; justify-content: space-between;">
|
||||
<ui:Label tabindex="-1" text="SpaceRace" display-tooltip-when-elided="true" name="title" style="font-size: 72px;" />
|
||||
<ui:Button text="EXIT" display-tooltip-when-elided="true" name="exit" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59e6af4d391d177a8910e7a8ab6e05e6
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -11,10 +11,10 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
|
||||
[SerializeField]
|
||||
ShipControls shipControls;
|
||||
|
||||
MenuUi menuUi;
|
||||
MenuUI menuUi;
|
||||
|
||||
[SerializeField]
|
||||
ShipUi shipUi;
|
||||
TimingUI timingUi;
|
||||
|
||||
SpaceRaceInput input;
|
||||
bool visible = false;
|
||||
@@ -28,7 +28,7 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
|
||||
}
|
||||
input.menu.Enable();
|
||||
|
||||
menuUi = GetComponent<MenuUi>();
|
||||
menuUi = GetComponent<MenuUI>();
|
||||
if (!menuUi) {
|
||||
Debug.LogError("No MenuUI");
|
||||
return;
|
||||
@@ -50,7 +50,7 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
|
||||
|
||||
// take control off the ship
|
||||
timingDoc.enabled = false;
|
||||
shipUi.enabled = false;
|
||||
timingUi.enabled = false;
|
||||
shipControls.enabled = false;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
|
||||
|
||||
// resume control of the ship
|
||||
timingDoc.enabled = true;
|
||||
shipUi.enabled = true;
|
||||
timingUi.enabled = true;
|
||||
shipControls.enabled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
using System.IO;
|
||||
|
||||
public class MenuUi : MonoBehaviour {
|
||||
public class MenuUI : MonoBehaviour {
|
||||
UIDocument uiDocument;
|
||||
VisualElement tracks;
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,18 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<Style src="project://database/Assets/Src/UI/TimingUi.uss?fileID=7433441132597879392&guid=cf92f075876ddf7ffb4cd5c59633ad7b&type=3#ShipUi" />
|
||||
<ui:VisualElement name="shipUi" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); color: rgb(255, 255, 255); font-size: 28px; -unity-font: url('project://database/Assets/UI%20Toolkit/Fonts/Jura-Medium.otf?fileID=12800000&guid=65648a14640996362a6b0929c723b6e4&type=3#Jura-Medium'); -unity-font-definition: initial;">
|
||||
<ui:VisualElement name="Top" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="Middle" style="flex-grow: 1; align-items: center;" />
|
||||
<ui:VisualElement name="Bottom" style="flex-grow: 0; background-color: rgba(0, 0, 0, 0.26); flex-direction: column; align-items: stretch; justify-content: flex-end; color: rgb(255, 255, 255); width: 33%; align-self: center;">
|
||||
<ui:VisualElement name="upper" 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;">
|
||||
<ui:Label tabindex="-1" text="Time" display-tooltip-when-elided="true" name="timer" style="align-self: flex-end; align-items: auto;" />
|
||||
<ui:Label tabindex="-1" text="1:28.248" display-tooltip-when-elided="true" name="pb" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="sectors" style="flex-grow: 0; background-color: rgba(0, 0, 0, 0); flex-direction: row; align-self: stretch; align-items: stretch; justify-content: space-between;">
|
||||
<ui:Label tabindex="-1" text="32.0" display-tooltip-when-elided="true" class="yellow" />
|
||||
<ui:Label tabindex="-1" text="64.0" display-tooltip-when-elided="true" class="green" style="-unity-font-style: normal; -unity-font: url('project://database/Assets/UI%20Toolkit/Fonts/Jura-Medium.otf?fileID=12800000&guid=65648a14640996362a6b0929c723b6e4&type=3#Jura-Medium');" />
|
||||
<ui:Label tabindex="-1" text="1:28.8" display-tooltip-when-elided="true" class="purple" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b8620c717c8ee2edafdfb5f4efa79cb
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class ShipUi : MonoBehaviour {
|
||||
public class TimingUI : MonoBehaviour {
|
||||
UIDocument uiDocument;
|
||||
|
||||
[SerializeField]
|
||||
@@ -14,8 +14,8 @@ public class ShipUi : MonoBehaviour {
|
||||
[SerializeField]
|
||||
Timing timing;
|
||||
|
||||
Label speed;
|
||||
Label timer;
|
||||
Label pb;
|
||||
VisualElement sectors;
|
||||
VisualElement timeSheet;
|
||||
|
||||
@@ -25,39 +25,31 @@ public class ShipUi : MonoBehaviour {
|
||||
|
||||
void Init() {
|
||||
uiDocument = GetComponent<UIDocument>();
|
||||
speed = uiDocument.rootVisualElement.Q<Label>("speed");
|
||||
timer = uiDocument.rootVisualElement.Q<Label>("timer");
|
||||
pb = uiDocument.rootVisualElement.Q<Label>("pb");
|
||||
sectors = uiDocument.rootVisualElement.Q<VisualElement>("sectors");
|
||||
timeSheet = uiDocument.rootVisualElement.Q<VisualElement>("timeSheet");
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
if (timer == null || speed == null) {
|
||||
if (timer == null) {
|
||||
Debug.LogWarning("no speed or timer");
|
||||
Init();
|
||||
return;
|
||||
}
|
||||
|
||||
timer.text = $"{TimeSpan.FromSeconds(timing.lapTime):m\\:ss\\.fff}";
|
||||
speed.text = $"{ship.Speed():0} u/s";
|
||||
|
||||
// clearly this is not ideal but idk atm
|
||||
UpdateTimesheet();
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
public void UpdateTimesheet() {
|
||||
public void UpdateUI() {
|
||||
if (sectors == null)
|
||||
Debug.LogWarning("null sectors");
|
||||
|
||||
timeSheet.Clear();
|
||||
foreach (Lap lap in LapStorageService.GetPlayerLaps(timing.mapName).Laps) {
|
||||
Label l = new Label();
|
||||
l.text = $"{lap}";
|
||||
timeSheet.Add(l);
|
||||
}
|
||||
pb.text = $"PB: {timing.PB().ToString()}";
|
||||
|
||||
sectors.Clear();
|
||||
|
||||
foreach (Sector sector in timing.sectors) {
|
||||
Label l = timing.sectorTimes
|
||||
.Where(s => s.Sector == sector.sector)
|
||||
File renamed without changes.
@@ -8,7 +8,6 @@
|
||||
color: var(--white);
|
||||
font-size: 24px;
|
||||
letter-spacing: 24px;
|
||||
unity-font: "Jura Medium";
|
||||
}
|
||||
|
||||
#list-entry {
|
||||
File renamed without changes.
Reference in new issue
Block a user