Example #1
0
        public void option_Subselection()
        {
            currKey = Keyboard.GetState();

            if (currKey.IsKeyDown(Keys.Down) && PrevKey.IsKeyUp(Keys.Down))
            {
                selected_sub++;
                if (selected_sub > num_options_sub)
                {
                    selected_sub = 1;
                }
            }

            if (currKey.IsKeyDown(Keys.Up) && PrevKey.IsKeyUp(Keys.Up))
            {
                selected_sub--;
                if (selected_sub <= 0)
                {
                    selected_sub = num_options_sub;
                }
            }

            PrevKey = currKey;
        }
Example #2
0
        /// <summary>
        /// Figures out what the user has selected and sets the selection
        /// to match it.
        /// </summary>
        public void option_selection()
        {
            currKey = Keyboard.GetState();

            if (currKey.IsKeyDown(Keys.Down) && PrevKey.IsKeyUp(Keys.Down))
            {
                selected++;
                if (selected > num_options)
                {
                    selected = 1;
                }
            }

            if (currKey.IsKeyDown(Keys.Up) && PrevKey.IsKeyUp(Keys.Up))
            {
                selected--;
                if (selected <= 0)
                {
                    selected = num_options;
                }
            }

            PrevKey = currKey;
        }
Example #3
0
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            //theMenu_Manager.option_selection();

            switch (state)
            {
            case GameState.StartMenu:
                #region StartMenu sequence

                theMusic_Manager.playTheme(state, New_Game_state);

                theMenu_Manager.option_selection();
                currKey = Keyboard.GetState();
                if (currKey.IsKeyUp(Keys.Enter) && PrevKey.IsKeyDown(Keys.Enter))
                {
                    state = (GameState)theMenu_Manager.selected;
                }
                PrevKey = currKey;

                break;
                #endregion

            case GameState.NewGame:

                Keyboard_Listener2();

                theMusic_Manager.playTheme(state, New_Game_state);

                theMenu_Manager.option_Subselection();

                if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    New_Game_state = (NewGameMenu)theMenu_Manager.selected_sub;
                }

                switch (New_Game_state)
                {
                case NewGameMenu.Normal:
                    #region vers1Game sequence

                    Keyboard_Listener();

                    if (ball_1.isActive)
                    {
                        Update_OneBallGame(gameTime);

                        if (ball_1.Position.Y > paddle.Position.Y)
                        {
                            ball_1.isActive = false;
                            gameover        = true;
                        }
                    }

                    else if (gameover)
                    {
                        gameover = false;
                        theSoundBank.PlayCue("LBMiss");
                        Fade_Controls.beingFade = true;
                        Fade_Controls.fadeAnim  = true;
                    }

                    else if (Fade_Controls.beingFade)
                    {
                        Fade_Controls.Dec_AlphaPerTime(gameTime);
                    }


                    break;
                    #endregion

                case NewGameMenu.Hard:
                    #region vers2Game sequence

                    Keyboard_Listener();

                    if (ball_1.isActive && ball_2.isActive)
                    {
                        Update_TwoBallGame(gameTime);

                        if (ball_1.Position.Y > paddle.Position.Y)
                        {
                            ball_1.isActive = false;
                            gameover        = true;
                        }

                        if (ball_2.Position.Y > paddle.Position.Y)
                        {
                            ball_2.isActive = false;
                            gameover        = true;
                        }
                    }

                    else if (gameover)
                    {
                        gameover = false;
                        theSoundBank.PlayCue("LBMiss");
                        Fade_Controls.beingFade = true;
                        Fade_Controls.fadeAnim  = true;
                    }

                    else if (Fade_Controls.beingFade)
                    {
                        Fade_Controls.Dec_AlphaPerTime(gameTime);
                    }

                    break;
                    #endregion
                }
                break;

            case GameState.Options:
                Keyboard_Listener2();
                break;

            case GameState.Help:
                Keyboard_Listener2();
                break;

            case GameState.About:
                Keyboard_Listener2();
                break;

            case GameState.Exit:
                #region Exit sequence
                this.Exit();
                break;
                #endregion
            }

            base.Update(gameTime);
        }
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            PrevKey    = CurrentKey;
            CurrentKey = Keyboard.GetState();
            prevms     = ms;
            ms         = Mouse.GetState();
            string username = Login.userName;

            switch (gameState)
            {
            case GameStates.TitleScreen:
                if (playButton.Contains(ms.Position))
                {
                    if (ms.LeftButton == ButtonState.Pressed && prevms.LeftButton == ButtonState.Released)
                    {
                        loginForm.Show();
                        System.Threading.Thread.Sleep(300);
                        gameState = GameStates.GameLobby;
                    }
                }
                if (exitButton.Contains(ms.Position))
                {
                    if (ms.LeftButton == ButtonState.Pressed && prevms.LeftButton == ButtonState.Released)
                    {
                        Exit();
                    }
                }
                break;

            case GameStates.GameLobby:
                Network.Update(this);
                ChatManager.Update();
                GameLobby.Update(gameTime, ms);

                if (Login.IsConnected)
                {
                    if (CurrentKey.IsKeyDown(Keys.E) && PrevKey.IsKeyUp(Keys.E))
                    {
                        chatBox.Show();
                    }
                }

                if (GameLobby.timer <= 0)
                {
                    Random randX = new Random();
                    Random randY = new Random();
                    int    x, y;

                    x = randX.Next(0, 500);
                    y = randY.Next(0, 400);

                    Network.outmsg = Network.Client.CreateMessage();
                    Network.outmsg.Write("CharacterSelection");
                    Network.outmsg.Write(Login.userName);
                    Network.outmsg.Write(GameLobby.selectedHero);
                    Network.outmsg.Write(x);
                    Network.outmsg.Write(y);
                    Network.Client.SendMessage(Network.outmsg, NetDeliveryMethod.ReliableOrdered);
                    gameState = GameStates.PlayingState;
                }
                break;

            case GameStates.PlayingState:
                Network.Update(this);
                collisionManager.Update(this);
                Player.Update(gameTime);
                shotManager.Update();
                break;

            case GameStates.EndGameScreen:
                Network.Update(this);
                break;
            }
            base.Update(gameTime);
        }