Compare commits

...

13 commits

13 changed files with 346 additions and 415 deletions

View file

@ -146,7 +146,7 @@ public class GameManager : MonoBehaviour
QueueMessage("I think I did everything... I think I can leave for school now");
}
// mark: u can track whether they want to do their tasks, some people may be unmotivated to
// for mark (backend): u can track whether they want to do their tasks, some people may be unmotivated to
// do the tasks in game, then we can ask them irl why they didn't do the task
// Tracks if the bedroom is cleaned or not

View file

@ -1,13 +1,12 @@
/*
Author: Reza
Date: 7/2/25
Description: Collects information when a player looks at objects long enough
*/
* Author: Reza
* Date: 7/2/25
* Description: Collects information when a player looks at objects long enough
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine;
public class InfoCollector : MonoBehaviour
{
@ -23,149 +22,129 @@ public class InfoCollector : MonoBehaviour
// Defines the UI text to display
public TMP_Text infoText;
// Defines the camera
private Camera vrCamera;
// Defines whether UI is displaying to prevent spamming
private bool isDisplaying = false;
// Defines the object the player is currently looking at
private GameObject currentObject = null;
// Tracks how long the player has been looking at the object
private float gazeTimer = 0f;
// Defines Audio References
public AudioSource audioSource;
public AudioClip scribbleSound;
// Store objects that have already been collected
private HashSet<GameObject> collectedObjects = new HashSet<GameObject>();
void Start()
// Store objects that have already been collected
private readonly HashSet<GameObject> _collectedObjects = new();
// Defines the object the player is currently looking at
private GameObject _currentObject;
// Tracks how long the player has been looking at the object
private float _gazeTimer;
// Defines whether UI is displaying to prevent spamming
private bool _isDisplaying;
// Defines the camera
private Camera _vrCamera;
private void Start()
{
// Assigns to player's camera
vrCamera = Camera.main;
_vrCamera = Camera.main;
// Clear UI text initially
infoText.text = "";
}
void Update()
private void Update()
{
// Detects the direction the player is looking at
Ray ray = new Ray(vrCamera.transform.position, vrCamera.transform.forward);
RaycastHit hit;
var ray = new Ray(_vrCamera.transform.position, _vrCamera.transform.forward);
// Stores data of object hit in the detection range
if (Physics.Raycast(ray, out hit, detectionRange))
if (Physics.Raycast(ray, out var hit, detectionRange))
{
// Ensures that relevant info objects are detected
if (hit.collider.CompareTag("InfoObject"))
if (!hit.collider.CompareTag("InfoObject")) return;
var targetObject = hit.collider.gameObject;
// **Fix: Stop gaze timer if an object has been collected**
if (_collectedObjects.Contains(targetObject)) return; // Exit without increasing gaze time
// If the player is still looking at the same object, increase gaze time
if (_currentObject == targetObject)
{
GameObject targetObject = hit.collider.gameObject;
_gazeTimer += Time.deltaTime;
// **Fix: Stop gaze timer if object has been collected**
if (collectedObjects.Contains(targetObject))
{
return; // Exit without increasing gaze time
}
// If the player is still looking at the same object, increase gaze time
if (currentObject == targetObject)
{
gazeTimer += Time.deltaTime;
// If gaze time reaches required time and info is not displayed yet
if (gazeTimer >= gazeTimeRequired && !isDisplaying)
{
CollectInfo(targetObject);
}
}
else
{
// Reset timer when looking at a new object
currentObject = targetObject;
gazeTimer = 0f;
}
// If gaze time reaches the required time and info is not displayed yet
if (_gazeTimer >= gazeTimeRequired && !_isDisplaying) CollectInfo(targetObject);
}
else
{
// Reset timer when looking at a new object
_currentObject = targetObject;
_gazeTimer = 0f;
}
}
else
{
// Reset if no valid object is in view
currentObject = null;
gazeTimer = 0f;
_currentObject = null;
_gazeTimer = 0f;
}
}
// Function to display object information
void CollectInfo(GameObject obj)
private void CollectInfo(GameObject obj)
{
// Prevents spamming of display
isDisplaying = true;
_isDisplaying = true;
// **Fix: Mark object as collected**
collectedObjects.Add(obj);
_collectedObjects.Add(obj);
// Displays information
infoText.text = "<size=15>Info Collected:</size>\n\n" +
"<size=20>" + obj.name + "</size>\n" +
// Display information
infoText.text = "<size=15>Info Collected:</size>\n\n" +
"<size=20>" + obj.name + "</size>\n" +
"<size=16>" + GetObjectInfo(obj) + "</size>";
Debug.Log("Collected information from: " + obj.name);
// Play sound only if no other sound is currently playing
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(scribbleSound);
}
if (!audioSource.isPlaying) audioSource.PlayOneShot(scribbleSound);
// Clears text after displayed time
Invoke(nameof(ClearText), displayTime);
}
// Function to clear text after a delay
void ClearText()
private void ClearText()
{
// Removes text
infoText.text = "";
// Allows new information to be displayed
isDisplaying = false;
_isDisplaying = false;
}
// mark : this info collecting mechanism is more of easter eggs and if the players are
// for mark (backend): this info collecting mechanism is more of easter eggs and if the players are
// observant enough to look around the room / find out what the character is going through
// can use this as statistics of what players tend to focus on
string GetObjectInfo(GameObject obj)
private static string GetObjectInfo(GameObject obj)
{
// Check if the object's name is the same
if (obj.name == "Needles")
return obj.name switch
{
// Check if the object's name is the same
// Returns predefined information
return "A used needle. If my parents finds out they would murder me.";
if (obj.name == "Bottles")
"Needles" => "A used needle. If my parents finds out they would murder me.",
// Returns predefined information
return "Saw dad drink this... I like how it numbs the pain";
if (obj.name == "Cigarettes")
"Bottles" => "Saw dad drink this... I like how it numbs the pain",
// Returns predefined information
return "Stole this from mom. I hope she doesn't find out.";
if (obj.name == "Penknife")
"Cigarettes" => "Stole this from mom. I hope she doesn't find out.",
// Returns predefined information
return "Sometimes I use this to feel something.";
if (obj.name == "Blood")
"Penknife" => "Sometimes I use this to feel something.",
// Returns predefined information
return "I don't remember if daddy or I did this.";
if (obj.name == "ParentsDoor")
"Blood" => "I don't remember if daddy or I did this.",
// Returns predefined information
return "My parents room. It's locked";
// Default information if there is no specific case
return "There's nothing to look at.";
"ParentsDoor" => "My parents room. It's locked",
// Default information if there is no specific case
_ => "There's nothing to look at."
};
}
}

