Exemplo n.º 1
0
        /// <summary>
        /// 添加一个有参的定时器事件,runTimes = -1 时为无数次
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="delay"></param>
        /// <param name="runTimes"></param>
        /// <param name="interval"></param>
        /// <param name="callback"></param>
        public static void AddTimerEvent(string eventName, float delay, int runTimes, float interval, Callback <object[]> callback, params object[] parmas)
        {
            if (callback == null)
            {
                CDebug.LogError("Error CTimer.AddTimeEvent -> callback is null ");
            }

            if (callback == null)
            {
                CDebug.LogError("Error CTimer.AddTimeEvent -> callback is null ");
                return;
            }

            if (delay < 0)
            {
                CDebug.LogError("Error CTimer.AddTimeEvent -> delay can not less then 0 ");
                return;
            }

            if (interval < 0)
            {
                CDebug.LogError("Error CTimer.AddTimeEvent -> interval can not less then 0 ");
                return;
            }

            if (runTimes <= 0 && runTimes != -1)
            {
                CDebug.LogError("Error CTimer.AddTimeEvent -> runTimes can not less then 0 ");
                return;
            }

            TimerEvent timeEvent = new TimerEvent(eventName, delay, runTimes, interval, callback, parmas);

            //CDebug.Log("CTimer.AddTimeEvent eventName with parmas " + eventName);
            eventList.Add(timeEvent);
        }
Exemplo n.º 2
0
 public void AddToNWheel(TimerEvent te, int n)
 {
     _NWheel[n - 1][GetNthIndex(te.ExpireTime, n)].AddLast(te);
 }
Exemplo n.º 3
0
 public void AddFirst(TimerEvent te)
 {
     _firstWheel[te.ExpireTime & kFirstMask].AddLast(te);
 }