Esempio n. 1
0
 public TimerStateType Tick(float deltaTime)
 {
     if (state == TimerStateType.Normal)
     {
         if (times != 0)
         {
             _timer += deltaTime;
             if (_timer >= interval)
             {
                 _timer = 0.0f;
                 if (times > 0)
                 {
                     times--;
                 }
                 if (callback != null)
                 {
                     callback(this);
                 }
             }
         }
         else
         {
             state = TimerStateType.Stop;
         }
     }
     return(state);
 }
Esempio n. 2
0
        public Timer Regist(Action <Timer> callback, float interval, int times, TimerStateType state = TimerStateType.Normal)
        {
            Timer timer = new Timer(callback, interval, times, state);

            _timers.Add(timer);
            return(timer);
        }
Esempio n. 3
0
        private float _timer;           //计时

        public Timer(Action <Timer> callback, float interval, int times, TimerStateType state = TimerStateType.Normal)
        {
            this.callback = callback;
            this.interval = interval;
            this.times    = times;
            this.state    = state;

            this._timer = 0.0f;
        }
        private float _timer;//计时

        public Timer(Action<Timer> callback, float interval, int times, TimerStateType state = TimerStateType.Normal)
        {
            this.callback = callback;
            this.interval = interval;
            this.times = times;
            this.state = state;

            this._timer = 0.0f;
        }
 public TimerStateType Tick(float deltaTime)
 {
     if (state == TimerStateType.Normal)
     {
         if (times != 0)
         {
             _timer += deltaTime;
             if (_timer >= interval)
             {
                 _timer = 0.0f;
                 if (times > 0) times--;
                 if (callback != null) callback(this);
             }
         }else
         {
             state = TimerStateType.Stop;
         }
     }
     return state;
 }
 public Timer Regist(Action<Timer> callback, float interval, int times, TimerStateType state = TimerStateType.Normal)
 {
     Timer timer = new Timer(callback, interval, times, state);
     _timers.Add(timer);
     return timer;
 }