Esempio n. 1
0
        public void Update(MyGame game, GameTime gameTime)
        {
            background.Update(game, gameTime, PlayerAction.None);
            timer++;
            var kbState = Keyboard.GetState();
            var gpState = GamePad.GetState(PlayerIndex.One);

            if (timer > 0)
            {
                if (gpState.Buttons.Back == ButtonState.Pressed || kbState.IsKeyDown(Keys.Escape))
                {
                    game.Exit();
                    return;
                }

                if ((kbState.IsKeyDown(Keys.Right)
                                || kbState.IsKeyDown(Keys.D)
                                || gpState.IsButtonDown(Buttons.DPadRight)
                                || gpState.IsButtonDown(Buttons.LeftThumbstickRight)))
                {
                    timer = -10;
                    selectedButton[selectedIndex] = false;
                    selectedButton[(selectedIndex + 1) % 4] = true;
                    selectedIndex = (selectedIndex + 1) % 4;
                    Draw(game, gameTime);
                }

                if (kbState.IsKeyDown(Keys.Left)
                    || kbState.IsKeyDown(Keys.A)
                    || gpState.IsButtonDown(Buttons.DPadLeft)
                    || gpState.IsButtonDown(Buttons.LeftThumbstickLeft))
                {
                    timer = -10;
                    selectedButton[selectedIndex] = false;
                    selectedButton[(selectedIndex + 3) % 4] = true;
                    selectedIndex = (selectedIndex + 3) % 4;
                    Draw(game, gameTime);
                }

                if (kbState.IsKeyDown(Keys.Space))
                {
                    if (selectedIndex == 0)
                    {
                        var scene = new GameLevel(@"Content\Maps\level_fire.txt");
                        game.setScene(scene);
                    }
                    else if (selectedIndex == 1)
                    {
                        var scene = new GameLevel(@"Content\Maps\level_earth.txt");
                        game.setScene(scene);
                    }
                    else if (selectedIndex == 2)
                    {
                        var scene = new GameLevel(@"Content\Maps\level_air.txt");
                        game.setScene(scene);
                    }
                    else if (selectedIndex == 3)
                    {
                        var scene = new GameLevel(@"Content\Maps\level_water.txt");
                        game.setScene(scene);
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Encerra a execução do jogo
 /// </summary>
 public static void End()
 {
     game.Exit();
 }