using System;
using UnityEngine;
using UnityEngine.Events;
///
/// Used on vulnerable trigger zones for ships.
///
public class TackleDetection : MonoBehaviour
{
[SerializeField] private TackleKind tackleKind;
public Action TackledResponse;
public Action TacklingResponse;
///
/// Invokes the fitting tackle response on trigger entered.
///
///
void OnTriggerEnter(Collider collider)
{
if (!(collider.tag == "Spike" ||
collider.tag == "Bumper" ||
collider.tag == "Vulnerable"))
{
return;
}
switch (collider.tag)
{
case "Spike":
// Critical for weak spots
TackledResponse.Invoke(tackleKind, collider);
break;
case "Bumper":
// Always normal tackle
TackledResponse.Invoke(TackleKind.IncomingNormal, collider);
break;
case "Vulnerable":
if (tackleKind == TackleKind.OutgoingCritical ||
tackleKind == TackleKind.OutgoingNormal)
TacklingResponse.Invoke();
break;
}
}
}
public enum TackleKind { IncomingCritical, IncomingNormal, OutgoingCritical, OutgoingNormal }