Example #1
0
        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, 1.0f, 1.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, 1.0f, 1.0f));
                        activeMenuButton++;
                        menuButtons[activeMenuButton].SetColor(new Vec3F(0.0f, 1.0f, 0.0f));
                    }
                    break;

                case "KEY_ENTER":
                    switch (activeMenuButton)
                    {
                    case 1:
                        TaxiBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent,
                                this,
                                "CHANGE_STATE",
                                "SELECT_LEVEL", ""));
                        break;

                    case 2:
                        TaxiBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.WindowEvent,
                                this,
                                "CLOSE_WINDOW", "", ""));
                        break;

                    default:
                        //GameRunning.NewInstance();
                        GameRunning.NewInstance();
                        TaxiBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent,
                                this,
                                "CHANGE_STATE",
                                "GAME_RUNNING", ""));
                        break;
                    }
                    break;
                }
            }
        }
Example #2
0
 private void GameOver()
 {
     GameRunning.NewInstance();
     TaxiBus.GetBus().RegisterEvent(
         GameEventFactory <object> .CreateGameEventForAllProcessors(
             GameEventType.GameStateEvent,
             this,
             "CHANGE_STATE",
             "MAIN_MENU", ""));
 }
Example #3
0
        public void SwitchState(GameStateType stateType)
        {
            switch (stateType)
            {
            case GameStateType.GameRunning:
                ActiveState = GameRunning.GetInstance();
                break;

            case GameStateType.MainMenu:
                ActiveState = MainMenu.GetInstance();
                break;

            case GameStateType.SelectLevel:
                ActiveState = SelectLevel.GetInstance();
                break;

            case GameStateType.GamePaused:
                ActiveState = GamePaused.GetInstance();
                break;
            }
        }
Example #4
0
 public static GameRunning GetInstance()
 {
     return(instance ?? (instance =
                             new GameRunning()));
 }
Example #5
0
 public static void NewInstance()
 {
     instance = new GameRunning();
 }