/// <summary> /// Process each game event /// </summary> /// <param name="aEvent"></param> private void ProcessGameEvent(ref GameEventData aEvent) { //Check the event type and iterate through the collection and invoke the ReceiveEvent method. switch(aEvent.eventType) { case GameEventType.GAME: { IEnumerator<IGameEventReceiver> receivers = m_GameEventListener.GetEnumerator(); while(receivers.MoveNext()) { if(receivers.Current == null) { continue; } receivers.Current.ReceiveEvent(ref aEvent); } } break; case GameEventType.UNIT: { IEnumerator<IGameEventReceiver> receivers = m_UnitEventListener.GetEnumerator(); while(receivers.MoveNext()) { if(receivers.Current == null) { continue ; } receivers.Current.ReceiveEvent(ref aEvent); } } break; case GameEventType.TRIGGER: { IEnumerator<IGameEventReceiver> receivers = m_TriggerEventListener.GetEnumerator(); while(receivers.MoveNext()) { if(receivers.Current == null) { continue; } receivers.Current.ReceiveEvent(ref aEvent); } } break; } }
public static void InvokeEvent(GameEventData aEvent) { instance.m_EventQueue.Enqueue(aEvent); }
/// <summary> /// Game event manager invokes this event to send event data. /// Override this method to intercept the call and ignore filtering. /// </summary> /// <param name="aData"></param> public void ReceiveEvent(ref GameEventData aData) { eventData = aData; FilterEvent(aData.eventType); eventData = GameEventData.empty; }