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