// Function loads the currently Highlighted song and starts the game private void StartPlayingWithCurrentlyHightlightedSong() { FileInfo cMidiFileInfo; // Use the Highlighted Song as the Song to Use switch (meHighlightedMusic) { default: case EMusic.Simple: // Set the Music to Play mcCurrentMusic = mcSIMPLE_MUSIC; // Store the Path of the Music to play cMidiFileInfo = new FileInfo("../../Data/Music/Simple.mid"); break; case EMusic.DansMario: // Set the Music to Play mcCurrentMusic = mcDANS_MARIO_MUSIC; // Store the Path of the Music to play cMidiFileInfo = new FileInfo("../../Data/Music/DansMario.mid"); break; case EMusic.Mario: // Set the Music to Play mcCurrentMusic = mcMARIO_MUSIC; // Store the Path of the Music to play cMidiFileInfo = new FileInfo("../../Data/Music/Mario.mid"); break; } // Reset the Players Score to zero miScore = 0; // Start Playing the Music mcWindowsMediaPlayer.URL = cMidiFileInfo.FullName; mcWindowsMediaPlayer.Ctlcontrols.play(); // Start Playing the Game meShootingGalleryState = EShootingGalleryGameStates.Play; }
// Reset class variables to their default values public void Reset() { // Record that we are playing Pong meGame = EGames.ShootingGallery; // Set the games initial State meShootingGalleryState = EShootingGalleryGameStates.ChoosingSong; // Set the default Music to use meHighlightedMusic = EMusic.Mario; mcCurrentMusic = mcMARIO_MUSIC; // Stop any Music that might be playing mcWindowsMediaPlayer.Ctlcontrols.stop(); // Reset the duration the Song has been done playing for mfSecondsSongHasBeenCompleteFor = 0.0f; // Create the Target List mcTargetList = new List <CTarget>(); }
// Handle key presses public override EGames KeyDown(KeyEventArgs e) { // If the Pause button is pressed if (e.KeyCode == Keys.Space) { // If we are currently Playing the Game if (meShootingGalleryState == EShootingGalleryGameStates.Play) { // Pause the music mcWindowsMediaPlayer.Ctlcontrols.pause(); // Pause the Game meShootingGalleryState = EShootingGalleryGameStates.Pause; } // Else if the Game is currently Paused else if (meShootingGalleryState == EShootingGalleryGameStates.Pause) { // Start the music mcWindowsMediaPlayer.Ctlcontrols.play(); // Play the Game meShootingGalleryState = EShootingGalleryGameStates.Play; } // Don't Pause if currently choosing a Song } // If we are Choosing a Song if (meShootingGalleryState == EShootingGalleryGameStates.ChoosingSong) { // If the Player wants to play with the Highlighted Song if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space) { StartPlayingWithCurrentlyHightlightedSong(); } } // If the Player wants to change the Highlighted Song // If Up was pressed if (e.KeyCode == Keys.Up) { // Highlight the Previous song meHighlightedMusic--; // Wrap around if (meHighlightedMusic < 0) { meHighlightedMusic = EMusic.DansMario; } } // Else if Down was pressed else if (e.KeyCode == Keys.Down) { // Highlight the Next song meHighlightedMusic++; // Wrap around if (meHighlightedMusic > EMusic.DansMario) { meHighlightedMusic = 0; } } // If the Restart button is pressed if (e.KeyCode == Keys.R) { // Return to Choosing a Song Reset(); } return(meGame); }