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"); }
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 HandleKeyEvent(string keyValue, string keyAction) { if (keyAction == "KEY_PRESS") { switch (keyValue) { case "KEY_UP": if (activeMenuButton > 0) { menuButtons[activeMenuButton].SetColor(new Vec3F(1.0f, 0.0f, 0.0f)); activeMenuButton--; menuButtons[activeMenuButton].SetColor(new Vec3F(0.0f, 1.0f, 0.0f)); } break; case "KEY_DOWN": if (activeMenuButton < maxMenuButtons - 1) { menuButtons[activeMenuButton].SetColor(new Vec3F(1.0f, 0.0f, 0.0f)); activeMenuButton++; menuButtons[activeMenuButton].SetColor(new Vec3F(0.0f, 1.0f, 0.0f)); } break; case "KEY_ENTER": StaticTimer.ResumeTimer(); if (activeMenuButton == 1) { LevelContainer.GetInstance().Restart(); SpaceTaxiBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "CHANGE_STATE", "MAIN_MENU", "")); } else if (activeMenuButton == 0) { SpaceTaxiBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_RUNNING", "")); } break; } } }