View file

@ -1,69 +1,65 @@
/*
Author: Reza, Wai Lam, Mark
Date: 10/2/25
Description: Verifies whether tasks in the house are completed before going to the next scene
*/
* Author: Reza, Wai Lam, Mark
* Date: 10/2/25
* Description: Verifies whether tasks in the house are completed before going to the next scene
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LeaveHouseTrigger : MonoBehaviour
{
// Name of the next scene
public string nextSceneName;
public string Day3;
public GameObject confirmationPanel;
public string day3;
public GameObject confirmationPanel;
public TMP_Text warningText;
public GameObject warningPanel;
// Start is called before the first frame update
void Start()
private void Start()
{
confirmationPanel.SetActive(false);
warningText.text = "";
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
ShowConfirmationButtons();
}
if (other.CompareTag("Player")) ShowConfirmationButtons();
}
void ShowConfirmationButtons()
private void ShowConfirmationButtons()
{
// FIXED: possibly refer to purely GameManager.Instance instead of any
// early-bound reference to GameManager because the game manager might
// early bound reference to GameManager because the game manager might
// not have died fast enough for other scripts to refer to the new
// GameManager instance
// keeping this here for future ref
// --mark
Debug.Log("Current Day in ShowConfirmationButtons: " + GameManager.Instance.currentDay);
confirmationPanel.SetActive(true);
warningPanel.SetActive(true);
Debug.Log("Current Day is: " + GameManager.Instance.currentDay);
if (GameManager.Instance.currentDay == 1)
{
Debug.Log("Setting text for Day 1");
warningText.text = "Should I leave the house? I might not have completed everything...";
}
else if (GameManager.Instance.currentDay == 2)
Debug.Log("Current Day in ShowConfirmationButtons: " + GameManager.Instance.CurrentDay);
confirmationPanel.SetActive(true);
warningPanel.SetActive(true);
Debug.Log("Current Day is: " + GameManager.Instance.CurrentDay);
switch (GameManager.Instance.CurrentDay)
{
Debug.Log("Setting text for Day 2");
warningText.text = "Do I even want to go to school...";
case 1:
Debug.Log("Setting text for Day 1");
warningText.text = "Should I leave the house? I might not have completed everything...";
break;
case 2:
Debug.Log("Setting text for Day 2");
warningText.text = "Do I even want to go to school...";
break;
}
StartCoroutine(HideWarningPanelAfterDelay(7f)); // can change how long you want the text to show for
// can change how long you want the text to show for
StartCoroutine(HideWarningPanelAfterDelay(7f));
}
IEnumerator HideWarningPanelAfterDelay(float delay)
private IEnumerator HideWarningPanelAfterDelay(float delay)
{
yield return new WaitForSeconds(delay);
warningPanel.SetActive(false);
@ -72,19 +68,20 @@ public class LeaveHouseTrigger : MonoBehaviour
public void ConfirmLeave()
{
// Log player choices
GameManager.Instance.LogPlayerChoices();
GameManager.Instance.LogPlayerChoices();
// Load the next scene directly without needing to set the last scene
SceneManager.LoadScene(nextSceneName);
}
public void CancelLeave()
{
if (GameManager.Instance.currentDay == 2)
if (GameManager.Instance.CurrentDay == 2)
{
GameManager.Instance.IncrementDay();
SceneManager.LoadScene(Day3);
SceneManager.LoadScene(day3);
}
confirmationPanel.SetActive(false);
warningPanel.SetActive(true);
}

View file

@ -1,22 +1,19 @@
/*
Author: Reza
Date: 3/2/25
Description: To show letter UI when letter is picked up or dropped
*/
* Author: Reza
* Date: 3/2/25
* Description: To show letter UI when the letter is picked up or dropped
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class Letter : MonoBehaviour
{
public GameObject letterUI;
public AudioClip scribble;
private void Start()
{
letterUI.SetActive(false);
letterUI.SetActive(false);
}
public void ShowLetterUI()
@ -30,4 +27,4 @@ public class Letter : MonoBehaviour
letterUI.SetActive(false);
Debug.Log("Dropped letter - UI should hide");
}
}
}

