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.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 = 2; } MenuScale[Selected] = 1; goUp = true; } if ((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 > 5) { Selected = 0; } MenuScale[Selected] = 1; goUp = true; } if ((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) { Entrance newGame = new Entrance(); newGame.Level = 1; ScreenManager.AddScreen(newGame); } else if (Selected == 1) { Entrance newGame = new Entrance(); newGame.Level = 2; ScreenManager.AddScreen(newGame); } else if (Selected == 2) { Entrance newGame = new Entrance(); newGame.Level = 3; ScreenManager.AddScreen(newGame); } else if (Selected == 3) { Entrance newGame = new Entrance(); newGame.Level = 4; ScreenManager.AddScreen(newGame); } else if (Selected == 4) { Entrance newGame = new Entrance(); newGame.Level = 5; ScreenManager.AddScreen(newGame); } else if (Selected == 5) { ScreenManager.RemoveAll(); ScreenManager.AddScreen(new MainMenu()); } } }
override public void Update(GameTime time) { if (goUp) { MenuScale[Selected] += .005f; } else { MenuScale[Selected] -= .005f; } if (MenuScale[Selected] > 0.6 || MenuScale[Selected] < 0.5) { goUp = !goUp; } oldState = currentState; XboxoldState = XboxcurrentState; XboxcurrentState = GamePad.GetState(PlayerIndex.One); currentState = Keyboard.GetState(); if ((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] = 0.5f; Selected--; if (Selected < 0) { Selected = 2; } MenuScale[Selected] = 0.5f; goUp = true; } if ((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] = 0.5f; Selected++; if (Selected > 2) { Selected = 0; } MenuScale[Selected] = 0.5f; goUp = true; } if ((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(); GamePlayScreen level = new GamePlayScreen(); this.level++; if (this.level >= 5) { this.level = 0; } 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 == 2) { ScreenManager.RemoveAll(); ScreenManager.AddScreen(new MainMenu()); } } }