public static void DeleteTimeListener(TimerListerType type) { TimeListener timeLlister = m_listTimeListener.Find(delegate(TimeListener timer) { return(timer.m_timerType == type); }); m_listTimeListener.Remove(timeLlister); sortTimeListener(); }
public static TimeListener AddTimeListener(System.Action callBackHandler, DateTime dateTime, TimerListerType type = TimerListerType.NULL) { TimeListener timeListener = new TimeListener(callBackHandler, dateTime, type); m_listTimeListener.Add(adjustEquilTime(timeListener)); sortTimeListener(); return(timeListener); }
public static TimeListener AddTimeListener(System.Action callBackHandler, float fTriggerTime, TimerListerType type = TimerListerType.NULL) { DateTime m_triggerTime = CurrentDateTime().AddSeconds(fTriggerTime); TimeListener timeListener = new TimeListener(callBackHandler, m_triggerTime, type); m_listTimeListener.Add(adjustEquilTime(timeListener)); sortTimeListener(); return(timeListener); }
/* 相同时间的 根据添加顺序调用 **/ private static TimeListener adjustEquilTime(TimeListener dateTime) { for (int i = 0, count = m_listTimeListener.Count; i < count; i++) { TimeListener listener = m_listTimeListener[i]; if (dateTime.m_triggerTime == listener.m_triggerTime) { dateTime.sort = listener.sort + 1; return(dateTime); } } return(dateTime); }
public static void Update() { //事件监听的时时检测 for (int i = m_listTimeListener.Count - 1; i >= 0; i--) { TimeListener timeListener = m_listTimeListener[i]; if (timeListener == null) { continue; } if (CurrentDateTime() >= timeListener.m_triggerTime) { if (timeListener.m_handler != null) { m_listTimeListener.RemoveAt(i); timeListener.m_handler(); } } } }
public static bool Contain(TimeListener listener) { return(m_listTimeListener.Contains(listener)); }
/** 移除定时器 */ public static void RemoveListener(TimeListener target) { m_listTimeListener.Remove(target); }