Esempio n. 1
0
        public void TestEventBusSimpleCount5TestSeq()
        {
            _eb.RegisterEvent(_eventControl);
            _eb.RegisterEvent(_eventSound);
            _eb.RegisterEvent(_eventControl);
            _eb.RegisterEvent(_eventControl);
            _eb.RegisterEvent(_eventSound);

            _eb.ProcessEventsSequentially();

            Assert.That(_simpleEventProcessor.EventCounterControl == 3);
            Assert.That(_simpleEventProcessor.EventCounterSound == 2);
        }
Esempio n. 2
0
        public void GameLoop()
        {
            while (win.IsRunning())
            {
                gameTimer.MeasureTime();

                win.PollEvents();

                eventBus.ProcessEventsSequentially();

                stateMachine.ActiveState.UpdateGameLogic();
                if (gameTimer.ShouldRender())
                {
                    win.Clear();

                    stateMachine.ActiveState.RenderState();

                    win.SwapBuffers();
                }
                if (gameTimer.ShouldReset())
                {
                    // 1 second has passed - display last captured ups and fps from the timer
                    win.Title = "Space Taxi | UPS: " + gameTimer.CapturedUpdates + ", FPS: " +
                                gameTimer.CapturedFrames;
                }
            }
        }
        public void TestSingleEvent(int timeSpan)
        {
            container.AddTimedEvent(TimeSpanType.Milliseconds, timeSpan, "msg", "par1", "par2");

            // elapse timeSpan for events to expire
            var startTime = StaticTimer.GetElapsedMilliseconds();
            var nowTime   = 0.0;

            // save some space, because system timers are never 100% precise
            while ((nowTime = StaticTimer.GetElapsedMilliseconds()) - startTime < timeSpan + 10)
            {
            }

            container.ProcessTimedEvents();
            bus.ProcessEventsSequentially(); // events must be processed on the main thread!
            Assert.AreEqual(1, processor.ObservedEvents);
        }