game: flow and ui done, making info collecting flow now

This commit is contained in:
rezazfn 2025-02-12 11:28:28 +08:00
parent 13b886dba4
commit 39837f913a
5 changed files with 190 additions and 60 deletions

View file

@ -14132,6 +14132,140 @@ Mesh:
offset: 0
size: 0
path:
--- !u!1 &197586934
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 197586935}
- component: {fileID: 197586937}
- component: {fileID: 197586936}
m_Layer: 5
m_Name: Tasks Completed
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &197586935
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 197586934}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1776114652}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 45, y: -191}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &197586936
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 197586934}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: I think I did everything... I think I can leave for school now
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 20
m_fontSizeBase: 20
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: -234.78311, y: 0, z: -121.96213, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &197586937
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 197586934}
m_CullTransparentMesh: 1
--- !u!1 &198323985
GameObject:
m_ObjectHideFlags: 0
@ -116342,6 +116476,7 @@ RectTransform:
- {fileID: 1177838949}
- {fileID: 620624015}
- {fileID: 1839460624}
- {fileID: 197586935}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
@ -143235,12 +143370,14 @@ MonoBehaviour:
trashRequired: 1
door: {fileID: 214241217}
lockedDoorUI: {fileID: 1786768887}
storyPanelUI: {fileID: 620624014}
storyText: {fileID: 1214791149}
audioSource: {fileID: 1898819871}
lockedSound: {fileID: 8300000, guid: 66df24e59b960964d967e61a34192cc5, type: 3}
unlockedSound: {fileID: 8300000, guid: 52fae69899b3fc24694a0f879a7d821a, type: 3}
footstepsSound: {fileID: 8300000, guid: 4e0d17ae4f88eb0438e2148301bb6bd5, type: 3}
doorSlamSound: {fileID: 8300000, guid: 3bc52e150f066454883c18b25be2b983, type: 3}
throwTrashSound: {fileID: 8300000, guid: c203d3014d6d6d94ea98b5a50d5a9b67, type: 3}
throwTrashSound: {fileID: 0}
--- !u!43 &2060072005
Mesh:
m_ObjectHideFlags: 0

View file

@ -16,7 +16,6 @@ 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
@ -41,8 +40,8 @@ public class BedroomTask : MonoBehaviour
// Defines UI references
[Header("UI References")]
public GameObject lockedDoorUI;
//public GameObject storyPanelUI;
//public TMP_Text storyText;
public GameObject storyPanelUI;
public TMP_Text storyText;
// Defines Audio References
[Header("Audio References")]
@ -55,8 +54,6 @@ public class BedroomTask : MonoBehaviour
void Start()
{
storylineManager = FindObjectOfType<StorylineManager>();
// Hide all UI prompts on start
lockedDoorUI.SetActive(false);
//unlockedDoorUI.SetActive(false);
@ -84,13 +81,13 @@ public class BedroomTask : MonoBehaviour
}
}
storylineManager.EnqueueMessage("My parents are still home... I should wait for them to leave.", 7f);
/*if (storyPanelUI != null && storyText != null)
if (storyPanelUI != null && storyText != null)
{
storyPanelUI.SetActive(true);
storyText.text = "My parents are still home... I should clean up first.";
StartCoroutine(ClearMessageAfterSeconds(7f));
}*/
}
}
// Functions when trash is collected/thrown
@ -211,9 +208,8 @@ public class BedroomTask : MonoBehaviour
{
PostProcessingManager.Instance.TriggerEffect("Panic");
storylineManager.EnqueueMessage("!!!", 7f);
/*storyPanelUI.SetActive(true);
storyText.text = "!!!";*/
storyPanelUI.SetActive(true);
storyText.text = "!!!";
// Play footsteps of parents walking away
audioSource.PlayOneShot(footstepsSound);
@ -227,15 +223,13 @@ public class BedroomTask : MonoBehaviour
PostProcessingManager.Instance.StopEffect("Panic");
// Clear the "!!!"
//storyText.text = "";
storyText.text = "";
// Unlocks the door after the clips and update the story
UnlockDoor();
storylineManager.EnqueueMessage("They finally left... I can leave the room now", 5f);
/*storyText.text = "They finally left just as soon as I finished cleaning. I can leave the room now.";
StartCoroutine(ClearMessageAfterSeconds(7f));*/
storyText.text = "They finally left... just as soon as I finished cleaning. I can leave the room now.";
StartCoroutine(ClearMessageAfterSeconds(7f));
}
// Function to hide the UI after a delay
@ -243,7 +237,7 @@ public class BedroomTask : MonoBehaviour
{
// Waits for delay to end and hides the UI
yield return new WaitForSeconds(delay);
//storyText.text = "";
storyText.text = "";
}
private IEnumerator HidePanelAfterSeconds(GameObject uiElement, float delay)

