game(scripts/leavehouse): ref GameManager.Instance directly

This commit is contained in:
Mark Joshwel 2025-02-14 21:12:49 +08:00
parent 94659dedc0
commit e458c43300

View file

@ -1,5 +1,5 @@
/* /*
Author: Reza and Wai Lam Author: Reza, Wai Lam, Mark
Date: 10/2/25 Date: 10/2/25
Description: Verifies whether tasks in the house are completed before going to the next scene Description: Verifies whether tasks in the house are completed before going to the next scene
*/ */
@ -36,11 +36,14 @@ public class LeaveHouseTrigger : MonoBehaviour
void ShowConfirmationButtons() void ShowConfirmationButtons()
{ {
// FIXME: possibly refer to purely GameManager.Instance instead of any // FIXED: possibly refer to purely GameManager.Instance instead of any
// early-bound reference to GameManager because the game manager might // early-bound reference to GameManager because the game manager might
// not have died fast enough for other scripts to refer to the new // not have died fast enough for other scripts to refer to the new
// GameManager instance // GameManager instance
// keeping this here for future ref
// --mark
Debug.Log("Current Day in ShowConfirmationButtons: " + GameManager.Instance.currentDay); Debug.Log("Current Day in ShowConfirmationButtons: " + GameManager.Instance.currentDay);
confirmationPanel.SetActive(true); confirmationPanel.SetActive(true);
warningPanel.SetActive(true); warningPanel.SetActive(true);
@ -77,13 +80,12 @@ public class LeaveHouseTrigger : MonoBehaviour
public void CancelLeave() public void CancelLeave()
{ {
if (gameManager.currentDay == 2) if (GameManager.Instance.currentDay == 2)
{ {
gameManager.IncrementDay(); GameManager.Instance.IncrementDay();
SceneManager.LoadScene(Day3); SceneManager.LoadScene(Day3);
} }
confirmationPanel.SetActive(false); confirmationPanel.SetActive(false);
warningPanel.SetActive(true); warningPanel.SetActive(true);
} }
} }