Space-Smash-Out/Assets/Scripts/PlayingFieldDetection.cs
2024-04-03 16:48:59 +02:00

32 lines
761 B
C#

using System.Reflection;
using log4net;
using Managers;
using UnityEngine;
public class PlayingFieldDetection : MonoBehaviour
{
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Updates the match conditions, when a ship leaves the playing field.
/// </summary>
/// <param name="collider"></param>
private void OnTriggerExit(Collider collider)
{
if (collider.tag == "Ship")
{
if (!collider.TryGetComponent(out Ship ship))
{
Log.Error($"Collider: {collider} was tagged as Ship, but has no Ship component.");
return;
}
MatchManager.G.UpdateMatchCondition(new MatchConditionUpdate
{
Condition = WinCondition.Lives,
ship = ship,
count = -1
});
}
}
}