Beispiel #1
0
        //tutaj zczytujemy klawisz i dobieramy odpowiednie zachowaie do stanu gry
        public bool CheckButton(KeyboardState keyboardState)
        {
            // jak gramy to obslugą klawiatury zajmuje sie songPlayer
            if (state.gameState == GameState.PLAYING || state.gameState == GameState.EDITING)
            {
                songPlayer.Update(keyboardState);
            }


            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                switch (state.gameState)
                {
                case GameState.LOGO:
                    break;

                case GameState.MENU:
                    break;

                case GameState.PLAYING:
                    break;

                case GameState.EDITING:
                    break;

                case GameState.NAME:
                    state.gameState = GameState.MENU;
                    break;

                case GameState.CREDITS:
                    state.gameState = GameState.MORE;
                    break;

                case GameState.CONTROL:
                    break;

                case GameState.MORE:
                    state.gameState = GameState.MENU;
                    break;

                default:
                    break;
                }
            }

            if (state.gameState == GameState.NAME)
            {
                NameManager.CheckKey(keyboardState);
            }

            // dla klawisza ENTER
            if (keyboardState.IsKeyDown(Keys.Enter))
            {
                switch (state.gameState)
                {
                case GameState.NAME:
                    state.gameState = GameState.MENU;
                    break;

                // jak wyswietlamy logo to przelaczamy się na wyswietlanie menu
                case GameState.LOGO:
                    state.gameState = GameState.MENU;
                    break;

                // jak wyswietlamy menu to w zaleznosci od tego co jest zaznaczone
                case GameState.MENU:
                    switch (state.menuState)
                    {
                    //wyswietlamy liste piosenek
                    case MenuState.PLAY:
                    {
                        // TUTAJ MAGIA DYSPUTA

                        songPlayer      = new GameStageController(songResources, true);
                        state.gameState = GameState.PLAYING;
                    }
                    break;

                    // wyswietlamy creditsy
                    case MenuState.MORE:
                    {
                        state.gameState = GameState.MORE;
                    }
                    break;

                    // wychodzimy z gry
                    case MenuState.EXIT:
                        return(true);

                    // dys se wlacza editor
                    case MenuState.EDITOR:
                    {
                        songPlayer = new GameStageController(songResources, false);

                        state.gameState = GameState.EDITING;
                    }
                    break;

                    default:
                        break;
                    }
                    break;

                //Dodatkowe opcje
                case GameState.MORE:
                {
                    switch (state.moreState)
                    {
                    case MoreState.NAME:
                        state.gameState = GameState.NAME;
                        break;

                    case MoreState.CREDITS:
                        state.gameState = GameState.CREDITS;
                        break;

                    case MoreState.CONTROL:
                        Thread thread = new Thread(VirtualComPort.Connect);
                        thread.Start();
                        break;

                    default:
                        break;
                    }
                }
                break;

                // jak gramy piosenka (tu pewnie zostanie puste - nic nie robimy jak klikniemy enter grając w grę )
                case GameState.PLAYING:
                    break;

                default:
                    break;
                }
            }


            // dla klawisza UP
            if (keyboardState.IsKeyDown(Keys.Up))
            {
                switch (state.gameState)
                {
                case GameState.LOGO:
                    break;

                case GameState.MENU:
                {
                    int temp = (int)state.menuState - 1;
                    if (temp < 0)
                    {
                        temp = 3;
                    }
                    state.menuState = (MenuState)temp;
                }
                break;

                case GameState.MORE:
                {
                    int temp = (int)state.moreState - 1;
                    if (temp < 0)
                    {
                        temp = 2;
                    }
                    state.moreState = (MoreState)temp;
                }
                break;

                case GameState.PLAYING:
                    break;

                default:
                    break;
                }
            }

            //Dla klawisza DOWN
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Down))
            {
                switch (state.gameState)
                {
                case GameState.LOGO:
                    break;

                case GameState.MENU:
                {
                    int temp = (int)state.menuState + 1;
                    if (temp > 3)
                    {
                        temp = 0;
                    }
                    state.menuState = (MenuState)temp;
                }
                break;

                case GameState.MORE:
                {
                    int temp = (int)state.moreState + 1;
                    if (temp > 2)
                    {
                        temp = 0;
                    }
                    state.moreState = (MoreState)temp;
                }
                break;

                case GameState.PLAYING:
                    break;

                default:
                    break;
                }
            }

            return(false);
        }