public void HandleKeyEvent(string keyValue, string keyAction) { if (keyAction == "KEY_PRESS") { switch (keyValue) { case "KEY_UP": if (activeMenuButton == 1) { activeMenuButton = 0; inactiveMenuButton = 1; menuButtons[inactiveMenuButton].SetColor(new Vec3F(0.5f, 0.1f, 0.1f)); menuButtons[activeMenuButton].SetColor((new Vec3F(0.3f, 0.4f, 0.1f))); } break; case "KEY_DOWN": if (activeMenuButton == 0) { activeMenuButton = 1; inactiveMenuButton = 0; menuButtons[inactiveMenuButton].SetColor(new Vec3F(0.5f, 0.1f, 0.1f)); menuButtons[activeMenuButton].SetColor((new Vec3F(0.3f, 0.4f, 0.1f))); } break; case "KEY_ENTER": if (activeMenuButton == 0) { GameRunning.GetInstance().InitializeGameState(); GalagaBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_RUNNING", "")); } if (activeMenuButton == 1) { GalagaBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.WindowEvent, this, "CLOSE_WINDOW", "", "")); } break; } } }
public static GameRunning GetInstance() { return(GameRunning.instance ?? (GameRunning.instance = new GameRunning())); }