View file

@ -1,49 +1,48 @@
/*
Author: Reza
Date: 7/2/25
Description: General script for any message triggering areas
*/
* Author: Reza
* Date: 7/2/25
* Description: General script for any message triggering areas
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine;
public class MessageTrigger : MonoBehaviour
{
// Defines UI references
[Header("UI References")]
public GameObject storyPanelUI;
[Header("UI References")] public GameObject storyPanelUI;
public TMP_Text storyText;
[Header("Message Settings")]
// Custom message for this trigger
[TextArea(3, 5)] public string message;
[TextArea(3, 5)]
public string message;
// How long the message stays on screen
public float displayDuration = 5f;
// Has message been triggered already or not
private bool messageTriggered = false;
public float displayDuration = 5f;
// Has the message been triggered already or not?
private bool _messageTriggered;
private void OnTriggerEnter(Collider other)
{
// Shows up only if message has not been triggered and ensures only player triggers it
if (!messageTriggered && other.CompareTag("Player"))
{
storyPanelUI.SetActive(true);
storyText.text = message;
StartCoroutine(HideMessageAfterSeconds(displayDuration));
// Prevents message triggering again
messageTriggered = true;
}
// Shows up only if the message has not been triggered and ensures only player triggers it
if (_messageTriggered || !other.CompareTag("Player")) return;
storyPanelUI.SetActive(true);
storyText.text = message;
StartCoroutine(HideMessageAfterSeconds(displayDuration));
// Prevents a message triggering again
_messageTriggered = true;
}
private IEnumerator HideMessageAfterSeconds(float delay)
{
// Waits for delay to end and hides the UI
yield return new WaitForSeconds(delay);
storyPanelUI.SetActive(false);
}
}
}

