game: continuing game flow.........

This commit is contained in:
rezazfn 2025-02-11 13:57:18 +08:00
parent 6fded2c20d
commit 9be96a67fb
10 changed files with 727 additions and 5315 deletions

BIN
Game/Assets/Audio/Sweeping.mp3 (Stored with Git LFS)

Binary file not shown.

View file

@ -1,5 +1,33 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-7971538219786904851
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 66f335fb1ffd8684294ad653bf1c7564, type: 3}
m_Name: ColorAdjustments
m_EditorClassIdentifier:
active: 1
postExposure:
m_OverrideState: 0
m_Value: 0
contrast:
m_OverrideState: 0
m_Value: 0
colorFilter:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
hueShift:
m_OverrideState: 0
m_Value: 0
saturation:
m_OverrideState: 0
m_Value: 0
--- !u!114 &-1055684596109920917
MonoBehaviour:
m_ObjectHideFlags: 3
@ -21,13 +49,38 @@ MonoBehaviour:
m_Value: {x: 0.5, y: 0.5}
intensity:
m_OverrideState: 1
m_Value: 0.2
m_Value: 0.211
smoothness:
m_OverrideState: 1
m_Value: 1
rounded:
m_OverrideState: 1
m_Value: 0
--- !u!114 &-250395203872362012
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ccf1aba9553839d41ae37dd52e9ebcce, type: 3}
m_Name: MotionBlur
m_EditorClassIdentifier:
active: 1
mode:
m_OverrideState: 1
m_Value: 0
quality:
m_OverrideState: 1
m_Value: 0
intensity:
m_OverrideState: 1
m_Value: 0
clamp:
m_OverrideState: 1
m_Value: 0.05
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
@ -43,6 +96,37 @@ MonoBehaviour:
components:
- {fileID: -1055684596109920917}
- {fileID: 7381809258467126695}
- {fileID: -250395203872362012}
- {fileID: 6251107123337564194}
- {fileID: -7971538219786904851}
--- !u!114 &6251107123337564194
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c5e1dc532bcb41949b58bc4f2abfbb7e, type: 3}
m_Name: LensDistortion
m_EditorClassIdentifier:
active: 1
intensity:
m_OverrideState: 1
m_Value: 0
xMultiplier:
m_OverrideState: 1
m_Value: 1
yMultiplier:
m_OverrideState: 1
m_Value: 1
center:
m_OverrideState: 1
m_Value: {x: 0.5, y: 0.5}
scale:
m_OverrideState: 1
m_Value: 1
--- !u!114 &7381809258467126695
MonoBehaviour:
m_ObjectHideFlags: 3

File diff suppressed because one or more lines are too long

View file

