public void RepeatedTestPauseTimer()
        {
            var testTimer = new Stopwatch();

            StaticTimer.RestartTimer();

            for (int i = 0; i < 10; i++)
            {
                StaticTimer.ResumeTimer();
                Assert.GreaterOrEqual(StaticTimer.GetElapsedMilliseconds(), 1000 * i, $"test {i} (1)");
                Assert.Less(StaticTimer.GetElapsedMilliseconds(), 50 + 1000 * i, $"test {i} (2)");
                Wait(testTimer, 1000);
                StaticTimer.PauseTimer();
            }
        }
        public void TestPauseTimer()
        {
            var testTimer = new Stopwatch();

            StaticTimer.RestartTimer();
            Wait(testTimer, 1000);
            StaticTimer.PauseTimer();
            Assert.GreaterOrEqual(StaticTimer.GetElapsedMilliseconds(), 1000, "test 1");

            Wait(testTimer, 1000);
            StaticTimer.ResumeTimer();
            Wait(testTimer, 1000);
            //Assert.AreEqual(2000, StaticTimer.GetElapsedMilliseconds(), "test 2 første");
            Assert.GreaterOrEqual(StaticTimer.GetElapsedMilliseconds(), 2000, "test 2");
        }
Ejemplo n.º 3
0
        public void KeyPress(string key)
        {
            switch (key)
            {
            case "KEY_ESCAPE":
                StaticTimer.PauseTimer();
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_PAUSED", ""));
                break;

            case "KEY_F12":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.WindowEvent, this, "SAVE_SCREENSHOT", "", ""));
                break;

            case "KEY_UP":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "BOOSTER_UPWARDS", "", ""));
                break;

            case "KEY_LEFT":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "BOOSTER_TO_LEFT", "", ""));
                break;

            case "KEY_RIGHT":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "BOOSTER_TO_RIGHT", "", ""));
                break;
            }
        }