game: misc (bedroom task isnt fully working yet)
This commit is contained in:
parent
135579f366
commit
d9741b0290
3 changed files with 48 additions and 11 deletions
|
@ -315240,6 +315240,7 @@ GameObject:
|
||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 2057524443}
|
- component: {fileID: 2057524443}
|
||||||
|
- component: {fileID: 2057524444}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Bedroom Task
|
m_Name: Bedroom Task
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -315262,6 +315263,22 @@ Transform:
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &2057524444
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2057524442}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5400e1a957408e941ba95a252e2d15b0, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
trashCollected: 0
|
||||||
|
trashToUnlock: 10
|
||||||
|
door: {fileID: 61007070}
|
||||||
|
doorInteractable: {fileID: 61007073}
|
||||||
--- !u!43 &2057535447
|
--- !u!43 &2057535447
|
||||||
Mesh:
|
Mesh:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -4,28 +4,48 @@ Date: 3/2/25
|
||||||
Description: To track if cleaning/exploring bedroom task is done before allowing player to open door
|
Description: To track if cleaning/exploring bedroom task is done before allowing player to open door
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.ProBuilder.Shapes;
|
||||||
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
||||||
|
|
||||||
public class BedroomTask : MonoBehaviour
|
public class BedroomTask : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public int trashCollected = 0;
|
||||||
|
public int trashToUnlock = 1;
|
||||||
public GameObject door;
|
public GameObject door;
|
||||||
public XRGrabInteractable doorInteractable;
|
public XRGrabInteractable doorInteractable;
|
||||||
|
|
||||||
private bool taskCompleted = false;
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
if (door != null)
|
||||||
|
{
|
||||||
|
doorInteractable = door.GetComponent<XRGrabInteractable>();
|
||||||
|
if (doorInteractable != null)
|
||||||
|
{
|
||||||
|
doorInteractable.enabled = false;
|
||||||
|
Debug.Log("Room is not cleaned! Door is locked");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
public void CollectTrash()
|
||||||
void Update()
|
|
||||||
{
|
{
|
||||||
|
trashCollected++;
|
||||||
|
Debug.Log("Trash Collected: " + trashCollected + "/" + trashToUnlock);
|
||||||
|
|
||||||
|
if (trashCollected >= trashToUnlock)
|
||||||
|
{
|
||||||
|
UnlockDoor();
|
||||||
|
Debug.Log("Cleaning task completed! Unlocking door...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UnlockDoor()
|
||||||
|
{
|
||||||
|
doorInteractable.enabled = true;
|
||||||
|
Debug.Log("Room is cleaned! Door unlocked");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,14 @@ using UnityEngine;
|
||||||
|
|
||||||
public class Trash : MonoBehaviour
|
public class Trash : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static int trashCollected = 0;
|
private BedroomTask bedroomTask;
|
||||||
|
|
||||||
private void OnTriggerEnter(Collider other)
|
private void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
if (other.gameObject.CompareTag("TrashBin"))
|
if (other.CompareTag("TrashBin"))
|
||||||
{
|
{
|
||||||
trashCollected++;
|
bedroomTask.CollectTrash();
|
||||||
Debug.Log("Trash thrown in the bin! Count: " + trashCollected);
|
Debug.Log("Trash thrown in the bin! Count: " + bedroomTask.trashCollected);
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue