go to school in progress
This commit is contained in:
parent
5b0a7cd508
commit
8591ec7eb4
6 changed files with 163 additions and 43 deletions
|
@ -19971,7 +19971,8 @@ Transform:
|
|||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Children:
|
||||
- {fileID: 1776114652}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &278618526
|
||||
|
@ -127740,7 +127741,7 @@ RectTransform:
|
|||
- {fileID: 620624015}
|
||||
- {fileID: 1839460624}
|
||||
- {fileID: 197586935}
|
||||
m_Father: {fileID: 0}
|
||||
m_Father: {fileID: 278618525}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
@ -165901,7 +165902,6 @@ SceneRoots:
|
|||
- {fileID: 1898819870}
|
||||
- {fileID: 649665534}
|
||||
- {fileID: 347656174}
|
||||
- {fileID: 1776114652}
|
||||
- {fileID: 14967089}
|
||||
- {fileID: 1688857688}
|
||||
- {fileID: 533820784}
|
||||
|
|
|
@ -4064,7 +4064,7 @@ PrefabInstance:
|
|||
objectReference: {fileID: 1079096153}
|
||||
- target: {fileID: 124634771731201661, guid: e9780caa44a72904897def65e3f50790, type: 3}
|
||||
propertyPath: m_VersionIndex
|
||||
value: 1789
|
||||
value: 1792
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5615680084984838417, guid: e9780caa44a72904897def65e3f50790, type: 3}
|
||||
propertyPath: m_Mesh
|
||||
|
@ -8404,7 +8404,7 @@ PrefabInstance:
|
|||
objectReference: {fileID: 345227675}
|
||||
- target: {fileID: 124634771731201661, guid: e9780caa44a72904897def65e3f50790, type: 3}
|
||||
propertyPath: m_VersionIndex
|
||||
value: 1789
|
||||
value: 1792
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5615680084984838417, guid: e9780caa44a72904897def65e3f50790, type: 3}
|
||||
propertyPath: m_Mesh
|
||||
|
@ -31721,7 +31721,7 @@ PrefabInstance:
|
|||
objectReference: {fileID: 315325997}
|
||||
- target: {fileID: 124634771731201661, guid: e9780caa44a72904897def65e3f50790, type: 3}
|
||||
propertyPath: m_VersionIndex
|
||||
value: 1792
|
||||
value: 1795
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5615680084984838417, guid: e9780caa44a72904897def65e3f50790, type: 3}
|
||||
propertyPath: m_Mesh
|
||||
|
@ -55136,37 +55136,6 @@ Mesh:
|
|||
offset: 0
|
||||
size: 0
|
||||
path:
|
||||
--- !u!1 &278618524
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 278618525}
|
||||
m_Layer: 0
|
||||
m_Name: GameManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &278618525
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 278618524}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!43 &280867632
|
||||
Mesh:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -169246,7 +169215,7 @@ PrefabInstance:
|
|||
objectReference: {fileID: 1387674491}
|
||||
- target: {fileID: 124634771731201661, guid: e9780caa44a72904897def65e3f50790, type: 3}
|
||||
propertyPath: m_VersionIndex
|
||||
value: 1789
|
||||
value: 1792
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5615680084984838417, guid: e9780caa44a72904897def65e3f50790, type: 3}
|
||||
propertyPath: m_Mesh
|
||||
|
@ -281067,7 +281036,7 @@ MonoBehaviour:
|
|||
m_GameObject: {fileID: 1357420348}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5bae7a3fb14a3854ca6668491a8257b9, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: efcd661891d8a6b48b0cae6b4b9b0d51, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
fadeCanvasGroup: {fileID: 536676154}
|
||||
|
@ -281075,8 +281044,11 @@ MonoBehaviour:
|
|||
displayDuration: 3
|
||||
nextSceneName: House
|
||||
audioSources:
|
||||
- {fileID: 205722625}
|
||||
- {fileID: 1126005960}
|
||||
- {fileID: 205722625}
|
||||
audioLoop: {fileID: 1126005959}
|
||||
storyPanelUI: {fileID: 0}
|
||||
storyText: {fileID: 0}
|
||||
--- !u!43 &1359399347
|
||||
Mesh:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -471236,7 +471208,7 @@ PrefabInstance:
|
|||
objectReference: {fileID: 441713353}
|
||||
- target: {fileID: 124634771731201661, guid: e9780caa44a72904897def65e3f50790, type: 3}
|
||||
propertyPath: m_VersionIndex
|
||||
value: 1792
|
||||
value: 1795
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5615680084984838417, guid: e9780caa44a72904897def65e3f50790, type: 3}
|
||||
propertyPath: m_Mesh
|
||||
|
@ -534648,7 +534620,6 @@ SceneRoots:
|
|||
- {fileID: 1305339138}
|
||||
- {fileID: 960695709}
|
||||
- {fileID: 108605771}
|
||||
- {fileID: 278618525}
|
||||
- {fileID: 649665534}
|
||||
- {fileID: 563127885}
|
||||
- {fileID: 1390360348}
|
||||
|
|
|
@ -19,7 +19,11 @@ public class AudioLoop : MonoBehaviour
|
|||
}
|
||||
StartCoroutine(PlayPauseLoop());
|
||||
}
|
||||
|
||||
|
||||
public void StartAudioLoop()
|
||||
{
|
||||
StartCoroutine(PlayPauseLoop());
|
||||
}
|
||||
private IEnumerator PlayPauseLoop()
|
||||
{
|
||||
while (true)
|
||||
|
|
|
@ -25,6 +25,7 @@ public class GameManager : MonoBehaviour
|
|||
private bool bedroomCleaned = false;
|
||||
private bool teethBrushed = false;
|
||||
private bool floorSweeped = false;
|
||||
private bool goToSchool = false;
|
||||
|
||||
// Queue for managing messages
|
||||
private Queue<string> messageQueue = new Queue<string>();
|
||||
|
@ -37,6 +38,8 @@ public class GameManager : MonoBehaviour
|
|||
public bool IsTeethBrushed() { return teethBrushed; }
|
||||
public bool IsFloorSweeped() { return floorSweeped; }
|
||||
|
||||
public bool IsGoToSchool() { return goToSchool; }
|
||||
|
||||
/// <summary>
|
||||
/// Enforces singleton behaviour; sets doesn't destroy on load and checks for multiple instances
|
||||
/// </summary>
|
||||
|
@ -96,6 +99,7 @@ public class GameManager : MonoBehaviour
|
|||
Debug.Log("Bedroom Cleaned: " + bedroomCleaned);
|
||||
Debug.Log("Teeth Brushed: " + teethBrushed);
|
||||
Debug.Log("Floor Sweeped: " + floorSweeped);
|
||||
Debug.Log("Go To School: " + goToSchool);
|
||||
}
|
||||
|
||||
public void AreTasksDone()
|
||||
|
@ -126,4 +130,9 @@ public class GameManager : MonoBehaviour
|
|||
floorSweeped = true;
|
||||
AreTasksDone();
|
||||
}
|
||||
|
||||
public void GoToSchoolTaskComplete()
|
||||
{
|
||||
goToSchool = true;
|
||||
}
|
||||
}
|
||||
|
|
125
Game/Assets/Scripts/GoToSchool.cs
Normal file
125
Game/Assets/Scripts/GoToSchool.cs
Normal file
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
Author: Wai Lam
|
||||
Date: 12/2/25
|
||||
Description: Go to school
|
||||
*/
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.SceneManagement;
|
||||
public class GoToSchool : MonoBehaviour
|
||||
{
|
||||
private GameManager gameManager;
|
||||
|
||||
|
||||
public CanvasGroup fadeCanvasGroup; // Assign in Inspector
|
||||
public float fadeDuration = 1f; // Duration for fade in/out
|
||||
public float displayDuration = 5f; // Time the UI stays fully visible
|
||||
public string nextSceneName; // Name of the scene to load
|
||||
public AudioSource[] audioSources;
|
||||
|
||||
private bool hasTriggered = false; // Prevent multiple triggers
|
||||
|
||||
public AudioLoop audioLoop;
|
||||
// Defines UI references
|
||||
[Header("UI References")]
|
||||
|
||||
public GameObject storyPanelUI;
|
||||
public TMP_Text storyText;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (storyPanelUI == null)
|
||||
storyPanelUI = GameObject.Find("Story Panel"); // Use the exact name
|
||||
|
||||
if (storyText == null)
|
||||
storyText = FindObjectOfType<TMP_Text>(); // Finds the first TMP_Text in the scene
|
||||
|
||||
if (storyPanelUI != null)
|
||||
storyPanelUI.SetActive(true);
|
||||
|
||||
if (storyText != null)
|
||||
{
|
||||
storyText.text = "I guess I should head to school now...";
|
||||
StartCoroutine(ClearMessageAfterSeconds(7f));
|
||||
}
|
||||
|
||||
if (audioLoop != null)
|
||||
{
|
||||
audioLoop.StartAudioLoop();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private IEnumerator ClearMessageAfterSeconds(float delay)
|
||||
{
|
||||
// Waits for delay to end and hides the UI
|
||||
yield return new WaitForSeconds(delay);
|
||||
storyText.text = "";
|
||||
}
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
// Check if the player entered the trigger
|
||||
if (!hasTriggered && other.CompareTag("Player"))
|
||||
{
|
||||
hasTriggered = true;
|
||||
StartCoroutine(FadeInAndLoadScene());
|
||||
GameManager.Instance.GoToSchoolTaskComplete();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator FadeInAndLoadScene()
|
||||
{
|
||||
// Fade In
|
||||
yield return StartCoroutine(Fade(0f, 1f, fadeDuration));
|
||||
|
||||
// Display UI for 5 seconds
|
||||
yield return new WaitForSeconds(displayDuration);
|
||||
|
||||
// Load the next scene
|
||||
SceneManager.LoadScene(nextSceneName);
|
||||
}
|
||||
|
||||
IEnumerator Fade(float startAlpha, float endAlpha, float duration)
|
||||
{
|
||||
float elapsed = 0f;
|
||||
fadeCanvasGroup.alpha = startAlpha;
|
||||
|
||||
float[] startVolumes = new float[audioSources.Length];
|
||||
for (int i = 0; i < audioSources.Length; i++)
|
||||
{
|
||||
startVolumes[i] = audioSources[i] != null ? audioSources[i].volume : 1f;
|
||||
}
|
||||
|
||||
while (elapsed < duration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
float t = elapsed / duration;
|
||||
|
||||
fadeCanvasGroup.alpha = Mathf.Lerp(startAlpha, endAlpha, t);
|
||||
|
||||
for (int i = 0; i < audioSources.Length; i++)
|
||||
{
|
||||
if (audioSources[i] != null)
|
||||
{
|
||||
audioSources[i].volume = Mathf.Lerp(startVolumes[i], 0f, t);
|
||||
}
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
fadeCanvasGroup.alpha = endAlpha;
|
||||
|
||||
for (int i = 0; i < audioSources.Length; i++)
|
||||
{
|
||||
if (audioSources[i] != null)
|
||||
{
|
||||
audioSources[i].volume = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Game/Assets/Scripts/GoToSchool.cs.meta
Normal file
11
Game/Assets/Scripts/GoToSchool.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: efcd661891d8a6b48b0cae6b4b9b0d51
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Reference in a new issue