From ccb85b2ca6e541d4d5af2a84158b1a35a348c7aa Mon Sep 17 00:00:00 2001 From: pyoneerC Date: Mon, 23 Sep 2024 17:49:42 -0300 Subject: [PATCH] fix: no repair on end overlap --- Assets/Scripts/FixLogic.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/FixLogic.cs b/Assets/Scripts/FixLogic.cs index 8121ead..4cb82e1 100644 --- a/Assets/Scripts/FixLogic.cs +++ b/Assets/Scripts/FixLogic.cs @@ -23,6 +23,7 @@ private void OnTriggerExit(Collider other) if (!other.CompareTag("Leak")) return; _isOverlapping = false; _currentLeak = null; + audioSource.Stop(); Debug.Log("Exited leak area."); } @@ -46,6 +47,13 @@ private IEnumerator FixLeak() yield return null; } + if (!_isOverlapping || _currentLeak == null) + { + Debug.Log("No longer overlapping with leak. Fix aborted."); + _isFixing = false; + yield break; + } + fixedCount++; Debug.Log("Leak fixed! Total fixed leaks: " + fixedCount); @@ -60,7 +68,7 @@ private IEnumerator FixLeak() Destroy(child.gameObject); } } - + Destroy(_currentLeak); } @@ -73,8 +81,8 @@ private IEnumerator FixLeak() _isFixing = false; } - private void GameOver() + private static void GameOver() { Debug.Log("Game Over! You fixed 7 leaks."); } -} \ No newline at end of file +}