diff --git a/Game/Assets/Scenes/House.unity b/Game/Assets/Scenes/House.unity index 8395efc..1dde8a8 100644 --- a/Game/Assets/Scenes/House.unity +++ b/Game/Assets/Scenes/House.unity @@ -42650,6 +42650,82 @@ Mesh: offset: 0 size: 0 path: +--- !u!1 &620624014 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 620624015} + - component: {fileID: 620624017} + - component: {fileID: 620624016} + m_Layer: 5 + m_Name: Story Panel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &620624015 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 620624014} + 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: + - {fileID: 1214791148} + m_Father: {fileID: 1776114652} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &620624016 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 620624014} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &620624017 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 620624014} + m_CullTransparentMesh: 1 --- !u!43 &621483649 Mesh: m_ObjectHideFlags: 0 @@ -67443,7 +67519,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6045648537344725186, guid: a4a4b6738cb4ba34bb94baa14bd938f0, type: 3} propertyPath: m_LocalPosition.x - value: 75.189 + value: 72.062 objectReference: {fileID: 0} - target: {fileID: 6045648537344725186, guid: a4a4b6738cb4ba34bb94baa14bd938f0, type: 3} propertyPath: m_LocalPosition.y @@ -67451,7 +67527,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6045648537344725186, guid: a4a4b6738cb4ba34bb94baa14bd938f0, type: 3} propertyPath: m_LocalPosition.z - value: 1066.683 + value: 1069.24 objectReference: {fileID: 0} - target: {fileID: 6045648537344725186, guid: a4a4b6738cb4ba34bb94baa14bd938f0, type: 3} propertyPath: m_LocalRotation.w @@ -84670,6 +84746,140 @@ Transform: - {fileID: 1548920128} m_Father: {fileID: 533820784} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1214791147 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1214791148} + - component: {fileID: 1214791150} + - component: {fileID: 1214791149} + m_Layer: 5 + m_Name: Story Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1214791148 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1214791147} + 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: 620624015} + 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: 0, y: -191} + m_SizeDelta: {x: 200, y: 50} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1214791149 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1214791147} + 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: New Text + 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: -226.02475, 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 &1214791150 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1214791147} + m_CullTransparentMesh: 1 --- !u!43 &1217667260 Mesh: m_ObjectHideFlags: 0 @@ -90183,7 +90393,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &1295692143 Transform: m_ObjectHideFlags: 0 @@ -114383,6 +114593,7 @@ RectTransform: - {fileID: 707184550} - {fileID: 5551323} - {fileID: 1177838949} + - {fileID: 620624015} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -138144,7 +138355,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &2031915432 Transform: m_ObjectHideFlags: 0 @@ -140955,9 +141166,13 @@ MonoBehaviour: door: {fileID: 214241217} lockedDoorUI: {fileID: 1786768887} unlockedDoorUI: {fileID: 1654433218} + 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} --- !u!43 &2060072005 Mesh: m_ObjectHideFlags: 0 diff --git a/Game/Assets/Scripts/BedroomTask.cs b/Game/Assets/Scripts/BedroomTask.cs index dfa2d3c..7de5792 100644 --- a/Game/Assets/Scripts/BedroomTask.cs +++ b/Game/Assets/Scripts/BedroomTask.cs @@ -6,6 +6,7 @@ Description: To track if cleaning/exploring bedroom task is done before allowing using System.Collections; using System.Collections.Generic; +using TMPro; using UnityEngine; using UnityEngine.ProBuilder.Shapes; using UnityEngine.XR.Interaction.Toolkit.Interactables; @@ -13,13 +14,16 @@ using UnityEngine.XR.Interaction.Toolkit; public class BedroomTask : MonoBehaviour { + [Header("Task Requirement Values")] // To track how much trash has been collected so far public int trashCollected = 0; // Defines how much trash is needed to collect in order to unlock the door public int trashRequired = 10; + // Defines the door + [Header("Door to Unlock")] public GameObject door; // Defines the grab interactable to know when the door is grabbed @@ -32,13 +36,19 @@ public class BedroomTask : MonoBehaviour private Rigidbody doorRigidbody; // Defines UI references + [Header("UI References")] public GameObject lockedDoorUI; public GameObject unlockedDoorUI; + public GameObject storyPanelUI; + public TMP_Text storyText; // Defines Audio References + [Header("Audio References")] public AudioSource audioSource; public AudioClip lockedSound; public AudioClip unlockedSound; + public AudioClip footstepsSound; + public AudioClip doorSlamSound; void Start() { @@ -68,6 +78,15 @@ public class BedroomTask : MonoBehaviour LockDoor(); } } + + if (storyPanelUI != null && storyText != null) + { + storyPanelUI.SetActive(true); + storyText.text = "My parents are still home... I should clean up first."; + StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 10f)); + + } + } // Functions when trash is collected/thrown @@ -80,14 +99,10 @@ public class BedroomTask : MonoBehaviour // If player has collected/thrown required amount of trash if (trashCollected >= trashRequired) { - // Play sound only if no other sound is currently playing - if (!audioSource.isPlaying) - { - audioSource.PlayOneShot(unlockedSound); - } + Debug.Log("Trash requirement met! Starting sound sequence..."); - // Call unlocking door function - UnlockDoor(); + // Call unlocking door function/sequence + StartCoroutine(PlaySoundSequence()); } } @@ -122,7 +137,7 @@ public class BedroomTask : MonoBehaviour doorRigidbody.isKinematic = false; // Unfreezes door to let it open - doorRigidbody.constraints = RigidbodyConstraints.None; // Removes restrictions + doorRigidbody.constraints = RigidbodyConstraints.None; } // Ensure collider is not null @@ -168,6 +183,26 @@ public class BedroomTask : MonoBehaviour return trashCollected >= trashRequired; } + private IEnumerator PlaySoundSequence() + { + Debug.Log("Starting PlaySoundSequence..."); + + // Play footsteps of parents walking away + audioSource.PlayOneShot(footstepsSound); + yield return new WaitForSeconds(footstepsSound.length); + + // Play a door slam after the footsteps clip ends + audioSource.PlayOneShot(doorSlamSound); + yield return new WaitForSeconds(doorSlamSound.length); + + // 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."; + storyPanelUI.SetActive(true); + StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 10f)); + } + + // Function to hide the UI after a delay private IEnumerator HideMessageAfterSeconds(GameObject uiElement, float delay) { diff --git a/Game/Assets/Scripts/GameManager.cs b/Game/Assets/Scripts/GameManager.cs index 9515e8a..5232fbf 100644 --- a/Game/Assets/Scripts/GameManager.cs +++ b/Game/Assets/Scripts/GameManager.cs @@ -60,4 +60,9 @@ public class GameManager : MonoBehaviour { } + + public void BedroomTaskComplete() + { + bedroomCleaned = true; + } } diff --git a/Game/Assets/Scripts/TaskManager.cs b/Game/Assets/Scripts/TaskManager.cs deleted file mode 100644 index ec2d84b..0000000 --- a/Game/Assets/Scripts/TaskManager.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class TaskManager : MonoBehaviour -{ - - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } -} diff --git a/Game/Assets/Scripts/TaskManager.cs.meta b/Game/Assets/Scripts/TaskManager.cs.meta deleted file mode 100644 index 97c26f6..0000000 --- a/Game/Assets/Scripts/TaskManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2fb630affdddda844a313f76b6602abf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: