private int StartTimer(TimerTickDelegate tickFunc, float interval, float delayTime, int triggerTimes, float duration, OnBeginTimerDelegate beginFunc, OnEndTimerDelegate endFunc) { ++timerIndex; Timer timer = new Timer(); timer.id = timerIndex; timer.interval = interval; timer.triggerTimes = triggerTimes; timer.delayTime = delayTime; // duration 0 表示一直触发 timer.duration = duration; timer.OnBeginCallBack = beginFunc; timer.OnEndCallBack = endFunc; timer.OnTick = tickFunc; timer.Init(); timerList.Add(timer); return(timerIndex); }
// triggerTimes 和 duration 不能同时大于0 // 如果同时,那么哪个先到,哪个起作用 public int RepeatCallFunc(TimerTickDelegate tickFunc, float interval, float duration = 0, OnBeginTimerDelegate beginFunc = null, OnEndTimerDelegate endFunc = null) { return(StartTimer(tickFunc, interval, 0.0f, 0, duration, beginFunc, endFunc)); }