Beispiel #1
0
        /**
         * Invoke callback once and destroy timer
         */
        public static TimerControl CreateTimer(GameObject gameObj, Action callback, float duration, bool repeat)
        {
            TimerControl timer = gameObj.AddComponent <TimerControl>();
            TimerData    data  = new TimerData();

            data.duration = duration;
            data.repeat   = repeat;
            timer.Add(data);
            timer[0].AddCallback(callback);

            return(timer);
        }
Beispiel #2
0
 public void Add(TimerData data)
 {
     Array.Resize <TimerData>(ref timers, timers.Length + 1);
     timers[timers.Length - 1] = data;
     ResizeTimer();
 }
Beispiel #3
0
 public Timer(TimerData data)
 {
     this.data = data;
 }
Beispiel #4
0
 public Timer()
 {
     this.data = new TimerData();
 }
Beispiel #5
0
 public void SetTimerData(float dur, Action callback, bool loop = false)
 {
     this.data        = new TimerData(dur, callback);
     this.data.repeat = loop;
 }
Beispiel #6
0
 public void SetTimerData(TimerData data)
 {
     this.data = data;
 }