View file

@ -1,37 +1,32 @@
/*
Author: Reza
Date: 13/2/25
Description: Day 3 script that goes to the last scene after a certain amount of time
*/
* Author: Reza
* Date: 13/2/25
* Description: Day 3 script that goes to the last scene after a certain amount of time
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Day3 : MonoBehaviour
{
// Time in seconds to wait before transitioning to the next scene
public float timeToWait = 60f; // Change this to the desired wait time
private float timer;
public string NextScene;
public string nextScene;
private float _timer;
void Start()
private void Start()
{
// Initialize timer
timer = 0f;
_timer = 0f;
}
void Update()
private void Update()
{
// Increment timer
timer += Time.deltaTime;
_timer += Time.deltaTime;
// Check if the time has passed
if (timer >= timeToWait)
{
if (_timer >= timeToWait)
// Call method to change the scene
GameManager.Instance.IncrementDay();
}
GameManager.Instance.IncrementDay();
}
}

View file

@ -1,5 +1,10 @@
/*
* Author: Isaac
* Date: 11/2/25
* Description: Post-processing camera effects emulating various conditions
*/
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.SceneManagement;
public class PhoneInteraction : MonoBehaviour
@ -8,70 +13,53 @@ public class PhoneInteraction : MonoBehaviour
public GameObject choiceUI; // Assign your UI Panel in Inspector
public Transform attachTransform; // Drag XR Controller's Attach Transform here
private AudioSource audioSource;
private bool phonePickedUp = false;
private bool choiceMade = false;
private AudioSource _audioSource;
private bool _choiceMade;
private bool _phonePickedUp;
void Start()
private void Start()
{
// Ensure AudioSource is available
if (!TryGetComponent(out audioSource))
{
audioSource = gameObject.AddComponent<AudioSource>();
}
if (!TryGetComponent(out _audioSource)) _audioSource = gameObject.AddComponent<AudioSource>();
if (phoneCallAudio != null)
{
audioSource.clip = phoneCallAudio;
}
if (phoneCallAudio != null) _audioSource.clip = phoneCallAudio;
choiceUI.SetActive(false); // Hide UI initially
}
// Public method to be used in XR Grab Interactable's On Select Entered event
public void PickUpPhone()
{
if (!phonePickedUp)
{
phonePickedUp = true;
Debug.Log("Phone Picked Up! Showing UI.");
choiceUI.SetActive(true); // Show UI panel
// Ensure phone attaches properly
if (attachTransform != null)
{
transform.position = attachTransform.position;
transform.rotation = attachTransform.rotation;
}
}
}
private void Update()
{
if (phonePickedUp && !choiceMade)
{
if (Input.GetKeyDown(KeyCode.A))
{
AnswerCall();
}
else if (Input.GetKeyDown(KeyCode.B))
{
DeclineCall();
}
}
if (!_phonePickedUp || _choiceMade) return;
if (Input.GetKeyDown(KeyCode.A))
AnswerCall();
else if (Input.GetKeyDown(KeyCode.B)) DeclineCall();
}
// mark : this is whether the player chooses between seeking help/not seeking help
// maybe because they were scared or smtg?
// we can save this to ask them why they chose this and gather info on this bcos
// that time i pitched this to a teacher they were happy
// smtg along the lines of the MSF wanting to know how to improve and get people to reach out???
// Public method to be used in XR Grab interactable OnSelectEntered event
public void PickUpPhone()
{
if (_phonePickedUp) return;
_phonePickedUp = true;
Debug.Log("Phone Picked Up! Showing UI.");
choiceUI.SetActive(true); // Show the UI panel
// Ensure the phone attaches properly
if (attachTransform == null) return;
transform.position = attachTransform.position;
transform.rotation = attachTransform.rotation;
}
// for mark (backend): this is whether the player chooses between seeking help/not seeking help
// maybe because they were scared or something?
// we can save this to ask them why they chose this and gather info on this because
// that time I pitched this to a teacher they were happy
// something like the MSF wanting to know how to improve and get people to reach out???
private void AnswerCall()
{
choiceMade = true;
_choiceMade = true;
Debug.Log("Phone Answered! Loading GoodEnding...");
choiceUI.SetActive(false);
SceneManager.LoadScene("GoodEnding");
@ -79,10 +67,9 @@ public class PhoneInteraction : MonoBehaviour
private void DeclineCall()
{
choiceMade = true;
_choiceMade = true;
Debug.Log("Call Declined! Loading BadEnding...");
choiceUI.SetActive(false);
SceneManager.LoadScene("BadEnding");
}
}
}

