using System; using UnityEngine; using UnityEngine.Events; namespace _Game.Scripts.Scriptable_Object { public class ElementGameEventListener : MonoBehaviour { [SerializeField] private ElementGameEvent gameEvent; [SerializeField] private UnityEvent allResponse; [SerializeField] private UnityEvent airResponse; [SerializeField] private UnityEvent earthResponse; [SerializeField] private UnityEvent fireResponse; [SerializeField] private UnityEvent waterResponse; [SerializeField] private UnityEvent defaultResponse; private void OnEnable() { gameEvent.RegisterListener(this); } private void OnDisable() { gameEvent.UnregisterListener(this); } public void OnEventRaised(InfusedElement element) { allResponse.Invoke(); switch (element) { case InfusedElement.Air: airResponse.Invoke(); break; case InfusedElement.Earth: earthResponse.Invoke(); break; case InfusedElement.Fire: fireResponse.Invoke(); break; case InfusedElement.Water: waterResponse.Invoke(); break; case InfusedElement.None: defaultResponse.Invoke(); break; default: throw new ArgumentOutOfRangeException("element", element, null); } } } }