Пример #1
0
 internal override void Update(GameTime gameTime, SpriteBatch batch)
 {
     if (InputHelper.WasButtonPressed(Keys.R) || InputHelper.WasPadButtonPressedP1(Buttons.A))
     {
         GameStateManager.CurrentGameState = GameState.InGame;
         GameStateManager.HasChanged       = true;
     }
     if (InputHelper.WasButtonPressed(Keys.Escape) || InputHelper.WasPadButtonPressedP1(Buttons.B))
     {
         GameStateManager.CurrentGameState = GameState.MainMenu;
         GameStateManager.HasChanged       = true;
     }
 }
Пример #2
0
        internal override void Update(GameTime gameTime, SpriteBatch batch)
        {
            if (paused == false)
            {
                if (InputHelper.WasButtonPressed(Keys.Escape) | InputHelper.WasPadButtonPressedP1(Buttons.Start))
                {
                    paused = true;
                }

                foreach (CirclePlayer player in players)
                {
                    player.Update();
                }

                foreach (CirclePlayer player in AIplayers)
                {
                    player.Update();
                }

                tracks.Update();

                if (DeathHelper.KillPlayer.Count > 0)
                {
                    foreach (CirclePlayer player in DeathHelper.KillPlayer)
                    {
                        if (player.player < 4)
                        {
                            players.Remove(player);
                        }
                        else
                        {
                            AIplayers.Remove(player);
                        }
                    }
                }

                if (players.Count() < 2 && ScoreHelper.NPlayers != 1 |
                    ScoreHelper.NPlayers == 1 && (AIplayers.Count() < 1 | players.Count() < 1))
                {
                    if (end == false)
                    {
                        end = true;
                        if (players.Count() == 1)
                        {
                            int p = players[0].player;
                            ScoreHelper.Scores[p] += 1;
                        }
                    }

                    endTimer += gameTime.ElapsedGameTime.Milliseconds;

                    if (endTimer >= endTime)
                    {
                        GameStateManager.CurrentGameState = GameState.InGame;
                        GameStateManager.HasChanged       = true;
                    }
                }

                DeathHelper.KillPlayer = new List <CirclePlayer> {
                };
            }

            else
            {
                if (InputHelper.WasButtonPressed(Keys.Escape) | InputHelper.WasPadButtonPressedP1(Buttons.Start))
                {
                    paused = false;
                }

                if (InputHelper.WasButtonPressed(Keys.Q) | InputHelper.WasPadButtonPressedP1(Buttons.Back))
                {
                    GameStateManager.CurrentGameState = GameState.MainMenu;
                    GameStateManager.HasChanged       = true;
                }
            }
        }
Пример #3
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;
        }