Example #1
0
        public static int SetInterval(int frameInterval, BKAction action)
        {
            if (action == null)
            {
                return(0);
            }

            if (frameInterval <= 0)
            {
                action.Invoke();
                frameInterval = 1;
            }

            while (intervals.ContainsKey(intervalId))
            {
                intervalId++;
                if (intervalId == int.MaxValue)
                {
                    intervalId = 1;
                }
            }

            intervals.Add(intervalId, new TickItem(frameInterval, action));
            return(intervalId);
        }
Example #2
0
 private void DoComplete(bool hasError = false)
 {
     this.hasError = hasError;
     isComplete    = true;
     if (onComplete != null)
     {
         onComplete.Invoke();
     }
 }
Example #3
0
 public void Update()
 {
     if (time > 0f)
     {
         if (Time.time - last >= time)
         {
             action.Invoke();
             last = Time.time;
         }
     }
     else
     {
         if (last >= frame)
         {
             action.Invoke();
             last = 0f;
         }
         else
         {
             last++;
         }
     }
 }