public void Update() { this.m_iTempFrameCount++; while (this.m_queue.Count != 0) { TimerBase p = this.m_queue.Peek(); if (this.m_iTempFrameCount < p.NextDuration) { break; } this.m_queue.Dequeue(); if (p.Loop) { //表示循环 p.NextDuration = p.Duration + this.m_iTempFrameCount; this.m_queue.Enqueue(p.TimerId, p, p.NextDuration); p.Callback(); } else { p.Callback(); p.RecyleSelf(p); } } }
public void Update() { this.m_fRealTimeSinceStartUp += (uint)this.m_oStopWatch.ElapsedMilliseconds; this.m_oStopWatch.Reset(); this.m_oStopWatch.Start(); while (this.m_queue.Count != 0) { TimerBase p = this.m_queue.Peek(); if (this.m_fRealTimeSinceStartUp < p.NextDuration) { break; } this.m_queue.Dequeue(); if (p.Loop) { //表示循环 p.NextDuration = p.Duration + this.m_fRealTimeSinceStartUp; this.m_queue.Enqueue(p.TimerId, p, p.NextDuration); p.Callback(); } else { p.Callback(); p.RecyleSelf(p); } } }
private TimerBase InitTimer(TimerBase timer, uint delay, uint duration, bool loop = false) { timer.Loop = loop; timer.TimerId = TimerModule.TimeIdIndex++; timer.Duration = duration; timer.NextDuration = this.m_iTempFrameCount + duration + 1 + delay; this.m_queue.Enqueue(timer.TimerId, timer, timer.Duration); return(timer); }
public override void RecyleSelf(TimerBase data) { var d = data as TimerData; ClassPoolModule <TimerData> .Release(d); }
public abstract void RecyleSelf(TimerBase data);