Exemple #1
0
 public void Remove()
 {
     TimerDaemon.timerDaemon.timers.Remove(this);
     this.callback  = null;
     this.coRoutine = null;
     this.publisher = null;
 }
Exemple #2
0
    private static Timer Add(float delay, Callback callback, CoRoutineCallback coRoutine, Publisher publisher, bool repeatable, bool autodestruct)
    {
        Timer timer = new Timer(delay, callback, coRoutine, publisher, repeatable, autodestruct);

        TimerDaemon.timerDaemon.timers.Add(timer);
        return(timer);
    }
Exemple #3
0
 public Timer(float delay, Callback callback, CoRoutineCallback coRoutine, Publisher publisher, bool repeatable, bool autodestruct)
 {
     this.delay        = delay;
     this.callback     = callback;
     this.coRoutine    = coRoutine;
     this.publisher    = publisher;
     this.repeatable   = repeatable;
     this.autodestruct = autodestruct;
     this.isStarted    = true;
     this.startTime    = Time.realtimeSinceStartup;
     this.isPlaying    = true;
     this.isPaused     = false;
     this.isStopped    = false;
     this.isFinished   = true;
 }
Exemple #4
0
 public void Update(float currentTime)
 {
     if (!this.isPlaying || this.isPaused || this.isStopped)
     {
         return;
     }
     if (currentTime > this.startTime + this.delay / TimerDaemon.TimeLayer[this.timeLayer].timeScale)
     {
         if (this.callback != null)
         {
             this.callback();
             if (this.autodestruct)
             {
                 this.callback = null;
             }
         }
         if (this.coRoutine != null)
         {
             TimerDaemon.timerDaemon.StartCoroutine(this.coRoutine());
             if (this.autodestruct)
             {
                 this.coRoutine = null;
             }
         }
         if (this.publisher != null)
         {
             this.publisher.SendMessage();
             if (this.autodestruct)
             {
                 this.publisher = null;
             }
         }
         if (this.autodestruct)
         {
             this.Remove();
         }
         if (!this.repeatable)
         {
             this.isStarted  = false;
             this.isPlaying  = false;
             this.isFinished = true;
         }
         if (this.repeatable)
         {
             this.Reset();
         }
     }
 }
Exemple #5
0
 public static Timer CoAdd(float delay, CoRoutineCallback coRoutine, bool repeatable)
 {
     return(Timer.Add(delay, null, coRoutine, null, repeatable, !repeatable));
 }
Exemple #6
0
 public static Timer CoAdd(float delay, CoRoutineCallback coRoutine)
 {
     return(Timer.Add(delay, null, coRoutine, null, false, true));
 }