コード例 #1
0
        public void RegisterForEvent(eEvents p_eEvent, IEventHandler p_iObject)
        {
            switch (p_eEvent)
            {
            case eEvents.e_MouseButtonDown:
                m_lMouseButtonDownObjectsList.Add(p_iObject);
                break;

            case eEvents.e_MouseButtonUp:
                m_lMouseButtonUpObjectsList.Add(p_iObject);
                break;

            case eEvents.e_MouseMove:
                m_lMouseMoveObjectsList.Add(p_iObject);
                break;

            case eEvents.e_MouseWheel:
                m_lMouseWheelObjectsList.Add(p_iObject);
                break;

            case eEvents.e_KeyUp:
                m_lKeyUpObjectsList.Add(p_iObject);
                break;

            case eEvents.e_KeyDown:
                m_lKeyDownObjectsList.Add(p_iObject);
                break;

            default:
                throw new Exception("Unsupported event type");
            }
        }
コード例 #2
0
        public void DeRegisterEvent(eEvents @event, EventDelegate _delListener)
        {
            if (!_dicEventRegistry.ContainsKey(@event))
                return;

            _dicEventRegistry[@event] -= _delListener;
        }
コード例 #3
0
ファイル: EventSystem.cs プロジェクト: lvshiling/MyFramework
        public void RemoveEvent(eEvents type, GameEventHandler handler)
        {
            List <GameEventHandler> handlerList = m_event_dic.ContainsKey(type) ? m_event_dic[type] : null;

            if (handlerList != null && handlerList.Contains(handler))
            {
                handlerList.Remove(handler);
            }
        }
コード例 #4
0
        public void RegisterEvent(eEvents @event, EventDelegate delListener)
        {
            if (!_dicEventRegistry.ContainsKey(@event))
            {
                _dicEventRegistry.Add(@event, delListener);
                return;
            }

            _dicEventRegistry[@event] += delListener;
        }
コード例 #5
0
ファイル: EventSystem.cs プロジェクト: lvshiling/MyFramework
        public void OnEvent(eEvents type, params object[] args)
        {
            List <GameEventHandler> handlerList = m_event_dic.ContainsKey(type) ? m_event_dic[type] : null;

            if (handlerList != null)
            {
                for (short i = 0; i < handlerList.Count; i++)
                {
                    handlerList[i](args);
                }
            }
        }
コード例 #6
0
ファイル: EventSystem.cs プロジェクト: lvshiling/MyFramework
        public void AddEvent(eEvents type, GameEventHandler handler)
        {
            List <GameEventHandler> handlerList = m_event_dic.ContainsKey(type) ? m_event_dic[type] : null;

            if (handlerList == null)
            {
                m_event_dic[type] = new List <GameEventHandler>();
            }
            if (m_event_dic[type].Contains(handler))
            {
                return;
            }

            m_event_dic[type].Add(handler);
        }
コード例 #7
0
        public void TriggerEvent(eEvents @event, params object[] args)
        {
            string strEventKey = @event.ToString();
            EventDelegate d;

            if (!_dicEventRegistry.TryGetValue(@event, out d)) return;
            if (d != null)
                d(args);
            else
                Debug.LogError("Could not trigger event: " + strEventKey);
        }
コード例 #8
0
 public void RegisterForEvent(eEvents p_eEvent, IEventHandler p_iObject)
 {
     switch (p_eEvent)
     {
         case eEvents.e_MouseButtonDown:
             m_lMouseButtonDownObjectsList.Add(p_iObject);
             break;
         case eEvents.e_MouseButtonUp:
             m_lMouseButtonUpObjectsList.Add(p_iObject);
             break;
         case eEvents.e_MouseMove:
             m_lMouseMoveObjectsList.Add(p_iObject);
             break;
         case eEvents.e_MouseWheel:
             m_lMouseWheelObjectsList.Add(p_iObject);
             break;
         case eEvents.e_KeyUp:
             m_lKeyUpObjectsList.Add(p_iObject);
             break;
         case eEvents.e_KeyDown:
             m_lKeyDownObjectsList.Add(p_iObject);
             break;
         default:
             throw new Exception("Unsupported event type");
     }
 }
コード例 #9
0
 public static void RemoveEvent(eEvents _event, GameEventHandler _handler)
 {
     EventSystem.Instance.RemoveEvent(_event, _handler);
 }