From e0a5f9375276c0803d7c185cd80efeebbf7d0c6b Mon Sep 17 00:00:00 2001 From: rezazfn Date: Tue, 11 Feb 2025 15:36:03 +0800 Subject: [PATCH] game: storyline text fixing --- Game/Assets/Scripts/BedroomTask.cs | 3 +- Game/Assets/Scripts/BroomSweeping.cs | 5 +-- Game/Assets/Scripts/BrushTeeth.cs | 1 + Game/Assets/Scripts/GameManager.cs | 4 +- Game/Assets/Scripts/StorylineManager.cs | 38 +++++++++++++++++++ Game/Assets/Scripts/StorylineManager.cs.meta | 11 ++++++ .../com.unity.probuilder/Settings.json | 19 ++++++++++ 7 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 Game/Assets/Scripts/StorylineManager.cs create mode 100644 Game/Assets/Scripts/StorylineManager.cs.meta diff --git a/Game/Assets/Scripts/BedroomTask.cs b/Game/Assets/Scripts/BedroomTask.cs index 8a54485..6697b17 100644 --- a/Game/Assets/Scripts/BedroomTask.cs +++ b/Game/Assets/Scripts/BedroomTask.cs @@ -16,6 +16,7 @@ public class BedroomTask : MonoBehaviour { private GameManager gameManager; private PostProcessingManager postProcessingManager; + private StorylineManager storylineManager; [Header("Task Requirement Values")] // To track how much trash has been collected so far @@ -228,7 +229,7 @@ public class BedroomTask : MonoBehaviour // Unlocks the door after the clips and update the story UnlockDoor(); - storyText.text = "They finally left... just as soon as I finished cleaning. I can leave the room now."; + storylineManager.EnqueueMessage("They finally left... just as soon as I finished cleaning. I can leave the room now.", 7f); StartCoroutine(ClearMessageAfterSeconds(7f)); } diff --git a/Game/Assets/Scripts/BroomSweeping.cs b/Game/Assets/Scripts/BroomSweeping.cs index 26bc643..3c173b7 100644 --- a/Game/Assets/Scripts/BroomSweeping.cs +++ b/Game/Assets/Scripts/BroomSweeping.cs @@ -13,6 +13,7 @@ public class BroomSweeping : MonoBehaviour { private GameManager gameManager; private PostProcessingManager postProcessingManager; + private StorylineManager storylineManager; // To track how much trash has been collected so far public int dirtSweeped = 0; @@ -41,9 +42,7 @@ public class BroomSweeping : MonoBehaviour GameManager.Instance.FloorSweepedTaskComplete(); storyPanelUI.SetActive(true); - storyText.text = "I hope the house is clean enough now so I don't get scolded later..."; - - StartCoroutine(ClearMessageAfterSeconds(7f)); + storylineManager.EnqueueMessage("I hope the house is clean enough now so I don't get scolded later...", 7f) } } diff --git a/Game/Assets/Scripts/BrushTeeth.cs b/Game/Assets/Scripts/BrushTeeth.cs index 3586f4a..7a300c1 100644 --- a/Game/Assets/Scripts/BrushTeeth.cs +++ b/Game/Assets/Scripts/BrushTeeth.cs @@ -16,6 +16,7 @@ using TMPro; public class BrushTeeth : MonoBehaviour { private GameManager gameManager; + private StorylineManager storylineManager; public Slider progressBar; // Reference to the Slider (progress bar) public float progressTime = 5f; // Time for the progress bar to complete diff --git a/Game/Assets/Scripts/GameManager.cs b/Game/Assets/Scripts/GameManager.cs index 67bb71e..8246057 100644 --- a/Game/Assets/Scripts/GameManager.cs +++ b/Game/Assets/Scripts/GameManager.cs @@ -79,10 +79,11 @@ public class GameManager : MonoBehaviour public void AreTasksDone() { + Debug.Log("TASKS ARE DONE"); if (bedroomCleaned && teethBrushed && floorSweeped) { - storyText.text = "I think I did everything... I should go to school now"; storyPanelUI.SetActive(true); + storyText.text = "I think I did everything... I should go to school now"; StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 7f)); } } @@ -113,5 +114,4 @@ public class GameManager : MonoBehaviour yield return new WaitForSeconds(delay); uiElement.SetActive(false); } - } diff --git a/Game/Assets/Scripts/StorylineManager.cs b/Game/Assets/Scripts/StorylineManager.cs new file mode 100644 index 0000000..f3674ad --- /dev/null +++ b/Game/Assets/Scripts/StorylineManager.cs @@ -0,0 +1,38 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using TMPro; + +public class StorylineManager : MonoBehaviour +{ + public TMP_Text storyText; // Reference to the story text UI + private Queue messageQueue = new Queue(); // Queue to store messages + private bool isDisplayingMessage = false; // Track whether a message is currently being displayed + + public void EnqueueMessage(string message, float delay = 7f) + { + messageQueue.Enqueue(message); + if (!isDisplayingMessage) + { + StartCoroutine(DisplayMessages(delay)); + } + } + + private IEnumerator DisplayMessages(float delay) + { + isDisplayingMessage = true; + + while (messageQueue.Count > 0) + { + string currentMessage = messageQueue.Dequeue(); + storyText.text = currentMessage; + + // Wait before clearing the message + yield return new WaitForSeconds(delay); + + storyText.text = ""; // Clear the message + } + + isDisplayingMessage = false; + } +} \ No newline at end of file diff --git a/Game/Assets/Scripts/StorylineManager.cs.meta b/Game/Assets/Scripts/StorylineManager.cs.meta new file mode 100644 index 0000000..055d237 --- /dev/null +++ b/Game/Assets/Scripts/StorylineManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b46ba12a5ba4d8d46852e7051b32010e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Game/ProjectSettings/Packages/com.unity.probuilder/Settings.json b/Game/ProjectSettings/Packages/com.unity.probuilder/Settings.json index 6b486ad..340e8e2 100644 --- a/Game/ProjectSettings/Packages/com.unity.probuilder/Settings.json +++ b/Game/ProjectSettings/Packages/com.unity.probuilder/Settings.json @@ -111,6 +111,11 @@ "key": "editor.stripProBuilderScriptsOnBuild", "value": "{\"m_Value\":true}" }, + { + "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", + "key": "editor.extrudeEdgesAsGroup", + "value": "{\"m_Value\":true}" + }, { "type": "UnityEngine.ProBuilder.SelectionModifierBehavior, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "key": "editor.rectSelectModifier", @@ -161,6 +166,11 @@ "key": "ShapeBuilder.LastPivotLocation", "value": "{\"m_Value\":1}" }, + { + "type": "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", + "key": "SubdivideEdges.subdivisions", + "value": "{\"m_Value\":1}" + }, { "type": "UnityEngine.ProBuilder.PivotLocation, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "key": "mesh.newShapePivotLocation", @@ -174,7 +184,11 @@ { "type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "key": "ShapeBuilder.LastSize", +<<<<<<< Updated upstream "value": "{\"m_Value\":{\"x\":0.248779296875,\"y\":-0.09796714782714844,\"z\":0.2877197265625}}" +======= + "value": "{\"m_Value\":{\"x\":-0.4071826934814453,\"y\":0.2012939453125,\"z\":-0.5807037353515625}}" +>>>>>>> Stashed changes }, { "type": "UnityEngine.Quaternion, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", @@ -250,6 +264,11 @@ "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "key": "uv.uvEditorGridSnapIncrement", "value": "{\"m_Value\":0.125}" + }, + { + "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", + "key": "ExtrudeEdges.distance", + "value": "{\"m_Value\":0.5}" } ] }