void Play() { _timer = new ObservableTimer(_options.Duration); _timer.Progress += percentage => { float t = _isBackwards ? (1f - percentage) : percentage; float cur = _options.GetCurrent(t); Current?.Invoke(cur); }; _timer.OnDone += () => { if (_options.Count == -1) { Switch(); } else { ++_counter; if (_counter >= _options.Count) { _timer = null; float cur = _options.GetCurrent(_isBackwards ? 0f : 1f); Current?.Invoke(cur); OnDone?.Invoke(); } else { Switch(); } } }; }
public GameEngine(ObservableTimer timer, MessageBus bus, GameObjectFactory objectFactory) { Timer = timer; Bus = bus; ObjectFactory = objectFactory; IsRunning = false; Initialise(); }
void TryInitDelay() { if (_curAnim.delay.max > 0f) { _timerDelay = new ObservableTimer(_curAnim.delay.GetRand()); _timerDelay.OnDone += () => _timerDelay = null; } }
public void Setup() { mockMarketConfiguration = new Mock <IApplicationConfiguration>(); testScheduler = new TestScheduler(); instance = CreateObservableTimer(); mockMarketConfiguration.Setup(item => item.GetWorkDay(It.IsAny <DateTime>())) .Returns((DateTime item) => item); mockMarketConfiguration.Setup(item => item.Now).Returns(() => testScheduler.Now.UtcDateTime); }
void Start() { if (_options.Delay > 0f) { _timer = new ObservableTimer(_options.Delay); _timer.OnDone += () => { Play(); }; } else { Play(); } }
public PeriodicTimer(float duration, int repeat, Action callback) { _repeat = repeat; _callback = callback; _timer = new ObservableTimer(duration); _timer.OnDone += () => { if (_repeat < 0 || _counter < _repeat) { callback(); _timer.Reset(); } ++_counter; }; }