예제 #1
0
 public Emitter(ParticleData data, int intervalInMilliseconds)
 {
     ParticleSystem._emitters.Add(this);
     _timer.ResetAndWaitFor(intervalInMilliseconds);
     _timer.SetTimeReached += delegate()
     {
         ParticleSystem.Add(data);
     };
 }
예제 #2
0
 /// <summary>
 /// Blocks execution of code until the time duration has passed.
 /// </summary>
 /// <param name="duration"></param>
 /// <returns></returns>
 protected void WaitThen(int duration, Action action)
 {
     Misc.GameTimer timer = new Misc.GameTimer();
     _waitTimers.Add(timer);
     timer.ResetAndWaitFor(duration, delegate()
     {
         action?.Invoke();
         _waitTimers.Remove(timer);
     });
 }
예제 #3
0
 /// <summary>
 /// Performs the given action after the given duration.
 /// </summary>
 /// <param name="waitDuration"></param>
 /// <param name="action"></param>
 /// <returns>A timer that has the set time</returns>
 protected Misc.GameTimer CreateTimedAction(int duration, Action action)
 {
     Misc.GameTimer timer = new Misc.GameTimer();
     _waitTimers.Add(timer);
     timer.ResetAndWaitFor(duration, delegate()
     {
         timer.Reset();
         action?.Invoke();
     }, true);
     return(timer);
 }