2024-08-10 13:20:53 +08:00
|
|
|
/*
|
|
|
|
* author: mark joshwel
|
|
|
|
* date: 10/8/2024
|
|
|
|
* description: trigger to detect if the player landed in a specific area
|
|
|
|
*/
|
|
|
|
|
2024-08-10 15:04:02 +08:00
|
|
|
using System;
|
2024-08-10 13:20:53 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// detection behaviour class
|
|
|
|
/// </summary>
|
|
|
|
public class AerialFaithLandingTrigger : MonoBehaviour
|
|
|
|
{
|
|
|
|
/// <summary>
|
2024-08-11 03:00:59 +08:00
|
|
|
/// the first trigger that detects if the player has jumped out of the play area
|
2024-08-10 13:20:53 +08:00
|
|
|
/// </summary>
|
2024-08-11 03:00:59 +08:00
|
|
|
[SerializeField] private AerialFaithLeapTrigger linkedLeapTrigger1;
|
2024-08-10 15:04:02 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2024-08-11 03:00:59 +08:00
|
|
|
/// the second trigger that detects if the player has jumped out of the play area
|
|
|
|
/// </summary>
|
|
|
|
[SerializeField] private AerialFaithLeapTrigger linkedLeapTrigger2;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// the third trigger that detects if the player has jumped out of the play area
|
|
|
|
/// </summary>
|
|
|
|
[SerializeField] private AerialFaithLeapTrigger linkedLeapTrigger3;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// check if linkedLeapTrigger1 is set
|
2024-08-10 15:04:02 +08:00
|
|
|
/// </summary>
|
|
|
|
/// <exception cref="NullReferenceException">consequential exception</exception>
|
|
|
|
private void Awake()
|
|
|
|
{
|
2024-08-11 03:00:59 +08:00
|
|
|
if (linkedLeapTrigger1 == null)
|
|
|
|
throw new NullReferenceException("AerialFaithLandingTrigger: linkedLeapTrigger1 is not set");
|
2024-08-10 15:04:02 +08:00
|
|
|
}
|
2024-08-10 13:20:53 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// detect if player has entered the trigger
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">colliding game object</param>
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
|
|
{
|
2024-08-10 15:04:02 +08:00
|
|
|
// Debug.Log($"AerialFaithLandingTrigger: was hit by object with tag {other.tag}");
|
2024-08-11 03:00:59 +08:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2024-08-10 13:20:53 +08:00
|
|
|
Debug.Log("AerialFaithLandingTrigger: player landed");
|
2024-08-11 03:00:59 +08:00
|
|
|
linkedLeapTrigger1.isPlayerInAir = false;
|
|
|
|
if (linkedLeapTrigger2 != null) linkedLeapTrigger2.isPlayerInAir = false;
|
|
|
|
if (linkedLeapTrigger3 != null) linkedLeapTrigger3.isPlayerInAir = false;
|
2024-08-10 13:20:53 +08:00
|
|
|
}
|
|
|
|
}
|