game(scripts): standardise TrashBinTracker
This commit is contained in:
parent
8e1f74a92b
commit
5417c57b66
1 changed files with 13 additions and 14 deletions
|
@ -8,24 +8,24 @@ using UnityEngine;
|
||||||
|
|
||||||
public class TrashBinTracker : MonoBehaviour
|
public class TrashBinTracker : MonoBehaviour
|
||||||
{
|
{
|
||||||
private BedroomTask bedroomTask;
|
private BedroomTask _bedroomTask;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
// Find the BedroomTask script in the scene
|
// Find the BedroomTask script in the scene
|
||||||
bedroomTask = FindObjectOfType<BedroomTask>();
|
_bedroomTask = FindObjectOfType<BedroomTask>();
|
||||||
|
|
||||||
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)
|
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);
|
||||||
bedroomTask.CollectTrash();
|
|
||||||
Debug.Log("🗑️ Trash thrown in the bin! Count: " + bedroomTask.trashCollected);
|
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -33,5 +33,4 @@ public class TrashBinTracker : MonoBehaviour
|
||||||
Debug.LogError("BedroomTask reference is missing!");
|
Debug.LogError("BedroomTask reference is missing!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue