/// <summary> /// Controls the various scenes for the game, waiting for user input and responding with the correct follow up action /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { KeyboardState ks = Keyboard.GetState(); //the index of which menu item is currently hovered/selected int selectedIndex = 0; //check to see if were on menu screen if (menuScene.Enabled) { selectedIndex = menuScene.Menu.SelectedIndex; //sets the selected index if (selectedIndex == 0 && ks.IsKeyDown(Keys.Enter)) //if Play game is selected, hide the menu and menu music and play action scene with music { menuScene.Hide(); MediaPlayer.Stop(); actionScene.ResetGame(); actionScene.Show(); MediaPlayer.Play(actionSong); MediaPlayer.IsRepeating = true; MediaPlayer.Volume = 0.1f; } else if (selectedIndex == 1 && ks.IsKeyDown(Keys.Enter)) //if Help scene is selected, hide menu and show help scene { menuScene.Hide(); helpScene.Show(); } else if (selectedIndex == 2 && ks.IsKeyDown(Keys.Enter)) //if Credit scene is selected, hide menu and show credit scene { menuScene.Hide(); creditScene.Show(); } else if (selectedIndex == 3 && ks.IsKeyDown(Keys.Enter)) //if Quit is selected, close the application { Exit(); } } else if (actionScene.Enabled) //check to see if the user is on the action scene { if (ks.IsKeyDown(Keys.Escape)) { MediaPlayer.Stop(); actionScene.Hide(); menuScene.Show(); MediaPlayer.Play(menuSong); MediaPlayer.IsRepeating = true; } } else if (helpScene.Enabled) //check to see if user is on the help scene { if (ks.IsKeyDown(Keys.Escape)) { helpScene.Hide(); menuScene.Show(); } } else if (creditScene.Enabled) //check to see if the user is on the credit scene { if (ks.IsKeyDown(Keys.Escape)) { creditScene.Hide(); menuScene.Show(); } } else if (gameOverScene.Enabled) //check to see if the user is on the game over scene { if (ks.IsKeyDown(Keys.Escape)) { gameOverScene.Hide(); menuScene.Show(); MediaPlayer.Play(menuSong); MediaPlayer.IsRepeating = true; } } base.Update(gameTime); }