Exemplo n.º 1
0
            /// <summary>
            /// 添加回调
            /// </summary>
            /// <param name="handle"></param>
            /// <returns></returns>
            public bool AddHandle(HandleObjectAction handle)
            {
                if (handle == null)
                {
                    return(false);
                }
                if (m_Handle == null)
                {
                    m_Handle += handle;
                    return(true);
                }
                Delegate[] delArray = m_Handle.GetInvocationList();
                if (delArray == null || delArray.Length == 0)
                {
                    m_Handle += handle;
                    return(true);
                }
                Int32 nSize = delArray.Length;

                for (Int32 i = 0; i < nSize; ++i)
                {
                    if (delArray[i] == (Delegate)handle)
                    {
                        return(true);
                    }
                }
                m_Handle += handle;
                return(true);
            }
Exemplo n.º 2
0
            /// <summary>
            /// Constructor
            /// </summary>
            public CHandleInfo()
            {
                m_Handle  = null;
                m_ArgType = null;
#if BTDEBUG
                m_cpuProfiler = new CCpuProfiler();
#endif
            }
Exemplo n.º 3
0
            /// <summary>
            /// 注册
            /// </summary>
            /// <param name="fTrigger"></param>
            /// <param name="handleAction"></param>
            /// <param name="objTrigger"></param>
            public void Register(UInt32 uId, float fCountDownTime, HandleObjectAction handleOnTimeUp, System.Object objTimeUpParam, TUnityTimeType tTimeType, float fStartDelay)
            {
                float fTimeNow = CTimeAlgorithm.GetGameTimeNow(tTimeType);

                m_uTimerId            = uId;
                m_fLifeTimeRemain     = fCountDownTime;
                m_handleTriggerAction = handleOnTimeUp;
                m_objTriggerParam     = objTimeUpParam;
                m_fStartTime          = fTimeNow + fStartDelay;
            }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="nCacheSetSize"></param>
 /// <param name="handleReleaseCache"></param>
 public CObjectCache(Int32 nCacheSetSize, HandleObjectAction handleReleaseCache = null)
 {
     if (nCacheSetSize <= 0)
     {
         BTDebug.Exception("Object Cache Exception", "BT");
         return;
     }
     m_nCacheSetSize      = nCacheSetSize;
     m_Cache              = new QuickList <string, CCacheSet>();
     m_HandleReleaseCache = handleReleaseCache;
 }
Exemplo n.º 5
0
 /// <summary>
 /// 清理
 /// </summary>
 public void Clear()
 {
     m_uTimerId             = 0;
     m_fStartTime           = 0;
     m_fLifeTimeRemain      = 0;
     m_fKeepDecimal         = 0;
     m_fIntervalTime        = 0;
     m_handleTriggerAction  = null;
     m_handleIntervalAction = null;
     m_objTriggerParam      = null;
     m_objIntervalParam     = null;
     m_fLastUpdateTime      = 0;
     m_TimeType             = TUnityTimeType.enGameTime;
 }
Exemplo n.º 6
0
        /// <summary>
        /// 为事件移除一个回调
        /// </summary>
        /// <param name="uEventId"></param>
        /// <param name="handle"></param>
        /// <returns></returns>
        public bool RemoveHandle(UInt32 uEventId, HandleObjectAction handle)
        {
            CHandleInfo handleInfo = null;

            if (m_EventActionList.QuickFind(uEventId, ref handleInfo) == false || handleInfo == null)
            {
                return(false);
            }
            if (handleInfo.RemoveHandle(handle) == false)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 注册倒计时,带间隔时间触发
        /// </summary>
        /// <param name="fCountDownTime"></param>
        /// <param name="handleOnTimeUp"></param>
        /// <param name="fInterval"></param>
        /// <param name="handleOnIntervalTrigger"></param>
        /// <param name="objTimeUpParam"></param>
        /// <param name="objInvtervalTriggerParam"></param>
        /// <param name="tTimeType"></param>
        /// <param name="fStartDelay"></param>
        /// <returns></returns>
        public UInt32 RegisterCountDownTimer(float fCountDownTime, HandleObjectAction handleOnTimeUp, float fInterval, HandleObjectAction handleOnIntervalTrigger, System.Object objTimeUpParam = null, System.Object objInvtervalTriggerParam = null, TUnityTimeType tTimeType = TUnityTimeType.enGameTime, float fStartDelay = 0)
        {
            CTimer timer = m_TimerPool.RentObject() as CTimer;

            if (timer == null)
            {
                return(0);
            }
            UInt32 uId = m_uNextTimerID;

            m_uNextTimerID += 1;
            timer.Register(uId, fCountDownTime, handleOnTimeUp, fInterval, handleOnIntervalTrigger, objTimeUpParam, objInvtervalTriggerParam, tTimeType, fStartDelay);
            m_TimerList.Add(timer);
            return(uId);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 取消重定向输出
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="tDebugType"></param>
        /// <returns></returns>
        public static bool UnRegisterHandle(HandleObjectAction handle, TDebugLevel tDebugType)
        {
            if (handle == null)
            {
                return(false);
            }
            switch (tDebugType)
            {
            case TDebugLevel.enLog:
            {
                m_handleLog -= handle;
            }
            break;

            case TDebugLevel.enWarning:
            {
                m_handleWarning -= handle;
            }
            break;

            case TDebugLevel.enError:
            {
                m_handleError -= handle;
            }
            break;

            case TDebugLevel.enException:
            {
                m_handleException -= handle;
            }
            break;

            default:
            {
                return(false);
            }
            }
            return(true);
        }
Exemplo n.º 9
0
            /// <summary>
            /// 触发回调
            /// </summary>
            /// <param name="objParam"></param>
            /// <returns></returns>
            public bool TriggerHandle(System.Object objParam)
            {
                if (CheckEventParamType(objParam) == false)
                {
                    BTDebug.Warning("Trigger Event With An Param Not Fit", "ACTION");
                    return(false);
                }

#if BTDEBUG
                m_cpuProfiler.StartNewCall();
#endif
                if (m_Handle == null)
                {
                    return(true);
                }
                Delegate[] delArray = m_Handle.GetInvocationList();
                Int32      nSize    = delArray == null ? 0 : delArray.Length;
                for (Int32 i = 0; i < nSize; ++i)
                {
                    try
                    {
                        HandleObjectAction handle = (HandleObjectAction)delArray[i];
                        if (handle == null)
                        {
                            continue;
                        }
                        handle(objParam);
                    }
                    catch (System.Exception ex)
                    {
                        BTDebug.ExceptionEx(ex);
                    }
                }
#if BTDEBUG
                m_cpuProfiler.EndCall();
#endif
                return(true);
            }