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; }
//-------------------------------------- /// 构造函数 //-------------------------------------- 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; }
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; } } }
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; } } }
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; }
//---------------------------------------------- /// 移除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++; } }
//-------------------------------------- /// 构造函数 //-------------------------------------- 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; }
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); }
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); }
public bool IsDelegateMatched(OnTimeUpHandler timeUpHandler) { return(this.m_timeUpHandler == timeUpHandler); }
public uint SetLoopTimer(float time, OnTimeUpHandler onTimeUpHandler, object param) { return(SetTimer((int)(time * 1000), -1, onTimeUpHandler, param)); }
private uint SetTimer(int time, OnTimeUpHandler onTimeUpHandler, object param) { return(SetTimer(time, 1, onTimeUpHandler, param)); }
private uint SetTimer(int time, OnTimeUpHandler onTimeUpHandler) { return(SetTimer(time, onTimeUpHandler, null)); }
public uint SetTimer(float time, OnTimeUpHandler onTimeUpHandler) { return(SetTimer((int)(time * 1000), onTimeUpHandler)); }
//---------------------------------------------- /// 添加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)); }
//---------------------------------------------- /// 移除Timer /// @onTimeUpHandler //---------------------------------------------- public void RemoveTimer(OnTimeUpHandler onTimeUpHandler) { RemoveTimer(onTimeUpHandler, false); }
//---------------------------------------------- /// 添加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); }