@ -40,7 +40,6 @@ public class BedroomTask : MonoBehaviour
// Defines UI references
[Header("UI References")]
public GameObject lockedDoorUI;
public GameObject unlockedDoorUI;
public GameObject storyPanelUI;
public TMP_Text storyText;
@ -51,12 +50,13 @@ public class BedroomTask : MonoBehaviour
public AudioClip unlockedSound;
public AudioClip footstepsSound;
public AudioClip doorSlamSound;
public AudioClip throwTrashSound;
void Start()
{
// Hide all UI prompts on start
lockedDoorUI.SetActive(false);
unlockedDoorUI.SetActive(false);
//unlockedDoorUI.SetActive(false);
// Ensure door is not null
if (door != null)
@ -85,7 +85,7 @@ public class BedroomTask : MonoBehaviour
{
storyPanelUI.SetActive(true);
storyText.text = "My parents are still home... I should clean up first.";
StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 10f));
StartCoroutine(ClearMessageAfterSeconds(7f));
}
}
@ -95,6 +95,13 @@ public class BedroomTask : MonoBehaviour
{
// Add to trash count
trashCollected++;
// Play sound only if no other sound is currently playing
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(throwTrashSound);
}
Debug.Log($"Trash collected: {trashCollected}/{trashRequired}");
// If player has collected/thrown required amount of trash
@ -162,10 +169,10 @@ public class BedroomTask : MonoBehaviour
}
// Show the unlocked door UI
unlockedDoorUI.SetActive(true);
// unlockedDoorUI.SetActive(true);
// Call the function to hide the UI after delay
StartCoroutine(HideMessageAfterSeconds(unlockedDoorUI, 5f));
//StartCoroutine(HideMessageAfterSeconds(unlockedDoorUI, 5f));
Debug.Log("Room is clean! The door is now unlocked.");
}
@ -185,7 +192,7 @@ public class BedroomTask : MonoBehaviour
}
// Call the function to hide the UI after delay
StartCoroutine(HideMessageAfterSeconds(lockedDoorUI, 5f));
StartCoroutine(HidePanelAfterSeconds(lockedDoorUI, 5f));
Debug.Log("The door is locked! Clean the room first.");
}
}
@ -199,10 +206,10 @@ public class BedroomTask : MonoBehaviour
private IEnumerator PlaySoundSequence()
{
storyText.text = "!!!";
storyPanelUI.SetActive(true);
PostProcessingManager.Instance.TriggerEffect("Panic");
PostProcessingManager.Instance.StartEffect("Panic");
storyPanelUI.SetActive(true);
storyText.text = "!!!";
// Play footsteps of parents walking away
audioSource.PlayOneShot(footstepsSound);
@ -212,7 +219,7 @@ public class BedroomTask : MonoBehaviour
audioSource.PlayOneShot(doorSlamSound);
yield return new WaitForSeconds(doorSlamSound.length);
// Stop the panic effect once the door slam sound ends
PostProcessingManager.Instance.StopEffect("Panic");
// Clear the "!!!"
@ -221,28 +228,22 @@ public class BedroomTask : MonoBehaviour
// Unlocks the door after the clips and update the story
UnlockDoor();
// Add a small delay before updating the text to ensure everything shows properly
yield return new WaitForSeconds(0.5f);
storyText.text = "They finally left... just as soon as I finished cleaning. I can leave the room now.";
StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 10f));
StartCoroutine(ClearMessageAfterSeconds(7f));
}
// Function to hide the UI after a delay
private IEnumerator HideMessageAfterSeconds(GameObject uiElement, float delay)
private IEnumerator ClearMessageAfterSeconds(float delay)
{
// Waits for delay to end and hides the UI
yield return new WaitForSeconds(delay);
storyText.text = "";
}
private IEnumerator HidePanelAfterSeconds(GameObject uiElement, float delay)
{
// Waits for delay to end and hides the UI
yield return new WaitForSeconds(delay);
uiElement.SetActive(false);
}
public void ApplyHeadacheEffect()
{
PostProcessingManager.Instance?.TriggerEffect("Headache");
}
public void ApplyDizzinessEffect()
{
PostProcessingManager.Instance?.TriggerEffect("Dizziness");
}
}

View file

@ -20,6 +20,8 @@ public class BroomSweeping : MonoBehaviour
// Defines how much trash is needed to collect in order to unlock the door
public int dirtRequired = 10;
private bool taskCompleted = false;
// Defines UI references
[Header("UI References")]
public GameObject storyPanelUI;
@ -33,20 +35,23 @@ public class BroomSweeping : MonoBehaviour
// Update is called once per frame
void Update()
{
if (dirtSweeped >= dirtRequired)
if (dirtSweeped >= dirtRequired && !taskCompleted)
{
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...";
StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 7f));
StartCoroutine(ClearMessageAfterSeconds(7f));
}
}
private void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Dirt"))
// Now correctly checks for "Dirt" before triggering
if (other.CompareTag("Dirt"))
{
// Add to dirt swept count
dirtSweeped++;
// Destroy it to prevent extra counting
@ -59,10 +64,11 @@ public class BroomSweeping : MonoBehaviour
}
}
}
private IEnumerator HideMessageAfterSeconds(GameObject uiElement, float delay)
private IEnumerator ClearMessageAfterSeconds(float delay)
{
// Waits for delay to end and hides the UI
yield return new WaitForSeconds(delay);
uiElement.SetActive(false);
storyText.text = "";
}
}

