Beispiel #1
0
        internal override void Update(GameTime gameTime, SpriteBatch batch)
        {
            if (InputHelper.WasButtonPressed(Microsoft.Xna.Framework.Input.Keys.Enter) || InputHelper.WasButtonPressed(Microsoft.Xna.Framework.Input.Keys.Space) || InputHelper.WasPadButtonPressedP1(Buttons.A))
            {
                if (tree == 0)
                {
                    if (selected == 0)
                    {
                        GameStateManager.CurrentGameState = GameState.InGame;
                        GameStateManager.HasChanged       = true;
                    }
                    else if (selected == 1)
                    {
                        ScoreHelper.NPlayers += 1;
                        if (ScoreHelper.NPlayers > 4)
                        {
                            ScoreHelper.NPlayers = 1;
                        }
                        if (ScoreHelper.NAIPlayers == 0 && ScoreHelper.NPlayers == 1)
                        {
                            ScoreHelper.NAIPlayers = 1;
                        }
                    }
                    else if (selected == 2)
                    {
                        ScoreHelper.NAIPlayers += 1;
                        if (ScoreHelper.NAIPlayers > 4)
                        {
                            ScoreHelper.NAIPlayers = 0;
                        }
                        if (ScoreHelper.NAIPlayers == 0 && ScoreHelper.NPlayers == 1)
                        {
                            ScoreHelper.NAIPlayers = 1;
                        }
                    }
                    else if (selected == 3)
                    {
                        ViewPortHelper.ToggleFullscreen();
                    }
                    else if (selected == 4)
                    {
                        tree     = 1;
                        selected = 0;
                    }
                    else if (selected == 5)
                    {
                        Game.Exit();
                    }
                }

                else if (tree == 1)
                {
                    if (selected == 0)
                    {
                        GameStateManager.CurrentGameState = GameState.InGame;
                        GameStateManager.HasChanged       = true;
                    }
                    else if (selected == 1)
                    {
                        GameStateManager.CurrentGameState = GameState.InGame;
                        GameStateManager.HasChanged       = true;
                    }
                    else
                    {
                        tree     = 0;
                        selected = 0;
                    }
                }
            }

            // exit game
            if (InputHelper.WasButtonPressed(Microsoft.Xna.Framework.Input.Keys.Escape))
            {
                Game.Exit();
            }

            // menu control
            if (InputHelper.WasButtonPressed(Microsoft.Xna.Framework.Input.Keys.Up) || InputHelper.WasPadThumbstickUpP1())
            {
                selected -= 1;
            }
            if (InputHelper.WasButtonPressed(Microsoft.Xna.Framework.Input.Keys.Down) || InputHelper.WasPadThumbstickDownP1())
            {
                selected += 1;
            }

            if (selected > max)
            {
                selected = 0;
            }
            if (selected < 0)
            {
                selected = max;
            }


            // toggle fullscreen

            if (InputHelper.WasButtonPressed(Microsoft.Xna.Framework.Input.Keys.F) || InputHelper.WasPadButtonPressedP1(Buttons.X))
            {
                ViewPortHelper.ToggleFullscreen();
            }

            colours = new List <Color> {
                Color.White, Color.White, Color.White, Color.White, Color.White, Color.White
            };
            colours[selected] = Color.Red;
        }