Ejemplo n.º 1
0
        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();
                    }
                }
            };
        }
Ejemplo n.º 2
0
 public GameEngine(ObservableTimer timer, MessageBus bus, GameObjectFactory objectFactory)
 {
     Timer = timer;
     Bus = bus;
     ObjectFactory = objectFactory;
     IsRunning = false;
     Initialise();
 }
Ejemplo n.º 3
0
 void TryInitDelay()
 {
     if (_curAnim.delay.max > 0f)
     {
         _timerDelay         = new ObservableTimer(_curAnim.delay.GetRand());
         _timerDelay.OnDone += () => _timerDelay = null;
     }
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 void Start()
 {
     if (_options.Delay > 0f)
     {
         _timer         = new ObservableTimer(_options.Delay);
         _timer.OnDone += () => {
             Play();
         };
     }
     else
     {
         Play();
     }
 }
Ejemplo n.º 6
0
            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;
                };
            }