View file

@ -13,7 +13,6 @@ 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;
@ -25,19 +24,14 @@ public class BroomSweeping : MonoBehaviour
// Defines UI references
[Header("UI References")]
//public GameObject storyPanelUI;
public GameObject storyPanelUI;
public TMP_Text storyText;
// Defines Audio References
[Header("Audio References")]
public AudioSource audioSource;
public AudioClip sweepingSound;
void Start()
{
storylineManager = FindObjectOfType<StorylineManager>();
}
// Update is called once per frame
void Update()
{
@ -46,12 +40,10 @@ public class BroomSweeping : MonoBehaviour
taskCompleted = true;
GameManager.Instance.FloorSweepedTaskComplete();
//storyPanelUI.SetActive(true);
//storyText.text = "I hope the house is clean enough now so I don't get scolded later...";
storyPanelUI.SetActive(true);
storyText.text = "I hope the house is clean enough now so I don't get scolded later...";
storylineManager.EnqueueMessage("I tried my best... Hopefully I don't get scolded later.", 7f);
//StartCoroutine(ClearMessageAfterSeconds(7f));
StartCoroutine(ClearMessageAfterSeconds(7f));
}
}

View file

@ -16,7 +16,6 @@ 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
@ -39,8 +38,6 @@ public class BrushTeeth : MonoBehaviour
void Start()
{
storylineManager = FindObjectOfType<StorylineManager>();
grabInteractable = GetComponent<XRGrabInteractable>();
if (grabInteractable == null)
@ -127,13 +124,11 @@ public class BrushTeeth : MonoBehaviour
GameManager.Instance.BrushTeethTaskComplete();
storylineManager.EnqueueMessage("I should be fresh enough to go to school...", 7f);
//storyPanelUI.SetActive(true);
//storyText.text = "I should be fresh enough to go to school now...";
storyPanelUI.SetActive(true);
storyText.text = "I should be fresh enough to go to school now...";
// Clear the text after a delay
//StartCoroutine(ClearMessageAfterSeconds(7f));
StartCoroutine(ClearMessageAfterSeconds(7f));
Debug.Log("Progress completed!");
}

View file

@ -11,7 +11,6 @@ using TMPro;
public class GameManager : MonoBehaviour
{
/// <summary>
/// Define instance field for accessing the singleton elsewhere
/// </summary>
@ -26,6 +25,10 @@ public class GameManager : MonoBehaviour
private bool bedroomCleaned = false;
private bool teethBrushed = false;
private bool floorSweeped = false;
// Queue for managing messages
private Queue<string> messageQueue = new Queue<string>();
private bool isMessageActive = false;
/// <summary>
/// Checks if tasks are completed
@ -53,19 +56,39 @@ public class GameManager : MonoBehaviour
Destroy(gameObject);
}
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
// Continuously check and display queued messages
if (!isMessageActive && messageQueue.Count > 0)
{
string nextMessage = messageQueue.Dequeue();
StartCoroutine(DisplayMessage(nextMessage));
}
}
/// <summary>
/// Queues a message to be displayed
/// </summary>
public void QueueMessage(string message)
{
messageQueue.Enqueue(message);
}
/// <summary>
/// Displays a message and waits for it to disappear
/// </summary>
private IEnumerator DisplayMessage(string message)
{
isMessageActive = true;
storyPanelUI.SetActive(true);
storyText.text = message;
yield return new WaitForSeconds(7f); // Wait for 7 seconds before hiding
storyPanelUI.SetActive(false);
isMessageActive = false;
}
// Logs player's choices before leaving the house (for future Firebase tracking)
public void LogPlayerChoices()
{
@ -73,18 +96,13 @@ public class GameManager : MonoBehaviour
Debug.Log("Bedroom Cleaned: " + bedroomCleaned);
Debug.Log("Teeth Brushed: " + teethBrushed);
Debug.Log("Floor Sweeped: " + floorSweeped);
// Future-proofing for Firebase tracking
}
public void AreTasksDone()
{
Debug.Log("TASKS ARE DONE");
if (bedroomCleaned && teethBrushed && floorSweeped)
{
storyPanelUI.SetActive(true);
storyText.text = "I think I did everything... I should go to school now";
StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 7f));
QueueMessage("I think I did everything... I think I can leave for school now");
}
}
@ -108,10 +126,4 @@ public class GameManager : MonoBehaviour
floorSweeped = true;
AreTasksDone();
}
private IEnumerator HideMessageAfterSeconds(GameObject uiElement, float delay)
{
// Waits for delay to end and hides the UI
yield return new WaitForSeconds(delay);
uiElement.SetActive(false);
}
}