Exemplo n.º 1
0
 public void Remove()
 {
     TimerDaemon.timerDaemon.timers.Remove(this);
     this.callback  = null;
     this.coRoutine = null;
     this.publisher = null;
 }
Exemplo n.º 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);
    }
Exemplo n.º 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;
 }
Exemplo n.º 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();
         }
     }
 }
Exemplo n.º 5
0
 public static Timer CoAdd(float delay, CoRoutineCallback coRoutine, bool repeatable)
 {
     return(Timer.Add(delay, null, coRoutine, null, repeatable, !repeatable));
 }
Exemplo n.º 6
0
 public static Timer CoAdd(float delay, CoRoutineCallback coRoutine)
 {
     return(Timer.Add(delay, null, coRoutine, null, false, true));
 }