/* * author: mark joshwel * date: 10/8/2024 * description: trigger to detect if the player did not land in an aerial faith landing trigger */ using System; using UnityEngine; /// /// detection behaviour class /// public class AerialFaithDeathTrigger : MonoBehaviour { /// /// the first trigger that detects if the player has jumped out of the play area /// [SerializeField] private AerialFaithLeapTrigger linkedLeapTrigger1; /// /// the second trigger that detects if the player has jumped out of the play area /// [SerializeField] private AerialFaithLeapTrigger linkedLeapTrigger2; /// /// the third trigger that detects if the player has jumped out of the play area /// [SerializeField] private AerialFaithLeapTrigger linkedLeapTrigger3; /// /// check if linkedLeapTrigger1 is set /// /// consequential exception private void Awake() { if (linkedLeapTrigger1 == null) throw new NullReferenceException("AerialFaithLandingTrigger: linkedLeapTrigger1 is not set"); } /// /// detect if player has entered the trigger /// /// colliding game object private void OnTriggerEnter(Collider other) { // Debug.Log($"AerialFaithDeathTrigger: was hit by object with tag {other.tag}"); // proceed if: // - the colliding object is the player // - any of the linked leap triggers are active, the 1st is always not null if (!other.CompareTag("Player")) return; if (!(linkedLeapTrigger1.isPlayerInAir || (linkedLeapTrigger2 != null && linkedLeapTrigger2.isPlayerInAir) || (linkedLeapTrigger3 != null && linkedLeapTrigger3.isPlayerInAir))) return; Debug.Log("AerialFaithDeathTrigger: player missed, and will be baked"); linkedLeapTrigger1.isPlayerInAir = false; if (linkedLeapTrigger2 != null) linkedLeapTrigger2.isPlayerInAir = false; if (linkedLeapTrigger3 != null) linkedLeapTrigger3.isPlayerInAir = false; GameManager.Instance.SetDisplayState(GameManager.DisplayState.OverlayFailedOverTimeMenu); } }