Ejemplo n.º 1
0
        public void SwitchState(GameStateType stateType)
        {
            switch (stateType)
            {
            case GameStateType.GameRunning:
                ActiveState = GameRunning.GetInstance();
                break;

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

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

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

            case GameStateType.GameWon:
                ActiveState = GameWon.GetInstance();
                break;
            }
        }
Ejemplo n.º 2
0
        public void RenderState()
        {
            GameRunning.GetInstance().RenderState();

            foreach (Text but in menuButtons)
            {
                but.RenderText();
            }
        }
Ejemplo n.º 3
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, 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":
                    if (activeMenuButton == 1)
                    {
                        GalagaBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.WindowEvent,
                                this,
                                "CLOSE_WINDOW", "", ""));
                    }
                    else if (activeMenuButton == 0)
                    {
                        GameRunning.NewInstance();
                        GalagaBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent,
                                this,
                                "CHANGE_STATE",
                                "GAME_RUNNING", ""));
                    }
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        private void SwitchState(StateTransformer.GameStateType stateType)
        {
            switch (stateType)
            {
            case StateTransformer.GameStateType.MainMenu:
                ActiveState = MainMenu.GetInstance();
                break;

            case StateTransformer.GameStateType.GameRunning:
                ActiveState = GameRunning.GetInstance(game);
                break;

            case StateTransformer.GameStateType.GamePaused:
                ActiveState = GamePaused.GetInstance();
                break;
            }
        }
Ejemplo n.º 5
0
        public void ActivateButton()
        {
            switch (Math.Abs(activeMenuButton % maxMenuButtons))
            {
            case 0:
                GalagaBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_RUNNING", ""));
                break;

            case 1:
                GameRunning.NewInstance();
                GalagaBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.GameStateEvent, this, "CHANGE_STATE", "MAIN_MENU", ""));
                break;
            }
        }
Ejemplo n.º 6
0
 public static GameRunning NewInstance()
 {
     return(GameRunning.instance = new GameRunning());
 }
Ejemplo n.º 7
0
 public static GameRunning GetInstance()
 {
     return(GameRunning.instance ?? (GameRunning.instance = new GameRunning()));
 }