public static void TriggerEvent(GameData.Event eventName, bool active, int secondValue) { UnityEventBoolInt thisEvent = null; if (Instance.eventDictionaryBoolInt.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(active, secondValue); } }
public static void StopListening(GameData.Event eventName, UnityAction <bool, int> listener) { if (EventManager.Instance == null) //au cas ou on a déja supprimé l'eventManager { return; } UnityEventBoolInt thisEvent = null; //si on veut unregister et que la clé existe dans le dico.. if (Instance.eventDictionaryBoolInt.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public static void StartListening(GameData.Event eventName, UnityAction <bool, int> listener) { if (!Instance) { return; } UnityEventBoolInt thisEvent = null; if (Instance.eventDictionaryBoolInt.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new UnityEventBoolInt(); thisEvent.AddListener(listener); Instance.eventDictionaryBoolInt.Add(eventName, thisEvent); } }