game(scripts): standardise EffectTrigger

This commit is contained in:
Mark Joshwel 2025-02-14 22:20:14 +08:00
parent fc9b9ac330
commit 6d3005d9d7

View file

@ -1,5 +1,9 @@
using System.Collections; /*
using System.Collections.Generic; * Author: Reza
* Date: 13/2/2025
* Description: Car obstacle
*/
using UnityEngine; using UnityEngine;
public class EffectTrigger : MonoBehaviour public class EffectTrigger : MonoBehaviour
@ -7,26 +11,21 @@ public class EffectTrigger : MonoBehaviour
// The effect name to trigger when the player enters this area // The effect name to trigger when the player enters this area
public string effectName; public string effectName;
// Check if the player enters the trigger zone
private void OnTriggerStay(Collider other)
{
// Check if the player is in the trigger zone
if (other.CompareTag("Player"))
{
// Trigger the effect based on the specified effectName
if (!PostProcessingManager.Instance.IsEffectActive())
{
PostProcessingManager.Instance.TriggerEffect(effectName);
}
}
}
// Optionally stop the effect when the player exits the trigger zone // Optionally stop the effect when the player exits the trigger zone
private void OnTriggerExit(Collider other) private void OnTriggerExit(Collider other)
{ {
if (other.CompareTag("Player") && PostProcessingManager.Instance.IsEffectActive()) if (other.CompareTag("Player") && PostProcessingManager.Instance.IsEffectActive())
{
PostProcessingManager.Instance.StopEffect(); PostProcessingManager.Instance.StopEffect();
} }
// Check if the player enters the trigger zone
private void OnTriggerStay(Collider other)
{
// Check if the player is in the trigger zone
if (!other.CompareTag("Player")) return;
// Trigger the effect based on the specified effectName
if (!PostProcessingManager.Instance.IsEffectActive())
PostProcessingManager.Instance.TriggerEffect(effectName);
} }
} }