Example #1
0
        override public void Update(GameTime time)
        {
            if (goUp)
            {
                MenuScale[Selected] += .01f;
            }
            else
            {
                MenuScale[Selected] -= .01f;
            }
            if (MenuScale[Selected] > 1.4 || MenuScale[Selected] < 1)
            {
                goUp = !goUp;
            }

            oldState         = currentState;
            XboxoldState     = XboxcurrentState;
            XboxcurrentState = GamePad.GetState(PlayerIndex.One);
            currentState     = Keyboard.GetState();

            if ((currentState.IsKeyDown(Keys.W) && !oldState.IsKeyDown(Keys.W)) || (currentState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up)) || (XboxcurrentState.DPad.Up == ButtonState.Pressed && XboxoldState.DPad.Up != ButtonState.Pressed))
            {
                Sound.playSoundOnce("Sound\\tap", content);
                MenuScale[Selected] = 1;
                Selected--;
                if (Selected < 0)
                {
                    Selected = 1;
                }
                MenuScale[Selected] = 1;
                goUp = true;
            }
            if ((currentState.IsKeyDown(Keys.S) && !oldState.IsKeyDown(Keys.S)) || (currentState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down)) || (XboxcurrentState.DPad.Down == ButtonState.Pressed && XboxoldState.DPad.Down != ButtonState.Pressed))
            {
                Sound.playSoundOnce("Sound\\tap", content);
                MenuScale[Selected] = 1;
                Selected++;
                if (Selected > 1)
                {
                    Selected = 0;
                }
                MenuScale[Selected] = 1;
                goUp = true;
            }
            if ((currentState.IsKeyDown(Keys.Space) && !oldState.IsKeyDown(Keys.Space)) || (currentState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter)) || (XboxcurrentState.IsButtonDown(Buttons.A) && !XboxoldState.IsButtonDown(Buttons.A)))
            {
                //Enter was pressed on a menu Item.
                if (Selected == 0)
                {
                    ScreenManager.RemoveAll();
                    GamePlayScreen level = new GamePlayScreen();
                    level.Level          = this.level;
                    level.Terrain        = "Models\\" + this.level;
                    level.TerrainTexture = "Textures\\" + this.level;
                    level.Background     = "Sound\\" + this.level;
                    level.Name           = this.name;
                    ScreenManager.AddScreen(level);
                }
                else if (Selected == 1)
                {
                    ScreenManager.RemoveAll();
                    ScreenManager.AddScreen(new MainMenu());
                }
            }
        }