コード例 #1
0
        /// <summary>
        /// updates everything that's specific for a GameState
        /// </summary>
        /// <param name="mouseState"></param>
        /// <param name="keyboardState"></param>
        /// <param name="gameTime"></param>
        private void SwitchUpdate(KeyboardState keyboardState, GameTime gameTime)
        {
            switch (CurrentGameState)
            {
            case GameState.MainMenu:
                if (button.BtnFreePlay.IsClicked)
                {
                    CurrentGameState = GameState.FreePlay;
                }
                if (button.BtnTutorial.IsClicked)
                {
                    CurrentGameState = GameState.Tutorial;
                }
                if (button.BtnOptions.IsClicked)
                {
                    CurrentGameState = GameState.Options;
                }
                button.BtnOptions.Update(false, gameTime);
                button.BtnTutorial.Update(false, gameTime);
                button.BtnFreePlay.Update(false, gameTime);
                break;

            case GameState.Tutorial:
                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    CurrentGameState = GameState.MainMenu;
                }
                break;

            case GameState.Options:
                if (keyboardState.IsKeyDown(Keys.Right) && oldKeyboardState.IsKeyUp(Keys.Right))
                {
                    MediaPlayer.Stop();
                }
                if (keyboardState.IsKeyDown(Keys.OemPlus) && oldKeyboardState.IsKeyUp(Keys.OemPlus))
                {
                    cube.IncreaseRotationSpeed();
                }
                if (button.BtnRussian.IsClicked)
                {
                    lang.Russian();
                }
                if (button.BtnHebrew.IsClicked)
                {
                    lang.Hebrew();
                }
                if (button.BtnEnglish.IsClicked)
                {
                    lang.English();
                }
                button.BtnEnglish.Update(false, gameTime);
                button.BtnHebrew.Update(false, gameTime);
                button.BtnRussian.Update(false, gameTime);
                CheckClickOnAddMusic();
                music.Update();
                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    CurrentGameState = GameState.MainMenu;
                }
                break;

            case GameState.FreePlay:
                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    CurrentGameState = GameState.MainMenu;
                    DebugBorders("MainMenu");
                }
                if (button.BtnScramble.IsClicked)
                {
                    shouldRotate = true;
                }
                if (button.BtnSolve.IsClicked)
                {
                    clocks.StopStoper();
                    cube.Angle      = 0;
                    shouldRotate    = false;
                    AlgOrder        = "";
                    AllTimeAlgOrder = "";
                    YAlgOrder       = "";
                    cube.Solve();
                    DebugBorders("Reset!");
                }
                if (shouldRotate || solve.ShouldScramble)
                {
                    cube.Scramble();
                    AlgOrder            += cube.ScrambleResult;
                    shouldRotate         = false;
                    solve.ShouldScramble = false;
                }
                CheckClickOnStopper();
                clocks.UpdateStoper(gameTime);
                if (shouldRunStopper)
                {
                    clocks.StartStoper();
                }
                button.BtnScramble.Update(false, gameTime);
                button.BtnSolve.Update(false, gameTime);

                break;
            }
        }
コード例 #2
0
        private void SwitchUpdate(MouseState mouseState, KeyboardState keyboardState, GameTime gameTime)
        {
            switch (currentGameState)
            {
            case GameState.MainMenu:
                if (button.btnFreePlay.isClicked)
                {
                    currentGameState = GameState.FreePlay;
                }
                if (button.btnTutorial.isClicked)
                {
                    currentGameState = GameState.Tutorial;
                }
                if (button.btnOptions.isClicked)
                {
                    currentGameState = GameState.Options;
                }
                button.btnOptions.Update(mouseState, false);
                button.btnTutorial.Update(mouseState, false);
                button.btnFreePlay.Update(mouseState, false);
                break;

            case GameState.Tutorial:
                if (keyboardState.IsKeyDown(Keys.Back))
                {
                    currentGameState = GameState.MainMenu;
                }
                break;

            case GameState.Options:
                if (keyboardState.IsKeyDown(Keys.Right) && oldKeyboardState.IsKeyUp(Keys.Right))
                {
                    MediaPlayer.Stop();
                }
                if (button.btnHebrew.isClicked)
                {
                    lang.Hebrew();
                }
                if (button.btnEnglish.isClicked)
                {
                    lang.English();
                }
                if (button.ClassicBound.Contains(mousePos) && mouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released && whichGenre != "classic")
                {
                    whichGenre   = "classic";
                    justSwitched = true;
                    MediaPlayer.Stop();
                }
                else if (whichGenre == "classic")
                {
                    justSwitched = false;
                }
                if (button.RockBound.Contains(mousePos) && mouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released && whichGenre != "rock")
                {
                    whichGenre   = "rock";
                    justSwitched = true;
                    MediaPlayer.Stop();
                }
                else if (whichGenre == "rock")
                {
                    justSwitched = false;
                }
                music.Update(mouseState, whichGenre, justSwitched);
                button.btnEnglish.Update(mouseState, false);
                button.btnHebrew.Update(mouseState, false);
                if (keyboardState.IsKeyDown(Keys.Back))
                {
                    currentGameState = GameState.MainMenu;
                }
                break;

            case GameState.FreePlay:
                if (keyboardState.IsKeyDown(Keys.Back))
                {
                    currentGameState = GameState.MainMenu;
                }
                if (button.btnScramble.isClicked)
                {
                    shouldScramble = true;
                }
                if (button.btnSolve.isClicked)
                {
                    cube.Solve();
                }
                cube.Update(gameTime, shouldScramble, algOrder);
                if (cube.ScrambleIndex >= 25)
                {
                    shouldScramble     = false;
                    cube.ScrambleIndex = 0;
                }
                button.btnScramble.Update(mouseState, false);
                button.btnSolve.Update(mouseState, false);
                break;
            }
        }