public override void Update(GameTime gameTime)
 {
     menuComponent.Update(gameTime);
     if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) ||
         (menuComponent.MouseOver && Xin.CheckMouseReleased(MouseButtons.Left)))
     {
         if (menuComponent.SelectedIndex == 0)
         {
             Xin.FlushInput();
             GameRef.GamePlayState.SetUpNewGame();
             GameRef.GamePlayState.StartGame();
             manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl);
         }
         else if (menuComponent.SelectedIndex == 1)
         {
             Xin.FlushInput();
             GameRef.GamePlayState.LoadExistingGame();
             GameRef.GamePlayState.StartGame();
             manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl);
         }
         else if (menuComponent.SelectedIndex == 2)
         {
             Xin.FlushInput();
         }
         else if (menuComponent.SelectedIndex == 3)
         {
             Game.Exit();
         }
     }
     base.Update(gameTime);
 }
Пример #2
0
        public override void Update(GameTime gameTime)
        {
            PlayerIndex index = PlayerIndex.One; // TODO

            elapsed += gameTime.ElapsedGameTime;

            menuComponent.Update(gameTime, index);

            this.player1pad = GamePad.GetState(PlayerIndex.One);

            if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) || (menuComponent.MouseOver && Xin.CheckMouseReleased(MouseButtons.Left)) || this.player1pad.IsButtonDown(Buttons.A))
            {
                buttonSelect.Play();

                if (menuComponent.SelectedIndex == 0) // new single player game
                {
                    Xin.FlushInput();

                    this.gameOptions.GameType = GameType.SinglePlayer;
                    GameRef.GamePlayState.SetUpNewGame(this.gameOptions);
                    GameRef.GamePlayState.StartGame();
                    manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl);
                }
                else if (menuComponent.SelectedIndex == 1) // new 2 player cooperative game
                {
                    Xin.FlushInput();

                    this.gameOptions.GameType = GameType.TwoPlayerCooperative;
                    GameRef.GamePlayState.SetUpNewGame(this.gameOptions);
                    GameRef.GamePlayState.StartGame();
                    manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl);
                }
                else if (menuComponent.SelectedIndex == 2) // new 2 player deathmatch game
                {
                    Xin.FlushInput();

                    this.gameOptions.GameType = GameType.TwoPlayerDeathmatch;
                    GameRef.GamePlayState.SetUpNewGame(this.gameOptions);
                    GameRef.GamePlayState.StartGame();
                    manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl);
                }
                else if (menuComponent.SelectedIndex == 3)
                {
                    Game.Exit();
                }
            }
            base.Update(gameTime);
        }
Пример #3
0
        public override void Update(GameTime gameTime)
        {
            switch (connectionState)
            {
            case ConnectionState.SERVER_SELECT:
                serverSelectionMenuComponent.Update(gameTime);

                if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) || (serverSelectionMenuComponent.MouseOver && Xin.CheckMouseReleased(MouseButtons.Left)))
                {
                    if (serverSelectionMenuComponent.SelectedIndex == 0)
                    {
                        Xin.FlushInput();
                        ConnectToServer(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2013));
                        //GameRef.GamePlayState.SetUpNewGame();
                        //GameRef.GamePlayState.StartGame();
                        //manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl);
                    }
                    else if (serverSelectionMenuComponent.SelectedIndex == 1)
                    {
                        Xin.FlushInput();
                        GameRef.SetWindowResolution(400, 300);
                        //ConnectToServer(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2014));



                        //GameRef.GamePlayState.LoadExistingGame();
                        //GameRef.GamePlayState.StartGame();
                        //manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl);
                    }
                    else if (serverSelectionMenuComponent.SelectedIndex == 2)
                    {
                        Game.Exit();
                    }
                }
                break;

            case ConnectionState.LOGIN:
                loginComponent.Update(gameTime);
                break;
            }

            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            _menuComponent.Update(gameTime);
            if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) ||
                (_menuComponent.MouseOver && Xin.CheckMouseReleased(MouseButtons.Left)))
            {
                switch (_menuComponent.SelectedIndex)
                {
                case 0:
                    Xin.FlushInput();

                    GameRef.GamePlayState.SetUpNewGame();
                    GameRef.GamePlayState.StartGame();
                    Manager.PushState(GameRef.GamePlayState, PlayerIndexInControl);
                    break;

                case 1:
                    Xin.FlushInput();

                    GameRef.GamePlayState.LoadExistingGame();
                    GameRef.GamePlayState.StartGame();
                    Manager.PushState(GameRef.GamePlayState, PlayerIndexInControl);
                    break;

                case 2:
                    Xin.FlushInput();
                    break;

                case 3:
                    Game.Exit();
                    break;
                }
            }

            base.Update(gameTime);
        }