From 5417c57b6602b6c7b94cc4a9aad6869eafba4272 Mon Sep 17 00:00:00 2001 From: Mark Joshwel Date: Sat, 15 Feb 2025 00:36:32 +0800 Subject: [PATCH] game(scripts): standardise TrashBinTracker --- Game/Assets/Scripts/TrashBinTracker.cs | 27 +++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/Game/Assets/Scripts/TrashBinTracker.cs b/Game/Assets/Scripts/TrashBinTracker.cs index 713d954..12373e9 100644 --- a/Game/Assets/Scripts/TrashBinTracker.cs +++ b/Game/Assets/Scripts/TrashBinTracker.cs @@ -8,30 +8,29 @@ using UnityEngine; public class TrashBinTracker : MonoBehaviour { - private BedroomTask bedroomTask; + private BedroomTask _bedroomTask; private void Start() { // Find the BedroomTask script in the scene - bedroomTask = FindObjectOfType(); + _bedroomTask = FindObjectOfType(); - if (bedroomTask == null) Debug.LogWarning("BedroomTask script not found in the scene!"); + if (_bedroomTask == null) Debug.LogWarning("BedroomTask script not found in the scene!"); } private void OnTriggerEnter(Collider other) { - if (other.CompareTag("TrashBin")) + if (!other.CompareTag("TrashBin")) return; + + if (_bedroomTask != null) { - if (bedroomTask != null) - { - bedroomTask.CollectTrash(); - Debug.Log("🗑️ Trash thrown in the bin! Count: " + bedroomTask.trashCollected); - Destroy(gameObject); - } - else - { - Debug.LogError("BedroomTask reference is missing!"); - } + _bedroomTask.CollectTrash(); + Debug.Log("🗑️ Trash thrown in the bin! Count: " + _bedroomTask.trashCollected); + Destroy(gameObject); + } + else + { + Debug.LogError("BedroomTask reference is missing!"); } } } \ No newline at end of file