diff --git a/Assets/Scenes/sr_junglism2.unity b/Assets/Scenes/sr_junglism2.unity index 32e6c9d..d941f52 100755 --- a/Assets/Scenes/sr_junglism2.unity +++ b/Assets/Scenes/sr_junglism2.unity @@ -12243,6 +12243,10 @@ PrefabInstance: propertyPath: ship value: objectReference: {fileID: 2015948214} + - target: {fileID: 8438506523596255020, guid: dcb64e3a91f1fec7ab6098f4f407830b, type: 3} + propertyPath: audio + value: + objectReference: {fileID: 2015948217} m_RemovedComponents: [] m_RemovedGameObjects: - {fileID: 968610525847117003, guid: dcb64e3a91f1fec7ab6098f4f407830b, type: 3} diff --git a/Assets/Src/Laps.cs b/Assets/Src/Laps.cs index 2c2ba82..8524371 100644 --- a/Assets/Src/Laps.cs +++ b/Assets/Src/Laps.cs @@ -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 }, diff --git a/Assets/Src/PowerUnit.cs b/Assets/Src/PowerUnit.cs index 10e45f8..a781f61 100644 --- a/Assets/Src/PowerUnit.cs +++ b/Assets/Src/PowerUnit.cs @@ -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); diff --git a/Assets/Src/ShipControls.cs b/Assets/Src/ShipControls.cs index 9cd5cc5..0ae9869 100755 --- a/Assets/Src/ShipControls.cs +++ b/Assets/Src/ShipControls.cs @@ -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(); diff --git a/Assets/Src/ShipPhysics.cs b/Assets/Src/ShipPhysics.cs index 68e2f47..2ee9915 100644 --- a/Assets/Src/ShipPhysics.cs +++ b/Assets/Src/ShipPhysics.cs @@ -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); } } \ No newline at end of file diff --git a/Assets/Src/Timing.cs b/Assets/Src/Timing.cs index 4d5af90..c3990dd 100644 --- a/Assets/Src/Timing.cs +++ b/Assets/Src/Timing.cs @@ -28,6 +28,7 @@ public class Timing: MonoBehaviour { double lapStart; IEnumerator noticeLifecycle; + IEnumerator msgLifecycle; void Awake() { ui = GetComponent(); @@ -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; diff --git a/Assets/Src/UI/TimingUI.cs b/Assets/Src/UI/TimingUI.cs index eeb182d..b851b76 100644 --- a/Assets/Src/UI/TimingUI.cs +++ b/Assets/Src/UI/TimingUI.cs @@ -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