Esempio n. 1
0
 void ResetTimer()
 {
     m_timeUpHandler    = null;
     m_timeUpArgHandler = null;
     m_loop             = 1;
     m_totalTime        = 0;
     m_currentTime      = 0;
     m_isFinished       = false;
     m_isRunning        = false;
     m_sequence         = 0;
 }
Esempio n. 2
0
        //--------------------------------------
        /// 构造函数
        //--------------------------------------
        public Timer(int time, int loop, OnTimeUpHandler timeUpHandler, int sequence)
        {
            m_totalTime     = time;
            m_loop          = loop;
            m_timeUpHandler = timeUpHandler;
            m_sequence      = sequence;

            m_currentTime = 0;
            m_isRunning   = true;
            m_isFinished  = false;
        }
Esempio n. 3
0
 public void RemoveTimer(OnTimeUpHandler callBack, enTimerType enTimeType)
 {
     foreach (Timer timer in timers[enTimeType])
     {
         if (timer.IsCallBackMatch(callBack))
         {
             ReferencePool.Release(timer);
             timers[enTimeType].Remove(timer);
             return;
         }
     }
 }
Esempio n. 4
0
        public void RemoveTimer(OnTimeUpHandler ontime, enTimeType enTimeType)
        {
            List <Timer> list = m_timers[enTimeType == enTimeType.NoTimeScale ? 0 : 1];

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].IsDelegateMatch(ontime))
                {
                    list[i].Finish();
                    return;
                }
            }
        }
Esempio n. 5
0
 public CTimer(int time, int loop, OnTimeUpHandler timeUpHandler, int sequence)
 {
     if (loop == 0)
     {
         loop = -1;
     }
     this.m_totalTime     = time;
     this.m_loop          = loop;
     this.m_timeUpHandler = timeUpHandler;
     this.m_sequence      = sequence;
     this.m_currentTime   = 0;
     this.m_isRunning     = true;
     this.m_isFinished    = false;
 }
Esempio n. 6
0
    //----------------------------------------------
    /// 移除Timer
    /// @onTimeUpHandler
    /// @useFrameSync
    //----------------------------------------------
    public void RemoveTimer(OnTimeUpHandler onTimeUpHandler, bool useFrameSync)
    {
        List <Timer> timers = m_timers[(int)(useFrameSync ? enTimerType.FrameSync : enTimerType.Normal)];

        for (int i = 0; i < timers.Count;)
        {
            if (timers[i].IsDelegateMatched(onTimeUpHandler))
            {
                timers.RemoveAt(i);
                continue;
            }

            i++;
        }
    }
Esempio n. 7
0
    //--------------------------------------
    /// 构造函数
    //--------------------------------------
    public void ResetWith(int time, int loop, OnTimeUpHandler timeUpHandler, int sequence)
    {
        if (loop == 0)
        {
            loop = -1;
        }

        m_currentTime   = 0;
        m_totalTime     = time;
        m_loop          = loop;
        m_timeUpHandler = timeUpHandler;
        m_sequence      = sequence;

        m_currentTime = 0;
        m_isRunning   = true;
        m_isFinished  = false;
    }
Esempio n. 8
0
 public int AddTimer(int time, int loop, enTimeType enTimeType, OnTimeUpHandler onTimeUpHandler)
 {
     m_timerSquence++;
     m_timers[enTimeType == enTimeType.NoTimeScale ? 0 : 1].Add(new Timer(m_timerSquence, time, loop, onTimeUpHandler));
     return(m_timerSquence);
 }
Esempio n. 9
0
 public int AddTimer(int totalTime, int loopTimes, enTimerType timerType, OnTimeUpHandler callBcak, params object[] parms)
 {
     SerialID++;
     timers[timerType].Add(ReferencePool.Acquire <Timer>().Init(SerialID, totalTime, loopTimes, timerType, callBcak, parms));
     return(SerialID);
 }
Esempio n. 10
0
 public bool IsDelegateMatched(OnTimeUpHandler timeUpHandler)
 {
     return(this.m_timeUpHandler == timeUpHandler);
 }
Esempio n. 11
0
 public uint SetLoopTimer(float time, OnTimeUpHandler onTimeUpHandler, object param)
 {
     return(SetTimer((int)(time * 1000), -1, onTimeUpHandler, param));
 }
Esempio n. 12
0
 private uint SetTimer(int time, OnTimeUpHandler onTimeUpHandler, object param)
 {
     return(SetTimer(time, 1, onTimeUpHandler, param));
 }
Esempio n. 13
0
 private uint SetTimer(int time, OnTimeUpHandler onTimeUpHandler)
 {
     return(SetTimer(time, onTimeUpHandler, null));
 }
Esempio n. 14
0
 public uint SetTimer(float time, OnTimeUpHandler onTimeUpHandler)
 {
     return(SetTimer((int)(time * 1000), onTimeUpHandler));
 }
Esempio n. 15
0
 //----------------------------------------------
 /// 添加Timer
 /// @time               : 计时时间(ms)
 /// @loop               : 循环次数
 /// @onTimeUpHandler    : 时间到时的回调函数
 /// @return sequence of timer
 //----------------------------------------------
 private uint SetTimer(int time, int loop, OnTimeUpHandler onTimeUpHandler, object param)
 {
     return(SetTimer(time, loop, onTimeUpHandler, param, false));
 }
Esempio n. 16
0
 //----------------------------------------------
 /// 移除Timer
 /// @onTimeUpHandler
 //----------------------------------------------
 public void RemoveTimer(OnTimeUpHandler onTimeUpHandler)
 {
     RemoveTimer(onTimeUpHandler, false);
 }
Esempio n. 17
0
 //----------------------------------------------
 /// 添加Timer
 /// @time               : 计时时间(ms)
 /// @loop               : 循环次数
 /// @onTimeUpHandler    : 时间到时的回调函数
 /// @useFrameSync       : 是否使用桢同步
 /// @return sequence of timer
 //----------------------------------------------
 private uint SetTimer(int time, int loop, OnTimeUpHandler onTimeUpHandler, object param, bool useFrameSync)
 {
     m_timerSequence++;
     m_timers[(int)(useFrameSync ? enTimerType.FrameSync : enTimerType.Normal)].Add(new Timer(time, loop, onTimeUpHandler, m_timerSequence, param));
     return(m_timerSequence);
 }