예제 #1
0
        public void UnRegisterEvent(int key, object hoster)
        {
            List <EventHandler2> total = null;

            if (this.mEventHandlerMap.TryGetValue(key, out total))
            {
                List <EventHandler2> temp = new List <EventHandler2>();
                temp.AddRange(total);
                for (int i = 0; i < temp.Count; ++i)
                {
                    EventHandler2 handler = temp [i];
                    if (handler != null && handler.IsEvent(key, hoster))
                    {
                        total.Remove(handler);
                    }
                }
            }
        }
예제 #2
0
        public void RegisterEvent(int key, object hoster, object data, Callback <int, object, object[]> handler)
        {
            EventHandler2 e = new EventHandler2();

            e.Init(key, hoster, data, handler);

            List <EventHandler2> total = null;

            if (this.mEventHandlerMap.ContainsKey(key))
            {
                total = this.mEventHandlerMap[key];
            }
            else
            {
                total = new List <EventHandler2>();
                this.mEventHandlerMap.Add(key, total);
            }

            total.Add(e);
        }
예제 #3
0
        private void TrigEvent(Event2 e)
        {
            List <EventHandler2> total = null;

            if (this.mEventHandlerMap.TryGetValue(e.GetKey(), out total))
            {
                EventHandler2 eh = null;
                for (int i = 0; i < total.Count; ++i)
                {
                    eh = total[i];
                    if (eh != null)
                    {
                        eh.Fire(e);
                        mEventPool.Recycle(e);
                    }
                }
            }
            else
            {
                LoggerSystem.Instance.Error("No register of this event. key:" + e.GetKey());
            }
        }