vdfs n idk what else

This commit is contained in:
ntr committed 2023-10-02 19:18:36 +11:00
1 parent 51a9dccd97
commit 3c211a56fb
15 files changed
+130 -11

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ public enum NoticeCategory {
public class TimingNotice {
double Seconds;
NoticeCategory Category = NoticeCategory.Initial;
public NoticeCategory Category = NoticeCategory.Initial;
public static TimingNotice Compare(double seconds, double? pbSeconds = null, double? lrSeconds = null) => lrSeconds switch {
double lr when seconds < lr => new TimingNotice { Seconds = Math.Abs(lr - seconds), Category = NoticeCategory.Fastest },
+1
View File
@@ -36,6 +36,7 @@ public class PowerUnit {
static float shieldBoostAmount = 1000f;
public float Shield => shieldCurrent;
public float ShieldMax => shieldMax;
public string ShieldPct => $"{((shieldCurrent / shieldMax) * 100f):0}";
bool UsingMovementBoost => BoostActive.Any(b => b.output != Output.Shield);
+9 -1
View File
@@ -205,14 +205,22 @@ public class ShipControls : MonoBehaviour {
audio.PlayNoise();
// convert dmg to % to hide internals
float dmg = (amt / powerUnit.ShieldMax) * 100f;
timing.Message($"{dmg:0} Damage");
bool destroyed = powerUnit.ShieldReduce(amt);
if (destroyed) {
Debug.Log($"Ddddestroyed by {src}");
// play big noise!
Respawn();
}
}
public void OnTrackLimits() {
timing.Message("Track Limits");
Respawn();
}
void Deploy(Output output) {
bool deployed = powerUnit.Deploy(output);
if (deployed) audio.PlayNoise();
+2 -1
View File
@@ -10,13 +10,14 @@ public class ShipPhysics : MonoBehaviour {
void OnCollisionEnter(Collision collision) {
if (collision.gameObject.tag == "TrackLimits") {
Debug.Log("Track Limits " + collision.gameObject.name);
ship.Respawn();
ship.OnTrackLimits();
return;
}
float totalForce = collision.impulse.magnitude / Time.fixedDeltaTime;
Debug.Log($"mag {collision.relativeVelocity.magnitude}");
Debug.Log($"impulse {collision.impulse} {collision.impulse.magnitude} {totalForce}");
if (totalForce < 1f) return;
ship.Damage(totalForce, collision.gameObject.name);
}
}
+14 -1
View File
@@ -28,6 +28,7 @@ public class Timing: MonoBehaviour {
double lapStart;
IEnumerator noticeLifecycle;
IEnumerator msgLifecycle;
void Awake() {
ui = GetComponent<TimingUI>();
@@ -146,10 +147,22 @@ public class Timing: MonoBehaviour {
IEnumerator RecentLapLifecycle(Lap l) {
ui.ShowRecentLap(l);
yield return new WaitForSeconds(5);
yield return new WaitForSeconds(10);
ui.HideRecentLap();
}
public void Message(string msg) {
if (msgLifecycle != null) StopCoroutine(msgLifecycle);
msgLifecycle = ShowMessage(msg);
StartCoroutine(msgLifecycle);
}
IEnumerator ShowMessage(string msg) {
ui.ShowMessage(msg);
yield return new WaitForSeconds(5);
ui.HideMessage();
}
// these can be null after HMR
public Lap LapRecord => lapService?.LapRecord;
public Lap Pb => lapService?.Pb;
+19 -3
View File
@@ -14,6 +14,7 @@ public class TimingUI : MonoBehaviour {
VisualElement timer;
VisualElement timerSectors;
Label timerMsg;
Label timerTime;
Label timerPb;
Label timerPosition;
@@ -62,6 +63,7 @@ public class TimingUI : MonoBehaviour {
noticeTime = uiDocument.rootVisualElement.Q<Label>("noticeTime");
noticeDiff = uiDocument.rootVisualElement.Q<VisualElement>("noticeDiff");
timerMsg = uiDocument.rootVisualElement.Q<Label>("msg");
timerTime = uiDocument.rootVisualElement.Q<Label>("timerTime");
timerPb = uiDocument.rootVisualElement.Q<Label>("timerPb");
@@ -124,12 +126,17 @@ public class TimingUI : MonoBehaviour {
timer.AddToClassList("hidden");
notice.RemoveFromClassList("hidden");
TimingNotice lapNotice = timing.CompareLap(lap);
noticeTime.text = lap.ToString();
noticeDiff.Clear();
noticeDiff.Add(timing.CompareLap(lap).ToLabel());
noticeDiff.Add(lapNotice.ToLabel());
// int msgIndex = UnityEngine.Random.Range(0, completionMsgs.Length);
// noticeMsg.text = completionMsgs[msgIndex];
if (lapNotice.Category == NoticeCategory.Faster) ShowMessage("New PB!");
if (lapNotice.Category == NoticeCategory.Fastest) {
int msgIndex = UnityEngine.Random.Range(0, completionMsgs.Length);
ShowMessage(completionMsgs[msgIndex]);
}
noticeSectors.Clear();
foreach (SectorTime sector in lap.Sectors) {
@@ -140,7 +147,16 @@ public class TimingUI : MonoBehaviour {
public void HideRecentLap() {
Init();
HideMessage();
timer.RemoveFromClassList("hidden");
notice.AddToClassList("hidden");
}
public void ShowMessage(string msg) {
timerMsg.text = msg;
}
public void HideMessage() {
timerMsg.text = "";
}
}