game: triggering leaving house option to get to next level
This commit is contained in:
parent
55f90129ea
commit
1ca2d10a6d
5 changed files with 1791 additions and 25 deletions
File diff suppressed because it is too large
Load diff
|
@ -213,7 +213,7 @@ public class BedroomTask : MonoBehaviour
|
||||||
yield return new WaitForSeconds(doorSlamSound.length);
|
yield return new WaitForSeconds(doorSlamSound.length);
|
||||||
|
|
||||||
|
|
||||||
PostProcessingManager.Instance.StopEffect();
|
PostProcessingManager.Instance.StopEffect("Panic");
|
||||||
|
|
||||||
// Clear the "!!!"
|
// Clear the "!!!"
|
||||||
storyText.text = "";
|
storyText.text = "";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
Author: Reza
|
Author: Reza
|
||||||
Date: 3/2/25
|
Date: 3/2/25
|
||||||
Description: To keep track of tasks, which level the player is at, and game mechanics
|
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
|
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>
|
/// <summary>
|
||||||
/// singleton pattern: define instance field for accessing the singleton elsewhere
|
/// Define instance field for accessing the singleton elsewhere
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static GameManager Instance;
|
public static GameManager Instance;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Trackable Task Completions
|
// Trackable Task Completions
|
||||||
/// </summary>
|
|
||||||
private bool bedroomCleaned = false;
|
private bool bedroomCleaned = false;
|
||||||
private bool teethBrushed = false;
|
private bool teethBrushed = false;
|
||||||
private bool floorSweeped = false;
|
private bool floorSweeped = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
@ -61,14 +62,35 @@ 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()
|
public void BedroomTaskComplete()
|
||||||
{
|
{
|
||||||
bedroomCleaned = true;
|
bedroomCleaned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tracks if teeth is brushed or not
|
||||||
public void BrushTeethTaskComplete()
|
public void BrushTeethTaskComplete()
|
||||||
{
|
{
|
||||||
teethBrushed = true;
|
teethBrushed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tracks if floor is sweeped or not
|
||||||
|
public void FloorSweepedTaskComplete()
|
||||||
|
{
|
||||||
|
floorSweeped = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
54
Game/Assets/Scripts/LeaveHouseTrigger.cs
Normal file
54
Game/Assets/Scripts/LeaveHouseTrigger.cs
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
11
Game/Assets/Scripts/LeaveHouseTrigger.cs.meta
Normal file
11
Game/Assets/Scripts/LeaveHouseTrigger.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 95f0438a7d9b79a44b3b4266ba371262
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Add table
Reference in a new issue