Beispiel #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;
        }
Beispiel #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;
        }
        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);
        }