View file

@ -1,11 +1,10 @@
/*
Author: Reza
Date: 7/2/25
Description: Has all the post processing camera effects that replicate real symptoms like dizziness, fainting, panic, etc
*/
* Author: Reza
* Date: 7/2/25
* Description: Post-processing camera effects emulating various conditions
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
@ -17,13 +16,6 @@ public class PostProcessingManager : MonoBehaviour
// Defines the Global Volume
public Volume volume;
// All the effect overrides
private Vignette vignette;
private ChromaticAberration chromaticAberration;
private MotionBlur motionBlur;
private LensDistortion lensDistortion;
private ColorAdjustments colorAdjustments;
[Header("Effect Intensities")]
// Editable override values in inspector
[SerializeField]
@ -37,56 +29,56 @@ public class PostProcessingManager : MonoBehaviour
[SerializeField] public AnimationCurve colorAdjustmentsIntensity;
// Checks if effect is active or not
private bool isEffectActive = false;
// Defines Audio References
[Header("Audio References")]
public AudioSource audioSource;
[Header("Audio References")] public AudioSource audioSource;
public AudioClip heartbeatSound;
public AudioClip whisperSound;
public AudioClip distortedWhisperSound;
private ChromaticAberration _chromaticAberration;
private ColorAdjustments _colorAdjustments;
// Holds the current effect name to manage stopping and starting dynamically
private string currentEffectName = "";
private string _currentEffectName = "";
void Awake()
// Checks if effect is active or not
private bool _isEffectActive;
private LensDistortion _lensDistortion;
private MotionBlur _motionBlur;
// All the effect overrides
private Vignette _vignette;
private void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(gameObject);
}
}
// Start is called before the first frame update
void Start()
private void Start()
{
// Get references for effects
volume.profile.TryGet(out vignette);
volume.profile.TryGet(out chromaticAberration);
volume.profile.TryGet(out motionBlur);
volume.profile.TryGet(out lensDistortion);
volume.profile.TryGet(out colorAdjustments);
volume.profile.TryGet(out _vignette);
volume.profile.TryGet(out _chromaticAberration);
volume.profile.TryGet(out _motionBlur);
volume.profile.TryGet(out _lensDistortion);
volume.profile.TryGet(out _colorAdjustments);
}
// Checks if an effect is currently active
public bool IsEffectActive()
{
return isEffectActive;
return _isEffectActive;
}
// Function to trigger effects dynamically based on the effect name passed
public void TriggerEffect(string effectName)
{
// If an effect is already active, stop the current one
if (isEffectActive)
{
StopEffect(currentEffectName);
}
if (_isEffectActive) StopEffect(_currentEffectName);
// Start the new effect
StartEffect(effectName);
@ -95,8 +87,8 @@ public class PostProcessingManager : MonoBehaviour
// Start a specific effect
public void StartEffect(string effectName)
{
isEffectActive = true;
currentEffectName = effectName;
_isEffectActive = true;
_currentEffectName = effectName;
StartCoroutine(ApplyEffect(effectName));
}
@ -104,96 +96,83 @@ public class PostProcessingManager : MonoBehaviour
// Stop the active effect
public void StopEffect()
{
if (isEffectActive)
{
StopEffect(currentEffectName);
}
if (_isEffectActive) StopEffect(_currentEffectName);
}
// Stop a specific effect
private void StopEffect(string effectName)
{
isEffectActive = false;
currentEffectName = "";
_isEffectActive = false;
_currentEffectName = "";
// Reset effects to default
if (vignette != null) vignette.intensity.Override(0f);
if (chromaticAberration != null) chromaticAberration.intensity.Override(0f);
if (motionBlur != null) motionBlur.intensity.Override(0f);
if (lensDistortion != null) lensDistortion.intensity.Override(0f);
if (colorAdjustments != null) colorAdjustments.postExposure.Override(0f);
if (_vignette) _vignette.intensity.Override(0f);
if (_chromaticAberration) _chromaticAberration.intensity.Override(0f);
if (_motionBlur) _motionBlur.intensity.Override(0f);
if (_lensDistortion) _lensDistortion.intensity.Override(0f);
if (_colorAdjustments) _colorAdjustments.postExposure.Override(0f);
// Stop the audio
if (audioSource != null)
{
audioSource.Stop();
}
if (audioSource) audioSource.Stop();
}
// Applies effects over time based on the effect name
private IEnumerator ApplyEffect(string effectName)
{
// Handle audio for the effect
if (effectName == "Panic")
switch (effectName)
{
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();
// Handle audio for the effect
case "Panic":
audioSource.clip = heartbeatSound;
audioSource.loop = true;
audioSource.Play();
break;
case "Headache":
audioSource.clip = whisperSound;
audioSource.loop = true;
audioSource.Play();
break;
case "Dizziness":
audioSource.clip = distortedWhisperSound;
audioSource.loop = true;
audioSource.Play();
break;
}
// Apply effects while the effect is active
while (isEffectActive)
while (_isEffectActive)
{
// Visual effects for headache
if (effectName == "Headache")
switch (effectName)
{
vignette.intensity.Override(vignetteIntensity.Evaluate(Time.time));
chromaticAberration.intensity.Override(chromaticAberrationIntensity.Evaluate(Time.time));
}
// 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));
}
if (effectName == "Worst")
{
vignette.intensity.Override(vignetteIntensity.Evaluate(Time.time));
motionBlur.intensity.Override(motionBlurIntensity.Evaluate(Time.time));
lensDistortion.intensity.Override(lensDistortionIntensity.Evaluate(Time.time));
chromaticAberration.intensity.Override(chromaticAberrationIntensity.Evaluate(Time.time));
colorAdjustments.postExposure.Override(colorAdjustmentsIntensity.Evaluate(Time.time * 0.8f));
// Visual effects for headache
case "Headache":
_vignette.intensity.Override(vignetteIntensity.Evaluate(Time.time));
_chromaticAberration.intensity.Override(chromaticAberrationIntensity.Evaluate(Time.time));
break;
// Visual effects for dizziness
case "Dizziness":
_motionBlur.intensity.Override(motionBlurIntensity.Evaluate(Time.time));
_lensDistortion.intensity.Override(lensDistortionIntensity.Evaluate(Time.time));
break;
// Visual effects for panic
case "Panic":
_motionBlur.intensity.Override(motionBlurIntensity.Evaluate(Time.time));
_lensDistortion.intensity.Override(lensDistortionIntensity.Evaluate(Time.time));
_chromaticAberration.intensity.Override(chromaticAberrationIntensity.Evaluate(Time.time));
break;
case "Worst":
_vignette.intensity.Override(vignetteIntensity.Evaluate(Time.time));
_motionBlur.intensity.Override(motionBlurIntensity.Evaluate(Time.time));
_lensDistortion.intensity.Override(lensDistortionIntensity.Evaluate(Time.time));
_chromaticAberration.intensity.Override(chromaticAberrationIntensity.Evaluate(Time.time));
_colorAdjustments.postExposure.Override(colorAdjustmentsIntensity.Evaluate(Time.time * 0.8f));
break;
}
yield return 0;
}
// Stop audio after the effect ends
if (audioSource != null && audioSource.isPlaying)
{
audioSource.Stop();
}
if (audioSource && audioSource.isPlaying) audioSource.Stop();
}
}
}

