Space-Smash-Out/Assets/Scripts/PlayingFieldDetection.cs
Jakob Feldmann 6dc42a05cc feat: Apply an audio effect to every manageable audio on a gameobject
A new AudioManager Method triggers a signal which is received by every
ManageableAudio instance. If the causer of the signal is the same transform as the parent of the ManageableAudio, a change in AudioEffects is caused.
2024-04-13 15:56:20 +02:00

34 lines
906 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)
{
// TODO: This depends on a collider leaving the field which has only one
// instance with the same tag on the ship object.
if (collider.tag == "Ship")
{
if (!collider.TryGetComponent(out Ship shipComponent))
{
Log.Error($"Collider: {collider} was tagged as Ship, but has no Ship component.");
return;
}
MatchManager.G.UpdateMatchCondition(new MatchConditionUpdate
{
Condition = WinCondition.Lives,
Ship = shipComponent,
Count = -1
});
}
}
}