This commit is contained in:
ntr committed 2023-08-09 17:23:19 +10:00
1 parent b65814e4af
commit d291dc5a06
5 files changed
+97 -36

No files matched your search

+6
View File
@@ -11,6 +11,12 @@
<ui:Label tabindex="-1" display-tooltip-when-elided="true" name="shields" text="100" style="min-width: 5%; -unity-text-align: upper-right; flex-basis: 10%;" />
<ui:Label tabindex="-1" text="%" display-tooltip-when-elided="true" name="units" style="flex-basis: 10%; -unity-text-align: upper-left;" />
</ui:VisualElement>
<ui:VisualElement name="puCtr" style="flex-direction: row;">
<ui:Label tabindex="-1" display-tooltip-when-elided="true" name="puAccel" text="100" />
<ui:Label tabindex="-1" text="100" display-tooltip-when-elided="true" name="puDecel" />
<ui:Label tabindex="-1" text="100" display-tooltip-when-elided="true" name="puStrafe" />
<ui:Label tabindex="-1" text="100" display-tooltip-when-elided="true" name="puShield" />
</ui:VisualElement>
<ui:VisualElement name="middleBottom" style="flex-grow: 0; background-color: rgba(0, 0, 0, 0); flex-shrink: 0; flex-basis: 20%;" />
</ui:VisualElement>
<ui:VisualElement name="right" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); justify-content: center; align-items: center;" />
+16 -1
View File
@@ -12,6 +12,10 @@ public class ControlsUI : MonoBehaviour {
UIDocument uiDocument;
Label speed;
Label shields;
Label puAccel;
Label puDecel;
Label puStrafe;
Label puShield;
void OnEnable() {
Init();
@@ -21,6 +25,12 @@ public class ControlsUI : MonoBehaviour {
uiDocument = GetComponent<UIDocument>();
speed = uiDocument.rootVisualElement.Q<Label>("speed");
shields = uiDocument.rootVisualElement.Q<Label>("shields");
// PowerUnit
puAccel = uiDocument.rootVisualElement.Q<Label>("puAccel");
puDecel = uiDocument.rootVisualElement.Q<Label>("puDecel");
puStrafe = uiDocument.rootVisualElement.Q<Label>("puStrafe");
puShield = uiDocument.rootVisualElement.Q<Label>("puShield");
}
void FixedUpdate() {
@@ -31,6 +41,11 @@ public class ControlsUI : MonoBehaviour {
}
speed.text = $"{ship.Speed():0}";
shields.text = ship.Shields;
shields.text = ship.powerUnit.ShieldsPct;
puAccel.text = ship.powerUnit.Acceleration.ToString();
puDecel.text = ship.powerUnit.Deceleration.ToString();
puStrafe.text = ship.powerUnit.Strafing.ToString();
puShield.text = ship.powerUnit.ShieldsMax.ToString();
}
}