View file

@ -23,6 +23,8 @@ public class BrushTeeth : MonoBehaviour
private float timer = 0f;
private bool isGrabbing = false;
private bool taskCompleted = false;
// Defines UI references
[Header("UI References")]
@ -54,7 +56,7 @@ public class BrushTeeth : MonoBehaviour
void Update()
{
if (isGrabbing)
if (isGrabbing && !taskCompleted)
{
timer += Time.deltaTime;
progressBar.value = timer / progressTime;
@ -108,6 +110,9 @@ public class BrushTeeth : MonoBehaviour
private void CompleteProgress()
{
if (taskCompleted) return;
taskCompleted = true;
progressBar.gameObject.SetActive(false);
isGrabbing = false;
@ -119,8 +124,11 @@ public class BrushTeeth : MonoBehaviour
GameManager.Instance.BrushTeethTaskComplete();
storyPanelUI.SetActive(true);
storyText.text = "I should be fresh enough to go to school now...";
StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 7f));
// Clear the text after a delay
StartCoroutine(ClearMessageAfterSeconds(7f));
Debug.Log("Progress completed!");
}
@ -134,10 +142,10 @@ public class BrushTeeth : MonoBehaviour
}
}
private IEnumerator HideMessageAfterSeconds(GameObject uiElement, float delay)
private IEnumerator ClearMessageAfterSeconds(float delay)
{
// Waits for delay to end and hides the UI
yield return new WaitForSeconds(delay);
uiElement.SetActive(false);
storyText.text = "";
}
}

View file

@ -17,6 +17,10 @@ public class GameManager : MonoBehaviour
/// </summary>
public static GameManager Instance;
// Defines UI references
[Header("UI References")]
public GameObject storyPanelUI;
public TMP_Text storyText;
// Trackable Task Completions
private bool bedroomCleaned = false;
@ -73,22 +77,41 @@ public class GameManager : MonoBehaviour
// Future-proofing for Firebase tracking
}
public void AreTasksDone()
{
if (bedroomCleaned && teethBrushed && floorSweeped)
{
storyText.text = "I think I did everything... I should go to school now";
storyPanelUI.SetActive(true);
StartCoroutine(HideMessageAfterSeconds(storyPanelUI, 7f));
}
}
// Tracks if bedroom is cleaned or not
public void BedroomTaskComplete()
{
bedroomCleaned = true;
AreTasksDone();
}
// Tracks if teeth is brushed or not
public void BrushTeethTaskComplete()
{
teethBrushed = true;
AreTasksDone();
}
// Tracks if floor is sweeped or not
public void FloorSweepedTaskComplete()
{
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);
}
}

View file

