game: triggering leaving house option to get to next level

This commit is contained in:
rezazfn 2025-02-10 21:33:49 +08:00
parent 55f90129ea
commit 1ca2d10a6d
5 changed files with 1791 additions and 25 deletions

File diff suppressed because it is too large Load diff

View file

@ -213,7 +213,7 @@ public class BedroomTask : MonoBehaviour
yield return new WaitForSeconds(doorSlamSound.length);
PostProcessingManager.Instance.StopEffect();
PostProcessingManager.Instance.StopEffect("Panic");
// Clear the "!!!"
storyText.text = "";

View file

@ -1,4 +1,4 @@
/*
/*
Author: Reza
Date: 3/2/25
Description: To keep track of tasks, which level the player is at, and game mechanics
@ -11,26 +11,27 @@ using TMPro;
public class GameManager : MonoBehaviour
{
/* Game Story Flow:
- Player cleans room while waiting for parents to leave
- The door unlocks after room is cleaned and explored and player either sweeps floor or brushes teeth
-
*/
/// <summary>
/// singleton pattern: define instance field for accessing the singleton elsewhere
/// Define instance field for accessing the singleton elsewhere
/// </summary>
public static GameManager Instance;
/// <summary>
/// Trackable Task Completions
/// </summary>
// Trackable Task Completions
private bool bedroomCleaned = false;
private bool teethBrushed = false;
private bool floorSweeped = false;
/// <summary>
/// enforces singleton behaviour; sets doesn't destroy on load and checks for multiple instances
/// Checks if tasks are completed
/// </summary>
public bool IsBedroomCleaned() { return bedroomCleaned; }
public bool IsTeethBrushed() { return teethBrushed; }
public bool IsFloorSweeped() { return floorSweeped; }
/// <summary>
/// Enforces singleton behaviour; sets doesn't destroy on load and checks for multiple instances
/// </summary>
private void Awake()
{
@ -60,15 +61,36 @@ public class GameManager : MonoBehaviour
{
}
// Logs player's choices before leaving the house (for future Firebase tracking)
public void LogPlayerChoices()
{
Debug.Log("Player is trying to leave the house. Task Completion Status:");
Debug.Log("Bedroom Cleaned: " + bedroomCleaned);
Debug.Log("Teeth Brushed: " + teethBrushed);
Debug.Log("Floor Sweeped: " + floorSweeped);
// Future-proofing for Firebase tracking
}
// Tracks if bedroom is cleaned or not
public void BedroomTaskComplete()
{
bedroomCleaned = true;
}
// Tracks if teeth is brushed or not
public void BrushTeethTaskComplete()
{
teethBrushed = true;
}
// Tracks if floor is sweeped or not
public void FloorSweepedTaskComplete()
{
floorSweeped = true;
}
}

View file

@ -0,0 +1,54 @@
/*
Author: Reza
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;
public GameObject confirmationPanel;
public TMP_Text warningText;
// Start is called before the first frame update
void Start()
{
confirmationPanel.SetActive(false);
warningText.text = "";
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
ShowConfirmationButtons();
}
}
void ShowConfirmationButtons()
{
confirmationPanel.SetActive(true);
warningText.text = "Am I sure I want to leave the house? I might not have completed everything...";
}
public void ConfirmLeave()
{
GameManager.Instance.LogPlayerChoices();
SceneManager.LoadScene(nextSceneName);
}
public void CancelLeave()
{
confirmationPanel.SetActive(false);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95f0438a7d9b79a44b3b4266ba371262
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: