game: tried audio and it worksss
This commit is contained in:
parent
fa8ca2a41e
commit
29fe60bb58
2 changed files with 20 additions and 0 deletions
|
@ -138804,6 +138804,9 @@ MonoBehaviour:
|
|||
door: {fileID: 214241217}
|
||||
lockedDoorUI: {fileID: 1786768887}
|
||||
unlockedDoorUI: {fileID: 1654433218}
|
||||
audioSource: {fileID: 1898819871}
|
||||
lockedSound: {fileID: 8300000, guid: 66df24e59b960964d967e61a34192cc5, type: 3}
|
||||
unlockedSound: {fileID: 8300000, guid: 52fae69899b3fc24694a0f879a7d821a, type: 3}
|
||||
--- !u!43 &2060072005
|
||||
Mesh:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -35,6 +35,11 @@ public class BedroomTask : MonoBehaviour
|
|||
public GameObject lockedDoorUI;
|
||||
public GameObject unlockedDoorUI;
|
||||
|
||||
// Defines Audio References
|
||||
public AudioSource audioSource;
|
||||
public AudioClip lockedSound;
|
||||
public AudioClip unlockedSound;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Hide all UI prompts on start
|
||||
|
@ -75,6 +80,12 @@ public class BedroomTask : MonoBehaviour
|
|||
// If player has collected/thrown required amount of trash
|
||||
if (trashCollected >= trashRequired)
|
||||
{
|
||||
// Play sound only if no other sound is currently playing
|
||||
if (!audioSource.isPlaying)
|
||||
{
|
||||
audioSource.PlayOneShot(unlockedSound);
|
||||
}
|
||||
|
||||
// Call unlocking door function
|
||||
UnlockDoor();
|
||||
}
|
||||
|
@ -138,6 +149,12 @@ public class BedroomTask : MonoBehaviour
|
|||
// Show the locked door UI
|
||||
lockedDoorUI.SetActive(true);
|
||||
|
||||
// Play sound only if no other sound is currently playing
|
||||
if (!audioSource.isPlaying)
|
||||
{
|
||||
audioSource.PlayOneShot(lockedSound);
|
||||
}
|
||||
|
||||
// Call the function to hide the UI after delay
|
||||
StartCoroutine(HideMessageAfterSeconds(lockedDoorUI, 5f));
|
||||
Debug.Log("The door is locked! Clean the room first.");
|
||||
|
|
Loading…
Add table
Reference in a new issue