game: storyline text fixing
This commit is contained in:
parent
dda6a0f779
commit
e0a5f93752
7 changed files with 75 additions and 6 deletions
|
@ -16,6 +16,7 @@ public class BedroomTask : MonoBehaviour
|
||||||
{
|
{
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
private PostProcessingManager postProcessingManager;
|
private PostProcessingManager postProcessingManager;
|
||||||
|
private StorylineManager storylineManager;
|
||||||
|
|
||||||
[Header("Task Requirement Values")]
|
[Header("Task Requirement Values")]
|
||||||
// To track how much trash has been collected so far
|
// 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
|
// Unlocks the door after the clips and update the story
|
||||||
UnlockDoor();
|
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));
|
StartCoroutine(ClearMessageAfterSeconds(7f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ public class BroomSweeping : MonoBehaviour
|
||||||
{
|
{
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
private PostProcessingManager postProcessingManager;
|
private PostProcessingManager postProcessingManager;
|
||||||
|
private StorylineManager storylineManager;
|
||||||
|
|
||||||
// To track how much trash has been collected so far
|
// To track how much trash has been collected so far
|
||||||
public int dirtSweeped = 0;
|
public int dirtSweeped = 0;
|
||||||
|
@ -41,9 +42,7 @@ public class BroomSweeping : MonoBehaviour
|
||||||
GameManager.Instance.FloorSweepedTaskComplete();
|
GameManager.Instance.FloorSweepedTaskComplete();
|
||||||
|
|
||||||
storyPanelUI.SetActive(true);
|
storyPanelUI.SetActive(true);
|
||||||
storyText.text = "I hope the house is clean enough now so I don't get scolded later...";
|
storylineManager.EnqueueMessage("I hope the house is clean enough now so I don't get scolded later...", 7f)
|
||||||
|
|
||||||
StartCoroutine(ClearMessageAfterSeconds(7f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ using TMPro;
|
||||||
public class BrushTeeth : MonoBehaviour
|
public class BrushTeeth : MonoBehaviour
|
||||||
{
|
{
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
|
private StorylineManager storylineManager;
|
||||||
|
|
||||||
public Slider progressBar; // Reference to the Slider (progress bar)
|
public Slider progressBar; // Reference to the Slider (progress bar)
|
||||||
public float progressTime = 5f; // Time for the progress bar to complete
|
public float progressTime = 5f; // Time for the progress bar to complete
|
||||||
|
|
|
@ -79,10 +79,11 @@ public class GameManager : MonoBehaviour
|
||||||
|
|
||||||
public void AreTasksDone()
|
public void AreTasksDone()
|
||||||
{
|
{
|
||||||
|
Debug.Log("TASKS ARE DONE");
|
||||||
if (bedroomCleaned && teethBrushed && floorSweeped)
|
if (bedroomCleaned && teethBrushed && floorSweeped)
|
||||||
{
|
{
|
||||||
storyText.text = "I think I did everything... I should go to school now";
|
|
||||||
storyPanelUI.SetActive(true);
|
storyPanelUI.SetActive(true);
|
||||||
|
storyText.text = "I think I did everything... I should go to school now";
|
||||||
StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 7f));
|
StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 7f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,5 +114,4 @@ public class GameManager : MonoBehaviour
|
||||||
yield return new WaitForSeconds(delay);
|
yield return new WaitForSeconds(delay);
|
||||||
uiElement.SetActive(false);
|
uiElement.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
38
Game/Assets/Scripts/StorylineManager.cs
Normal file
38
Game/Assets/Scripts/StorylineManager.cs
Normal file
|
@ -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<string> messageQueue = new Queue<string>(); // 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;
|
||||||
|
}
|
||||||
|
}
|
11
Game/Assets/Scripts/StorylineManager.cs.meta
Normal file
11
Game/Assets/Scripts/StorylineManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b46ba12a5ba4d8d46852e7051b32010e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -111,6 +111,11 @@
|
||||||
"key": "editor.stripProBuilderScriptsOnBuild",
|
"key": "editor.stripProBuilderScriptsOnBuild",
|
||||||
"value": "{\"m_Value\":true}"
|
"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",
|
"type": "UnityEngine.ProBuilder.SelectionModifierBehavior, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
|
||||||
"key": "editor.rectSelectModifier",
|
"key": "editor.rectSelectModifier",
|
||||||
|
@ -161,6 +166,11 @@
|
||||||
"key": "ShapeBuilder.LastPivotLocation",
|
"key": "ShapeBuilder.LastPivotLocation",
|
||||||
"value": "{\"m_Value\":1}"
|
"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",
|
"type": "UnityEngine.ProBuilder.PivotLocation, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
|
||||||
"key": "mesh.newShapePivotLocation",
|
"key": "mesh.newShapePivotLocation",
|
||||||
|
@ -174,7 +184,11 @@
|
||||||
{
|
{
|
||||||
"type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
|
"type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
|
||||||
"key": "ShapeBuilder.LastSize",
|
"key": "ShapeBuilder.LastSize",
|
||||||
|
<<<<<<< Updated upstream
|
||||||
"value": "{\"m_Value\":{\"x\":0.248779296875,\"y\":-0.09796714782714844,\"z\":0.2877197265625}}"
|
"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",
|
"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",
|
"type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
|
||||||
"key": "uv.uvEditorGridSnapIncrement",
|
"key": "uv.uvEditorGridSnapIncrement",
|
||||||
"value": "{\"m_Value\":0.125}"
|
"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}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue