From 8c198f1df58cfc13a233f23671ac63b88aa3de03 Mon Sep 17 00:00:00 2001 From: yauwailam Date: Thu, 13 Feb 2025 21:22:19 +0800 Subject: [PATCH] day 2 going to school (schould work) --- Game/Assets/Scenes/Town.unity | 56 ++++++++++++++++++ Game/Assets/Scripts/GoToSchool.cs | 98 ++++++++++++++++++------------- 2 files changed, 114 insertions(+), 40 deletions(-) diff --git a/Game/Assets/Scenes/Town.unity b/Game/Assets/Scenes/Town.unity index 03bafd9..d241cab 100644 --- a/Game/Assets/Scenes/Town.unity +++ b/Game/Assets/Scenes/Town.unity @@ -250276,6 +250276,8 @@ MonoBehaviour: audioLoop: {fileID: 1126005959} storyPanelUI: {fileID: 1431178180} storyText: {fileID: 1809346053} + parkPondTrigger: {fileID: 1801320667} + schoolTrigger: {fileID: 1357420349} --- !u!43 &1359399347 Mesh: m_ObjectHideFlags: 0 @@ -346158,6 +346160,59 @@ Mesh: offset: 0 size: 0 path: +--- !u!1 &1801320666 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1801320668} + - component: {fileID: 1801320667} + m_Layer: 0 + m_Name: GoToPond + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!65 &1801320667 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1801320666} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!4 &1801320668 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1801320666} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0.36041337, z: -0, w: 0.9327927} + m_LocalPosition: {x: 15.56, y: 21.52, z: 1095.91} + m_LocalScale: {x: 3.4323885, y: 3.094469, z: 8.355327} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: -42.251, z: 0} --- !u!43 &1801863514 Mesh: m_ObjectHideFlags: 0 @@ -486380,6 +486435,7 @@ SceneRoots: - {fileID: 1305339138} - {fileID: 960695709} - {fileID: 108605771} + - {fileID: 1801320668} - {fileID: 1357420350} - {fileID: 931094981} - {fileID: 136651374} diff --git a/Game/Assets/Scripts/GoToSchool.cs b/Game/Assets/Scripts/GoToSchool.cs index ddc30de..8ff125e 100644 --- a/Game/Assets/Scripts/GoToSchool.cs +++ b/Game/Assets/Scripts/GoToSchool.cs @@ -17,6 +17,7 @@ public class GoToSchool : MonoBehaviour public float displayDuration = 5f; // Time the UI stays fully visible public AudioSource[] audioSources; + private bool atPond = false; private bool hasTriggered = false; // Prevent multiple triggers public AudioLoop audioLoop; @@ -25,6 +26,10 @@ public class GoToSchool : MonoBehaviour [Header("UI References")] public GameObject storyPanelUI; public TMP_Text storyText; + + [Header("Triggers")] + public Collider parkPondTrigger; // Assign in Inspector + public Collider schoolTrigger; // Assign in Inspector void Awake() { @@ -39,16 +44,29 @@ public class GoToSchool : MonoBehaviour if (storyPanelUI != null) storyPanelUI.SetActive(true); - if (storyText != null) + if (gameManager.currentDay == 1) { - storyText.text = "I guess I should head to school now..."; - StartCoroutine(ClearMessageAfterSeconds(7f)); + if (storyText != null) + { + storyText.text = "I guess I should head to school now..."; + StartCoroutine(ClearMessageAfterSeconds(7f)); + } + + if (audioLoop != null) + { + audioLoop.StartAudioLoop(); + } + } + + if (gameManager.currentDay == 2) + { + if (storyText != null) + { + storyText.text = "I need to calm down first... maybe going to the park pond would help..."; + StartCoroutine(ClearMessageAfterSeconds(7f)); + } } - if (audioLoop != null) - { - audioLoop.StartAudioLoop(); - } } private IEnumerator ClearMessageAfterSeconds(float delay) @@ -60,48 +78,48 @@ public class GoToSchool : MonoBehaviour private void OnTriggerEnter(Collider other) { - // Check if the player entered the trigger - if (!hasTriggered && other.CompareTag("Player")) + // // Check if the player entered the trigger + // if (!hasTriggered && other.CompareTag("Player")) + // { + // hasTriggered = true; + // StartCoroutine(FadeInAndLoadScene()); + // + // // Task completion is noted here + // gameManager.GoToSchoolTaskComplete(); + // } + + if (gameManager.currentDay == 2) + { + if (!atPond && other == parkPondTrigger) // Player arrives at pond first + { + atPond = true; + StartCoroutine(StayAtPond()); + } + else if (atPond && !hasTriggered && other == schoolTrigger) // Player can go to school after pond + { + hasTriggered = true; + StartCoroutine(FadeInAndLoadScene()); + gameManager.GoToSchoolTaskComplete(); + } + } + else if (!hasTriggered && other == schoolTrigger) // Normal case for Day 1 { hasTriggered = true; StartCoroutine(FadeInAndLoadScene()); - - // Task completion is noted here gameManager.GoToSchoolTaskComplete(); } } + + private IEnumerator StayAtPond() + { + storyText.text = "The sound of the water is soothing..."; + yield return new WaitForSeconds(7f); + storyText.text = "I feel a little better now. I should head to school now."; + StartCoroutine(ClearMessageAfterSeconds(7f)); + } IEnumerator FadeInAndLoadScene() { - // // Fade In - // yield return StartCoroutine(Fade(0f, 1f, fadeDuration)); - // - // // Display UI for 5 seconds - // yield return new WaitForSeconds(displayDuration); - // - // // Determine the next scene based on the current day - // int currentDay = gameManager.currentDay; - // string nextScene; - // - // switch (currentDay) - // { - // case 2: - // nextScene = "Day2"; - // break; - // case 3: - // nextScene = "Day3"; // need another way to go to day 3 tho bcos they arent going to sch on day 3 - // break; - // default: - // nextScene = "Start"; // Fallback in case of unexpected day value - // break; - // } - // - // // Load the determined next scene - // SceneManager.LoadScene(nextScene); - // - // // Increment the day AFTER transitioning to avoid multiple increments - // gameManager.IncrementDay(); - yield return StartCoroutine(Fade(0f, 1f, fadeDuration)); yield return new WaitForSeconds(displayDuration);