2025-02-10 21:33:49 +08:00
|
|
|
/*
|
2025-02-15 00:35:15 +08:00
|
|
|
* Author: Reza, Wai Lam, Mark
|
|
|
|
* Date: 10/2/25
|
|
|
|
* Description: Verifies whether tasks in the house are completed before going to the next scene
|
|
|
|
*/
|
2025-02-10 21:33:49 +08:00
|
|
|
|
|
|
|
using System.Collections;
|
|
|
|
using TMPro;
|
2025-02-15 00:35:15 +08:00
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.SceneManagement;
|
2025-02-10 21:33:49 +08:00
|
|
|
|
|
|
|
public class LeaveHouseTrigger : MonoBehaviour
|
|
|
|
{
|
|
|
|
// Name of the next scene
|
|
|
|
public string nextSceneName;
|
2025-02-15 00:35:15 +08:00
|
|
|
public string day3;
|
|
|
|
public GameObject confirmationPanel;
|
2025-02-10 21:33:49 +08:00
|
|
|
public TMP_Text warningText;
|
2025-02-12 13:46:08 +08:00
|
|
|
public GameObject warningPanel;
|
2025-02-15 00:35:15 +08:00
|
|
|
|
2025-02-10 21:33:49 +08:00
|
|
|
// Start is called before the first frame update
|
2025-02-15 00:35:15 +08:00
|
|
|
private void Start()
|
2025-02-10 21:33:49 +08:00
|
|
|
{
|
2025-02-13 17:56:09 +08:00
|
|
|
confirmationPanel.SetActive(false);
|
|
|
|
warningText.text = "";
|
2025-02-10 21:33:49 +08:00
|
|
|
}
|
2025-02-15 00:35:15 +08:00
|
|
|
|
2025-02-10 21:33:49 +08:00
|
|
|
private void OnTriggerEnter(Collider other)
|
|
|
|
{
|
2025-02-15 00:35:15 +08:00
|
|
|
if (other.CompareTag("Player")) ShowConfirmationButtons();
|
2025-02-10 21:33:49 +08:00
|
|
|
}
|
|
|
|
|
2025-02-15 00:35:15 +08:00
|
|
|
private void ShowConfirmationButtons()
|
2025-02-10 21:33:49 +08:00
|
|
|
{
|
2025-02-14 21:12:49 +08:00
|
|
|
// FIXED: possibly refer to purely GameManager.Instance instead of any
|
2025-02-15 00:35:15 +08:00
|
|
|
// early bound reference to GameManager because the game manager might
|
2025-02-14 18:05:23 +08:00
|
|
|
// not have died fast enough for other scripts to refer to the new
|
|
|
|
// GameManager instance
|
2025-02-15 00:35:15 +08:00
|
|
|
|
2025-02-14 21:12:49 +08:00
|
|
|
// keeping this here for future ref
|
|
|
|
// --mark
|
2025-02-14 13:03:21 +08:00
|
|
|
|
2025-02-15 00:35:15 +08:00
|
|
|
Debug.Log("Current Day in ShowConfirmationButtons: " + GameManager.Instance.CurrentDay);
|
|
|
|
confirmationPanel.SetActive(true);
|
|
|
|
warningPanel.SetActive(true);
|
|
|
|
Debug.Log("Current Day is: " + GameManager.Instance.CurrentDay);
|
|
|
|
switch (GameManager.Instance.CurrentDay)
|
2025-02-14 13:03:21 +08:00
|
|
|
{
|
2025-02-15 00:35:15 +08:00
|
|
|
case 1:
|
|
|
|
Debug.Log("Setting text for Day 1");
|
|
|
|
warningText.text = "Should I leave the house? I might not have completed everything...";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Debug.Log("Setting text for Day 2");
|
|
|
|
warningText.text = "Do I even want to go to school...";
|
|
|
|
break;
|
2025-02-14 13:03:21 +08:00
|
|
|
}
|
2025-02-15 00:35:15 +08:00
|
|
|
// can change how long you want the text to show for
|
|
|
|
StartCoroutine(HideWarningPanelAfterDelay(7f));
|
2025-02-12 13:46:08 +08:00
|
|
|
}
|
2025-02-13 17:56:09 +08:00
|
|
|
|
2025-02-15 00:35:15 +08:00
|
|
|
private IEnumerator HideWarningPanelAfterDelay(float delay)
|
2025-02-12 13:46:08 +08:00
|
|
|
{
|
|
|
|
yield return new WaitForSeconds(delay);
|
|
|
|
warningPanel.SetActive(false);
|
2025-02-10 21:33:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ConfirmLeave()
|
|
|
|
{
|
2025-02-13 17:56:09 +08:00
|
|
|
// Log player choices
|
2025-02-15 00:35:15 +08:00
|
|
|
GameManager.Instance.LogPlayerChoices();
|
|
|
|
|
2025-02-13 17:56:09 +08:00
|
|
|
// Load the next scene directly without needing to set the last scene
|
2025-02-10 21:33:49 +08:00
|
|
|
SceneManager.LoadScene(nextSceneName);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void CancelLeave()
|
|
|
|
{
|
2025-02-15 00:35:15 +08:00
|
|
|
if (GameManager.Instance.CurrentDay == 2)
|
2025-02-14 13:03:21 +08:00
|
|
|
{
|
2025-02-14 21:12:49 +08:00
|
|
|
GameManager.Instance.IncrementDay();
|
2025-02-15 00:35:15 +08:00
|
|
|
SceneManager.LoadScene(day3);
|
2025-02-14 13:03:21 +08:00
|
|
|
}
|
2025-02-15 00:35:15 +08:00
|
|
|
|
2025-02-14 13:48:11 +08:00
|
|
|
confirmationPanel.SetActive(false);
|
|
|
|
warningPanel.SetActive(true);
|
2025-02-10 21:33:49 +08:00
|
|
|
}
|
|
|
|
}
|