Ejemplo n.º 1
0
 /// <summary>
 /// Start the timer and set the callback functions.
 /// </summary>
 /// <param name="callback">The callback function will be called when timer is stopped.</param>
 /// <seealso cref="StartTimer"/>
 /// <seealso cref="StopTimer"/>
 public void StartTimer(params TimeIsUpHandler[] callback)
 {
     StartTimer();
     foreach (TimeIsUpHandler listener in callback)
     {
         timeIsUpHandler += listener;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Start the timer without the callback functions.
        /// </summary>
        /// <seealso cref="StartTimer(TimeIsUpHandler[])"/>
        /// <seealso cref="StopTimer"/>
        public void StartTimer()
        {
            //if (StartCallBack != null) {

            //}
            currentTime     = 0.0f;
            isTimerStarted  = true;
            timeIsUpHandler = null;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Stop the count down timer and clear the callback functions.
 /// </summary>
 /// <seealso cref="StartCountDownTimer(float, bool, TimeIsUpHandler[])"/>
 public void StopCountDownTimer()
 {
     isTimerStarted = false;
     if (countDownTimer != null)
     {
         StopCoroutine(countDownTimer);
     }
     timeIsUpHandler = null;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Stop the timer, call and clear the callback functions.
 /// </summary>
 /// <seealso cref="StartTimer"/>
 /// <seealso cref="StartTimer(TimeIsUpHandler[])"/>
 public void StopTimer()
 {
     if (isTimerStarted)
     {
         isTimerStarted = false;
         if (timeIsUpHandler != null)
         {
             timeIsUpHandler();
             timeIsUpHandler = null;
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Start the count down timer and set the callback functions.
        /// </summary>
        /// <param name="time">The count down time.</param>
        /// <param name="isRepetitive">Whether the count down process is repetitive.</param>
        /// <param name="callback">The callback function will be called when time's up.</param>
        /// <seealso cref="StopCountDownTimer"/>
        public void StartCountDownTimer(float time, bool needeventcall, bool isRepetitive = false, params TimeIsUpHandler[] callback)
        {
            StopCountDownTimer();
            isTimerStarted        = true;
            isCountDownRepetitive = isRepetitive;
            foreach (TimeIsUpHandler listener in callback)
            {
                timeIsUpHandler += listener;
            }

            if (eventStartCallBack != null && needeventcall)
            {
                eventStartCallBack();
            }
            countDownTimer = CountDownTimer(time);
            StartCoroutine(countDownTimer);
        }