2025-02-10 21:33:49 +08:00
|
|
|
/*
|
2025-02-14 10:38:31 +08:00
|
|
|
Author: Reza and Wai Lam
|
2025-02-10 21:33:49 +08:00
|
|
|
Date: 10/2/25
|
|
|
|
Description: Verifies whether tasks in the house are completed before going to the next scene
|
|
|
|
*/
|
|
|
|
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
using TMPro;
|
|
|
|
|
|
|
|
public class LeaveHouseTrigger : MonoBehaviour
|
|
|
|
{
|
|
|
|
public GameManager gameManager;
|
|
|
|
|
|
|
|
// Name of the next scene
|
|
|
|
public string nextSceneName;
|
2025-02-14 13:03:21 +08:00
|
|
|
public string Day3;
|
2025-02-10 21:33:49 +08:00
|
|
|
public GameObject confirmationPanel;
|
|
|
|
public TMP_Text warningText;
|
2025-02-12 13:46:08 +08:00
|
|
|
public GameObject warningPanel;
|
2025-02-10 21:33:49 +08:00
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
2025-02-13 17:56:09 +08:00
|
|
|
confirmationPanel.SetActive(false);
|
|
|
|
warningText.text = "";
|
2025-02-10 21:33:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
|
|
{
|
|
|
|
if (other.CompareTag("Player"))
|
|
|
|
{
|
|
|
|
ShowConfirmationButtons();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowConfirmationButtons()
|
|
|
|
{
|
|
|
|
confirmationPanel.SetActive(true);
|
2025-02-14 13:03:21 +08:00
|
|
|
if (gameManager.currentDay == 1)
|
|
|
|
{
|
|
|
|
warningText.text = "Should I leave the house? I might not have completed everything...";
|
|
|
|
StartCoroutine(HideWarningPanelAfterDelay(7f)); // can change how long you want the text to show for
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gameManager.currentDay == 2)
|
|
|
|
{
|
|
|
|
warningText.text = "Do I even want to go to school...";
|
|
|
|
StartCoroutine(HideWarningPanelAfterDelay(7f)); // can change how long you want the text to show for
|
|
|
|
}
|
2025-02-12 13:46:08 +08:00
|
|
|
}
|
2025-02-13 17:56:09 +08:00
|
|
|
|
2025-02-12 13:46:08 +08:00
|
|
|
IEnumerator HideWarningPanelAfterDelay(float delay)
|
|
|
|
{
|
|
|
|
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-10 21:33:49 +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()
|
|
|
|
{
|
|
|
|
confirmationPanel.SetActive(false);
|
2025-02-12 13:46:08 +08:00
|
|
|
warningPanel.SetActive(true);
|
2025-02-14 13:03:21 +08:00
|
|
|
|
|
|
|
if (gameManager.currentDay == 2)
|
|
|
|
{
|
|
|
|
gameManager.IncrementDay();
|
|
|
|
SceneManager.LoadScene(Day3);
|
|
|
|
}
|
2025-02-10 21:33:49 +08:00
|
|
|
}
|
|
|
|
}
|