game(scripts): standardise BedroomTask
This commit is contained in:
parent
fb236bd1bc
commit
23122b395b
1 changed files with 21 additions and 25 deletions
|
@ -106,13 +106,11 @@ public class BedroomTask : MonoBehaviour
|
||||||
{
|
{
|
||||||
yield return new WaitForSeconds(0.5f); // Small delay to ensure a smooth transition
|
yield return new WaitForSeconds(0.5f); // Small delay to ensure a smooth transition
|
||||||
|
|
||||||
if (storyPanelUI != null && storyText != null)
|
if (!storyPanelUI || storyText == null) yield break;
|
||||||
{
|
|
||||||
storyPanelUI.SetActive(true);
|
storyPanelUI.SetActive(true);
|
||||||
storyText.text = "My parents are still home... I should clean up first.";
|
storyText.text = "My parents are still home... I should clean up first.";
|
||||||
StartCoroutine(ClearMessageAfterSeconds(7f));
|
StartCoroutine(ClearMessageAfterSeconds(7f));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Functions when trash is collected/thrown
|
// Functions when trash is collected/thrown
|
||||||
public void CollectTrash()
|
public void CollectTrash()
|
||||||
|
@ -126,8 +124,8 @@ public class BedroomTask : MonoBehaviour
|
||||||
Debug.Log($"Trash collected: {trashCollected}/{trashRequired}");
|
Debug.Log($"Trash collected: {trashCollected}/{trashRequired}");
|
||||||
|
|
||||||
// If the player has collected/ thrown the required amount of trash
|
// If the player has collected/ thrown the required amount of trash
|
||||||
if (trashCollected >= trashRequired)
|
if (trashCollected < trashRequired) return;
|
||||||
{
|
|
||||||
if (GameManager.Instance == null)
|
if (GameManager.Instance == null)
|
||||||
Debug.LogError("GameManager instance is null!");
|
Debug.LogError("GameManager instance is null!");
|
||||||
else
|
else
|
||||||
|
@ -136,7 +134,6 @@ public class BedroomTask : MonoBehaviour
|
||||||
// Call unlocking door function/sequence
|
// Call unlocking door function/sequence
|
||||||
StartCoroutine(PlaySoundSequence());
|
StartCoroutine(PlaySoundSequence());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Functions when the door is locked
|
// Functions when the door is locked
|
||||||
private void LockDoor()
|
private void LockDoor()
|
||||||
|
@ -190,8 +187,8 @@ public class BedroomTask : MonoBehaviour
|
||||||
private void OnDoorGrabAttempt(SelectEnterEventArgs args)
|
private void OnDoorGrabAttempt(SelectEnterEventArgs args)
|
||||||
{
|
{
|
||||||
// If the amount of trash collected is lesser than the required amount
|
// If the amount of trash collected is lesser than the required amount
|
||||||
if (trashCollected < trashRequired)
|
if (trashCollected >= trashRequired) return;
|
||||||
{
|
|
||||||
// Show the locked door UI
|
// Show the locked door UI
|
||||||
lockedDoorUI.SetActive(true);
|
lockedDoorUI.SetActive(true);
|
||||||
|
|
||||||
|
@ -202,7 +199,6 @@ public class BedroomTask : MonoBehaviour
|
||||||
StartCoroutine(HidePanelAfterSeconds(lockedDoorUI, 5f));
|
StartCoroutine(HidePanelAfterSeconds(lockedDoorUI, 5f));
|
||||||
Debug.Log("The door is locked! Clean the room first.");
|
Debug.Log("The door is locked! Clean the room first.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Function when the task is completed
|
// Function when the task is completed
|
||||||
public bool IsTaskCompleted()
|
public bool IsTaskCompleted()
|
||||||
|
|
Loading…
Add table
Reference in a new issue