Esempio n. 1
0
        /// <summary>
        /// 注册事件
        /// </summary>
        /// <param name="notifyID"></param>
        /// <param name="action"></param>
        /// <param name="inQuene"></param>
        public static void Regist(string notifyID, Action action, bool inQuene)
        {
            LTEventHandler handle = new LTEventHandler()
            {
                isInQueue       = inQuene,
                zeroParamAction = action
            };

            _HandleRegist(notifyID, handle);
        }
Esempio n. 2
0
 private static void _DoAction(LTEventHandler handle, float _float)
 {
     if (handle.isInQueue && ENABLE_THREAD)
     {
         LTTimeManager.instance.AddTimer(0, () =>
         {
             handle.Invoke(null, 0, _float, null);
         });
     }
     else
     {
         handle.Invoke(null, 0, _float, null);
     }
 }
Esempio n. 3
0
 private static void _DoAction(LTEventHandler handle, string _string)
 {
     if (handle.isInQueue && ENABLE_THREAD)
     {
         LTTimeManager.instance.AddTimer(0, () =>
         {
             handle.Invoke(_string, 0, 0, _string);
         });
     }
     else
     {
         handle.Invoke(_string, 0, 0, _string);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 取消注册事件
        /// </summary>
        /// <param name="notifyID"></param>
        /// <param name="action"></param>
        /// <param name="inQuene"></param>
        public static void UnRegist(string notifyID, Action <object> action, bool inQuene)
        {
            LTEventHandler handle = new LTEventHandler()
            {
                isInQueue      = inQuene,
                objParamAction = action
            };
            List <LTEventHandler> findList = null;

            if (_eventMap.TryGetValue(notifyID, out findList))
            {
                if (findList.Contains(handle))
                {
                    findList.Remove(handle);
                }
                if (findList.Count == 0)
                {
                    _eventMap.Remove(notifyID);
                }
            }
        }
Esempio n. 5
0
        private static void _HandleRegist(string notifyID, LTEventHandler handle)
        {
            List <LTEventHandler> findList = null;

            if (_eventMap.TryGetValue(notifyID, out findList))
            {
                if (findList.Contains(handle))
                {
                    LTDebug.LogWarning("{0}已存在同样事件注册{1},本次注册取消", notifyID, handle);
                }
                else
                {
                    findList.Add(handle);
                }
            }
            else
            {
                findList = new List <LTEventHandler>();
                findList.Add(handle);
                _eventMap.Add(notifyID, findList);
            }
        }