recent lap
This commit is contained in:
1 parent
daa84c8a9d
commit
69a97e3c76
6 files changed
+70
-38
No files matched your search
@@ -474,7 +474,7 @@ PrefabInstance:
|
||||
- target: {fileID: 5313449993149091347, guid: ebed5434f18ca13e38d2d7bfcc18d6c3, type: 3}
|
||||
propertyPath: shipControls
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
objectReference: {fileID: 699883395}
|
||||
- target: {fileID: 9074617566735061565, guid: ebed5434f18ca13e38d2d7bfcc18d6c3, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 4
|
||||
@@ -656,6 +656,17 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 7588376663361902483, guid: 73ab56de058af21389c312279181f856, type: 3}
|
||||
m_PrefabInstance: {fileID: 679062965}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &699883395 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 1093091269199902593, guid: 217f9c8f922f2d41cac52c3699bde478, type: 3}
|
||||
m_PrefabInstance: {fileID: 702758806}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 40716ff800be8d74ead775a18a496d89, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &702758806
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -664,6 +675,10 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 1093091269199902593, guid: 217f9c8f922f2d41cac52c3699bde478, type: 3}
|
||||
propertyPath: timing
|
||||
value:
|
||||
objectReference: {fileID: 1643546426}
|
||||
- target: {fileID: 3589635702276405719, guid: 217f9c8f922f2d41cac52c3699bde478, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 5
|
||||
@@ -1253,6 +1268,17 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 7588376663361902483, guid: 73ab56de058af21389c312279181f856, type: 3}
|
||||
m_PrefabInstance: {fileID: 1549479480}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1643546426 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 8438506523596255020, guid: dcb64e3a91f1fec7ab6098f4f407830b, type: 3}
|
||||
m_PrefabInstance: {fileID: 6345872851367721384}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 385acf04d40a396a9a95f738b7353198, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &1799749852
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1950,11 +1976,15 @@ PrefabInstance:
|
||||
- target: {fileID: 5975136821837370545, guid: dcb64e3a91f1fec7ab6098f4f407830b, type: 3}
|
||||
propertyPath: ship
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
objectReference: {fileID: 699883395}
|
||||
- target: {fileID: 5975136821837370545, guid: dcb64e3a91f1fec7ab6098f4f407830b, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8438506523596255020, guid: dcb64e3a91f1fec7ab6098f4f407830b, type: 3}
|
||||
propertyPath: ui
|
||||
value:
|
||||
objectReference: {fileID: 1292078235}
|
||||
- target: {fileID: 8438506523596255020, guid: dcb64e3a91f1fec7ab6098f4f407830b, type: 3}
|
||||
propertyPath: sectors.Array.size
|
||||
value: 2
|
||||
|
||||
+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,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +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: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-Light.otf?fileID=12800000&guid=54b9163f81dfb0d7baa7fda0d795ceeb&type=3#Jura-Light'); -unity-font-definition: initial; font-size: 16px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -1,14 +1,14 @@
|
||||
<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" />
|
||||
<Style src="project://database/Assets/Src/UI/TimingUi.uss?fileID=7433441132597879392&guid=cf92f075876ddf7ffb4cd5c59633ad7b&type=3#TimingUi" />
|
||||
<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="currentLap" 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; visibility: visible; display: flex;">
|
||||
<ui:VisualElement name="currentLap" 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="pbCompare" 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:VisualElement name="recentLap" 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="1:24.248" display-tooltip-when-elided="true" name="recentTime" style="align-self: flex-end; align-items: auto;" />
|
||||
<ui:Label tabindex="-1" text="-0.999" display-tooltip-when-elided="true" name="recentDiff" class="green" />
|
||||
</ui:VisualElement>
|
||||
|
||||
+11
-10
@@ -19,7 +19,7 @@ public class TimingUI : MonoBehaviour {
|
||||
Label recentTime;
|
||||
Label recentDiff;
|
||||
|
||||
VisualElement pbCompare;
|
||||
VisualElement recentLap;
|
||||
VisualElement currentLap;
|
||||
VisualElement sectors;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TimingUI : MonoBehaviour {
|
||||
void Init() {
|
||||
uiDocument = GetComponent<UIDocument>();
|
||||
|
||||
pbCompare = uiDocument.rootVisualElement.Q<VisualElement>("pbCompare");
|
||||
recentLap = uiDocument.rootVisualElement.Q<VisualElement>("recentLap");
|
||||
currentLap = uiDocument.rootVisualElement.Q<VisualElement>("currentLap");
|
||||
sectors = uiDocument.rootVisualElement.Q<VisualElement>("sectors");
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TimingUI : MonoBehaviour {
|
||||
pb.text = "-";
|
||||
|
||||
|
||||
pbCompare.AddToClassList("hidden");
|
||||
recentLap.AddToClassList("hidden");
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
@@ -76,17 +76,18 @@ public class TimingUI : MonoBehaviour {
|
||||
|
||||
sectors.Add(l);
|
||||
}
|
||||
|
||||
// if (timing.recentLap != null) ShowRecentLap()
|
||||
}
|
||||
|
||||
// yadad yadad
|
||||
void ShowRecentLap() {
|
||||
public void ShowRecentLap(Lap lap) {
|
||||
currentLap.AddToClassList("hidden");
|
||||
pbCompare.RemoveFromClassList("hidden");
|
||||
recentLap.RemoveFromClassList("hidden");
|
||||
recentTime.text = lap.ToString();
|
||||
recentDiff.text = lap.ToString();
|
||||
}
|
||||
|
||||
recentTime.text = timing.recentLap.ToString();
|
||||
// recentDiff = yadad
|
||||
public void HideRecentLap() {
|
||||
currentLap.RemoveFromClassList("hidden");
|
||||
recentLap.AddToClassList("hidden");
|
||||
}
|
||||
|
||||
Label SectorLabel(SectorTime s) {
|
||||
|
||||
@@ -10,24 +10,6 @@
|
||||
letter-spacing: 24px;
|
||||
}
|
||||
|
||||
#list-entry {
|
||||
height: 41px;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding-left: 10px;
|
||||
background-color: rgb(170, 89, 57);
|
||||
border-color: rgb(49, 26, 17);
|
||||
border-width: 2px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
#character-name {
|
||||
|
||||
-unity-font-style: bold;
|
||||
font-size: 18px;
|
||||
color: rgb(49, 26, 17);
|
||||
}
|
||||
|
||||
.green {
|
||||
color: var(--green);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user