wirm/Game/Assets/Scripts/Trash.cs
yauwailam ceeeb08400 game(many,day2): half-working fixes, game still does not compile
sorry isaac wait a while just chill w ya friends
2025-02-14 18:05:52 +08:00

42 lines
No EOL
1,016 B
C#

/*
Author: Reza
Date: 4/2/25
Description: To track how much trash has been thrown in the trashbin
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Trash : MonoBehaviour
{
private BedroomTask bedroomTask;
private void Start()
{
// Find the BedroomTask script in the scene
bedroomTask = FindObjectOfType<BedroomTask>();
if (bedroomTask == null)
{
Debug.LogWarning("BedroomTask script not found in the scene!");
}
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("TrashBin"))
{
if (bedroomTask != null)
{
bedroomTask.CollectTrash();
Debug.Log("🗑️ Trash thrown in the bin! Count: " + bedroomTask.trashCollected);
Destroy(gameObject);
}
else
{
Debug.LogError("BedroomTask reference is missing!");
}
}
}
}