View file

@ -1,10 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
// NOTE: / FIXME: no asset usages, and school is not a tag; is this script dead?
public class SceneTransition : MonoBehaviour
{
public Image fadeImage; // Assign the black image here
@ -12,24 +12,21 @@ public class SceneTransition : MonoBehaviour
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("School"))
{
StartCoroutine(FadeOutAndLoadScene());
}
if (other.CompareTag("School")) StartCoroutine(FadeOutAndLoadScene());
}
private IEnumerator FadeOutAndLoadScene()
{
float elapsed = 0f;
var elapsed = 0f;
while (elapsed < fadeDuration)
{
elapsed += Time.deltaTime;
float alpha = Mathf.Clamp01(elapsed / fadeDuration);
var alpha = Mathf.Clamp01(elapsed / fadeDuration);
fadeImage.color = new Color(0, 0, 0, alpha);
yield return null;
}
SceneManager.LoadScene("NextScene");
}
}
}

View file

@ -1,68 +1,65 @@
/*
Author: Reza and Wailam
Date: 14/2/25
Description: For text to appear itself for storytelling
*/
* Author: Reza and Wai Lam
* Date: 14/2/25
* Description: For texts to appear themselves for storytelling
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
public class StoryTyping : MonoBehaviour
{
[Header("Message Settings")]
// Custom message for this trigger
[TextArea(3, 5)] public string[] storyLines;
[TextArea(3, 5)]
public string[] storyLines;
public TMP_Text storyText;
// Speed at which text appears
public float typingSpeed = 0.05f;
public float typingSpeed = 0.05f;
public string nextSceneName = "NextScene";
private int currentLine = 0;
public string nextSceneName = "NextScene";
public CanvasGroup fadeCanvasGroup; // Assign in Inspector
public float fadeDuration = 1f; // Duration for fade in/out
public float displayDuration = 5f;
public float fadeDuration = 1f; // Duration for fade in/out
public float displayDuration = 5f;
private int _currentLine;
private void Start()
{
// Start typing the first line if there are any lines
if (storyLines.Length > 0)
{
StartCoroutine(TypeText());
}
if (storyLines.Length > 0) StartCoroutine(TypeText());
}
IEnumerator TypeText()
private IEnumerator TypeText()
{
// Loop through each line of text
while (currentLine < storyLines.Length)
while (_currentLine < storyLines.Length)
{
string fullText = storyLines[currentLine];
string currentText = "";
var fullText = storyLines[_currentLine];
var currentText = "";
// Type out the current line character by character
for (int i = 0; i < fullText.Length; i++)
foreach (var t in fullText)
{
currentText += fullText[i];
currentText += t;
storyText.text = currentText;
yield return new WaitForSeconds(typingSpeed);
}
currentLine++; // Move to the next line
yield return new WaitForSeconds(displayDuration); // Wait briefly before displaying the next line
_currentLine++; // Move to the next line
yield return new WaitForSeconds(displayDuration); // Wait briefly before displaying the next line
}
// After all lines are typed, trigger fade and load the next scene
StartCoroutine(FadeToBlack());
}
IEnumerator FadeToBlack()
private IEnumerator FadeToBlack()
{
// Fade to black
yield return StartCoroutine(Fade(0f, 1f, fadeDuration));
@ -71,16 +68,16 @@ public class StoryTyping : MonoBehaviour
SceneManager.LoadScene(nextSceneName);
}
IEnumerator Fade(float startAlpha, float endAlpha, float duration)
private IEnumerator Fade(float startAlpha, float endAlpha, float duration)
{
float elapsed = 0f;
var elapsed = 0f;
fadeCanvasGroup.alpha = startAlpha;
// Fade over the specified duration
while (elapsed < duration)
{
elapsed += Time.deltaTime;
float t = elapsed / duration;
var t = elapsed / duration;
fadeCanvasGroup.alpha = Mathf.Lerp(startAlpha, endAlpha, t);
yield return null;

View file

@ -8,30 +8,29 @@ using UnityEngine;
public class TrashBinTracker : MonoBehaviour
{
private BedroomTask bedroomTask;
private BedroomTask _bedroomTask;
private void Start()
{
// Find the BedroomTask script in the scene
bedroomTask = FindObjectOfType<BedroomTask>();
_bedroomTask = FindObjectOfType<BedroomTask>();
if (bedroomTask == null) Debug.LogWarning("BedroomTask script not found in the scene!");
if (_bedroomTask == null) Debug.LogWarning("BedroomTask script not found in the scene!");
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("TrashBin"))
if (!other.CompareTag("TrashBin")) return;
if (_bedroomTask != null)
{
if (bedroomTask != null)
{
bedroomTask.CollectTrash();
Debug.Log("🗑️ Trash thrown in the bin! Count: " + bedroomTask.trashCollected);
Destroy(gameObject);
}
else
{
Debug.LogError("BedroomTask reference is missing!");
}
_bedroomTask.CollectTrash();
Debug.Log("🗑️ Trash thrown in the bin! Count: " + _bedroomTask.trashCollected);
Destroy(gameObject);
}
else
{
Debug.LogError("BedroomTask reference is missing!");
}
}
}

View file

@ -1,34 +1,33 @@
using System.Collections;
using System.Collections.Generic;
/*
* Author: Reza
* Date: 7/2/25
* Description: Vignette breathing effect
*/
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class VignetteBreathing : MonoBehaviour
{
[SerializeField]
public Volume postProcessingVolume;
private Vignette vignette;
[SerializeField] public Volume postProcessingVolume;
[SerializeField] public AnimationCurve intensityCurve; // Assign in Inspector
[SerializeField]
public AnimationCurve intensityCurve; // Assign in Inspector
public float cycleDuration = 3f; // Time for one full cycle
void Start()
private Vignette _vignette;
private void Start()
{
if (postProcessingVolume.profile.TryGet(out vignette))
{
Debug.Log("Vignette found!");
}
if (postProcessingVolume.profile.TryGet(out _vignette)) Debug.Log("Vignette found!");
}
void Update()
private void Update()
{
if (vignette != null)
{
float t = (Time.time % cycleDuration) / cycleDuration; // Loop 0-1 over time
vignette.intensity.Override(intensityCurve.Evaluate(t));
}
if (!_vignette) return;
var t = Time.time % cycleDuration / cycleDuration; // Loop 0-1 over time
_vignette.intensity.Override(intensityCurve.Evaluate(t));
}
}

View file

@ -35,6 +35,12 @@ EditorBuildSettings:
- enabled: 0
path: Assets/Scenes/Testing Scenes/Day Increment Playground After.unity
guid: 065e518bf23235d4298388363e3f16f8
- enabled: 1
path: Assets/Scenes/GoodEnding.unity
guid: de004170c210b114fa72b28853c704b7
- enabled: 1
path: Assets/Scenes/BadEnding.unity
guid: 0b49410f1606e7c4494b9bdd0df77c9f
m_configObjects:
Unity.XR.Oculus.Settings: {fileID: 11400000, guid: bfa1182bd221b4ca89619141f66f1260, type: 2}
Unity.XR.WindowsMR.Settings: {fileID: 11400000, guid: dc5a169419fa04987b057f65238cf3ba, type: 2}