예제 #1
0
        public void FireEvent(int key, params object[] args)
        {
            // 先判断目前的事件队列中是否有这个事件,如果有的话,则刷新为最新。因为在同一帧中两次事件的没有作用
            Event2 e = null;

            for (int i = 0; i < mFiredEventList.Count; ++i)
            {
                if (mFiredEventList [i].GetKey() == key)
                {
                    e = mFiredEventList [i];
                    break;
                }
            }

            if (e == null)
            {
                e = mEventPool.Alloc();
                e.Set(key, args);
                mFiredEventList.Add(e);
            }
            else
            {
                e.Set(key, args);
            }
        }
예제 #2
0
 public void Fire(Event2 e)
 {
     if (mHandler != null && mHoster != null)
     {
         mHandler(e.GetKey(), mData, e.GetArgs());
         mFireCount++;
     }
     else
     {
         LoggerSystem.Instance.Error("EventLisener Error! hoster:" + this.mHoster + ", handler:" + this.mHandler);
     }
 }
예제 #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());
            }
        }