2025-02-04 09:08:06 +08:00
|
|
|
/*
|
|
|
|
Author: Reza
|
|
|
|
Date: 3/2/25
|
|
|
|
Description: To track if cleaning/exploring bedroom task is done before allowing player to open door
|
|
|
|
*/
|
|
|
|
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2025-02-04 12:03:44 +08:00
|
|
|
using UnityEngine.ProBuilder.Shapes;
|
2025-02-04 09:08:06 +08:00
|
|
|
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
|
|
|
|
|
|
|
public class BedroomTask : MonoBehaviour
|
|
|
|
{
|
2025-02-04 12:03:44 +08:00
|
|
|
public int trashCollected = 0;
|
|
|
|
public int trashToUnlock = 1;
|
2025-02-04 09:08:06 +08:00
|
|
|
public GameObject door;
|
|
|
|
public XRGrabInteractable doorInteractable;
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
2025-02-04 12:03:44 +08:00
|
|
|
if (door != null)
|
|
|
|
{
|
|
|
|
doorInteractable = door.GetComponent<XRGrabInteractable>();
|
|
|
|
if (doorInteractable != null)
|
|
|
|
{
|
|
|
|
doorInteractable.enabled = false;
|
|
|
|
Debug.Log("Room is not cleaned! Door is locked");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void CollectTrash()
|
|
|
|
{
|
|
|
|
trashCollected++;
|
|
|
|
Debug.Log("Trash Collected: " + trashCollected + "/" + trashToUnlock);
|
|
|
|
|
|
|
|
if (trashCollected >= trashToUnlock)
|
|
|
|
{
|
|
|
|
UnlockDoor();
|
|
|
|
Debug.Log("Cleaning task completed! Unlocking door...");
|
|
|
|
}
|
2025-02-04 09:08:06 +08:00
|
|
|
}
|
|
|
|
|
2025-02-04 12:03:44 +08:00
|
|
|
private void UnlockDoor()
|
2025-02-04 09:08:06 +08:00
|
|
|
{
|
2025-02-04 12:03:44 +08:00
|
|
|
doorInteractable.enabled = true;
|
|
|
|
Debug.Log("Room is cleaned! Door unlocked");
|
2025-02-04 09:08:06 +08:00
|
|
|
}
|
|
|
|
}
|