@ -29,21 +29,24 @@ public class PostProcessingManager : MonoBehaviour
[SerializeField]
public AnimationCurve vignetteIntensity;
[SerializeField]
public AnimationCurve chromaticAberrationIntensity;
[SerializeField] public AnimationCurve chromaticAberrationIntensity;
[SerializeField]
public AnimationCurve motionBlurIntensity;
[SerializeField] public AnimationCurve motionBlurIntensity;
[SerializeField]
public AnimationCurve lensDistortionIntensity;
[SerializeField] public AnimationCurve lensDistortionIntensity;
[SerializeField]
public AnimationCurve colorAdjustmentsIntensity;
[SerializeField] public AnimationCurve colorAdjustmentsIntensity;
// Checks if effect is active or not
private bool isEffectActive = false;
// Defines Audio References
[Header("Audio References")] public AudioSource audioSource;
public AudioClip heartbeatSound;
public AudioClip whisperSound;
public AudioClip distortedWhisperSound;
void Awake()
{
if (Instance == null)
@ -113,60 +116,68 @@ public class PostProcessingManager : MonoBehaviour
if (motionBlur != null) motionBlur.intensity.Override(0f);
if (lensDistortion != null) lensDistortion.intensity.Override(0f);
if (colorAdjustments != null) colorAdjustments.postExposure.Override(0f);
// Stop audio
if (audioSource != null)
{
audioSource.Stop();
}
}
// Applies effects over time based on the type
private IEnumerator ApplyEffect(string effectName)
{
float time = 0f;
float duration = 1f;
while (time < duration)
// Handle the audio for the effect
if (effectName == "Panic")
{
time += Time.deltaTime;
float t = Mathf.Clamp01(time / duration);
// Values for headache effect
if (effectName == "Headache")
{
vignette.intensity.Override(vignetteIntensity.Evaluate(time));
chromaticAberration.intensity.Override(chromaticAberrationIntensity.Evaluate(time));
}
// Values for dizziness effect
else if (effectName == "Dizziness")
{
motionBlur.intensity.Override(motionBlurIntensity.Evaluate(time));
lensDistortion.intensity.Override(lensDistortionIntensity.Evaluate(time));
}
yield return null;
audioSource.clip = heartbeatSound;
audioSource.loop = true;
audioSource.Play();
}
else if (effectName == "Headache")
{
audioSource.clip = whisperSound;
audioSource.loop = true;
audioSource.Play();
}
else if (effectName == "Dizziness")
{
audioSource.clip = distortedWhisperSound;
audioSource.loop = true;
audioSource.Play();
}
}
public void ApplyPanicEffect()
{
StartCoroutine(LoopPanicEffect());
}
private IEnumerator LoopPanicEffect()
{
float time = 0f;
float duration = 0.1f;
// Apply effects while the effect is active
while (isEffectActive)
{
time += Time.deltaTime;
float t = Mathf.PingPong(time / duration, 1f); // Looping the effect
// Visual effects for headache
if (effectName == "Headache")
{
vignette.intensity.Override(vignetteIntensity.Evaluate(Time.time));
chromaticAberration.intensity.Override(chromaticAberrationIntensity.Evaluate(Time.time));
}
// Apply intensity for panic effect
vignette.intensity.Override(vignetteIntensity.Evaluate(t));
chromaticAberration.intensity.Override(chromaticAberrationIntensity.Evaluate(t));
motionBlur.intensity.Override(motionBlurIntensity.Evaluate(t));
lensDistortion.intensity.Override(lensDistortionIntensity.Evaluate(t));
colorAdjustments.postExposure.Override(colorAdjustmentsIntensity.Evaluate(t));
// Visual effects for dizziness
if (effectName == "Dizziness")
{
motionBlur.intensity.Override(motionBlurIntensity.Evaluate(Time.time));
lensDistortion.intensity.Override(lensDistortionIntensity.Evaluate(Time.time));
}
// Visual effects for panic
if (effectName == "Panic")
{
motionBlur.intensity.Override(motionBlurIntensity.Evaluate(Time.time));
lensDistortion.intensity.Override(lensDistortionIntensity.Evaluate(Time.time));
chromaticAberration.intensity.Override(chromaticAberrationIntensity.Evaluate(Time.time));
}
yield return null;
}
// Stop audio when the effect ends
if (audioSource != null && audioSource.isPlaying)
{
audioSource.Stop();
}
}
}

View file

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
executionOrder: 150
icon: {instanceID: 0}
userData:
assetBundleName:

View file

@ -159,7 +159,7 @@
{
"type": "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "ShapeBuilder.ActiveShapeIndex",
"value": "{\"m_Value\":6}"
"value": "{\"m_Value\":7}"
},
{
"type": "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
@ -184,11 +184,7 @@
{
"type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.LastSize",
<<<<<<< HEAD
"value": "{\"m_Value\":{\"x\":-0.4071826934814453,\"y\":0.2012939453125,\"z\":-0.5807037353515625}}"
=======
"value": "{\"m_Value\":{\"x\":0.197540283203125,\"y\":0.015741348266601564,\"z\":0.1954345703125}}"
>>>>>>> fb51f41 (calling updates)
},
{
"type": "UnityEngine.Quaternion, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",