public Timer(TimerObserverOrSubject observer, OnCallBack callback, object arg, float time) { m_Observer = observer; m_Callback = callback; m_Arg = arg; m_Subject = null; m_IsCanDoFunc = null; m_ArgForIsCanDoFunc = null; m_PassTime = time; }
public Timer(TimerObserverOrSubject observer, OnCallBack callback, object arg, TimerObserverOrSubject subject, OnIsCanDo isCanDoFunc, object argForIsCanDo) { m_Observer = observer; m_Callback = callback; m_Arg = arg; m_Subject = subject; m_IsCanDoFunc = isCanDoFunc; m_ArgForIsCanDoFunc = argForIsCanDo; m_PassTime = 0; }
/// <summary> /// Sets the timer. /// </summary> /// <param name='observer'> /// The TimerObserverOrSubject you need to listen /// </param> /// <param name='callback'> /// The callback when condition is true. /// </param> /// <param name='arg'> /// Argument of the callback. /// </param> /// <param name='observer'> /// The TimerObserverOrSubject you need to observe /// </param> /// <param name='isCanDoFunc'> /// The condition function, must return a boolean. /// </param> /// <param name='argForIsCanDo'> /// Argument for condition function. /// </param> public void SetTimer(TimerObserverOrSubject observer, OnCallBack callback, object arg, TimerObserverOrSubject subject, OnIsCanDo isCanDoFunc, object argForIsCanDo) { if (observer == null || subject == null || callback == null || isCanDoFunc == null) { return; } if (isCanDoFunc(argForIsCanDo)) { callback(arg); return; } Timer timer = new Timer(observer, callback, arg, subject, isCanDoFunc, argForIsCanDo); m_Timers.Add(timer); }