// If a Mouse button is pressed public override EGames MouseDown(MouseEventArgs e) { // Save the current game being played (i.e. Main Menu) EGames eGameToPlay = meGame; // Get Mouses Position and store it as a rectangle Rectangle rMouse = new Rectangle(e.X, e.Y, 1, 1); // If the Left Mouse button was pressed if (e.Button == MouseButtons.Left) { // If they clicked to Toggle the Sound on/off if (mrToggleSoundArea.IntersectsWith(rMouse)) { // Toggle the Sound on/off CFMOD.mbSoundOn = !CFMOD.mbSoundOn; } // Else play the Selected game else { // Get which game to start playing eGameToPlay = meSelectedGame; } } // Return which Game should be played now return(eGameToPlay); }
// If a Keyboard Key is pressed public override EGames KeyDown(KeyEventArgs e) { // Game to load EGames eGameToPlay = meGame; // If the player is switching the selection if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Up) { // Switch selection to previous game meSelectedGame--; // Reset the Game Scale mfSelectedGameScale = 0.0f; // Wrap around if necessary if (meSelectedGame == EGames.MainMenu) { meSelectedGame = EGames.HighScores; } // Play Menu Selection Changed sound CFMOD.PlaySound(msSoundSelectionChanged, false); } else if (e.KeyCode == Keys.Right || e.KeyCode == Keys.Down) { // Switch selection to next game meSelectedGame++; // Reset the Game Scale mfSelectedGameScale = 0.0f; // Wrap around if necessary if (meSelectedGame > EGames.HighScores) { meSelectedGame = EGames.Spong; } // Play Menu Selection Changed sound CFMOD.PlaySound(msSoundSelectionChanged, false); } // If the player has chosen the Game to play if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space) { eGameToPlay = meSelectedGame; } // If the player is toggling the Sound on/off if (e.KeyCode == Keys.S) { // Toggle the Sound on/off CFMOD.mbSoundOn = !CFMOD.mbSoundOn; } // Return which Game should be played now return(eGameToPlay); }
// Reset class variables back to default values public void Reset() { // Record that we are in the Main Menu meGame = EGames.MainMenu; // Select Pong by default meSelectedGame = EGames.Spong; // Set the grow/shrink variables mfSelectedGameScale = 0.0f; mbSelectedGameScaleGrow = true; }
// Handle Mouse presses public override EGames MouseDown(MouseEventArgs e) { EGames eGameToPlay = meGame; // If the right mouse button was pressed if (e.Button == MouseButtons.Right) { eGameToPlay = EGames.MainMenu; } return(eGameToPlay); }
public bool bSwitchGamesNow; // Tells if we should switch the game now or not // Function to Reset variables to their default values public void Reset() { sColor = Color.Black; iDurationInMilliseconds = 0; eGameToSwitchTo = EGames.MainMenu; fEndOpacity = 1.0f; iElapsedTime = 0; bPerfromingTransition = false; bFadeOutComplete = false; bSwitchGamesNow = false; }
// Handle Mouse presses public override EGames MouseDown(MouseEventArgs e) { EGames eGameToPlay = meGame; // If the right mouse button was pressed if (e.Button == MouseButtons.Right) { eGameToPlay = EGames.MainMenu; } // Else if the Left mouse button was pressed else if (e.Button == MouseButtons.Left) { // Fire the Arrow FireArrow(); } return(eGameToPlay); }
// Handle Mouse presses public override EGames MouseDown(MouseEventArgs e) { EGames eGameToPlay = meGame; // If the right mouse button was pressed if (e.Button == MouseButtons.Right) { // Switch to the Main Menu eGameToPlay = EGames.MainMenu; } // If we are Choosing a Song if (meShootingGalleryState == EShootingGalleryGameStates.ChoosingSong) { // If the Player wants to play with the Highlighted Song if (e.Button == MouseButtons.Left) { StartPlayingWithCurrentlyHightlightedSong(); } } return(eGameToPlay); }
// Constructor public CGame() { meGame = EGames.MainMenu; }
// If the Mouse is moved public override void MouseMove(MouseEventArgs e) { // Get Mouses Position and store it as a rectangle Rectangle rMouse = new Rectangle(e.X, e.Y, 1, 1); // If the Mouse is over the Pong game icon if (mrPongIcon.IntersectsWith(rMouse) && meSelectedGame != EGames.Spong) { // Set Pong as the Selected game meSelectedGame = EGames.Spong; // Reset the Game Scale mfSelectedGameScale = 0.0f; // Play Menu Selection Changed sound CFMOD.PlaySound(msSoundSelectionChanged, false); } // Else if the Mouse is over the Shooting Gallery game icon else if (mrShootingGalleryIcon.IntersectsWith(rMouse) && meSelectedGame != EGames.ShootingGallery) { // Set Shooting Gallery as the Selected game meSelectedGame = EGames.ShootingGallery; // Reset the Game Scale mfSelectedGameScale = 0.0f; // Play Menu Selection Changed sound CFMOD.PlaySound(msSoundSelectionChanged, false); } // Else if the Mouse is over the Pitch Matcher game icon else if (mrPitchMatcherIcon.IntersectsWith(rMouse) && meSelectedGame != EGames.PitchMatcher) { // Set Pitch Matcher as the Selected game meSelectedGame = EGames.PitchMatcher; // Reset the Game Scale mfSelectedGameScale = 0.0f; // Play Menu Selection Changed sound CFMOD.PlaySound(msSoundSelectionChanged, false); } // Else if the Mouse is over the Target Practice game icon else if (mrTargetPracticeIcon.IntersectsWith(rMouse) && meSelectedGame != EGames.TargetPractice) { // Set Target Practice as the Selected game meSelectedGame = EGames.TargetPractice; // Reset the Game Scale mfSelectedGameScale = 0.0f; // Play Menu Selection Changed sound CFMOD.PlaySound(msSoundSelectionChanged, false); } // Else if the Mouse is over the Profile Settings icon else if (mrProfileSettingsIcon.IntersectsWith(rMouse) && meSelectedGame != EGames.ProfileSettings) { // Set the Profile Settings as the Selected icon meSelectedGame = EGames.ProfileSettings; // Reset the Game Scale mfSelectedGameScale = 0.0f; // Play Menu Selection Changed sound CFMOD.PlaySound(msSoundSelectionChanged, false); } // Else if the Mouse is over the High Scores icon else if (mrHighScoresIcon.IntersectsWith(rMouse) && meSelectedGame != EGames.HighScores) { // Set High Scores as the Selected game meSelectedGame = EGames.HighScores; // Reset the Game Scale mfSelectedGameScale = 0.0f; // Play Menu Selection Changed sound CFMOD.PlaySound(msSoundSelectionChanged, false); } }
// If eNewGame is different than the current Game, start playing the New Game private void PlayGame(EGames eNewGame) { // If the Game type should be changed if (mcGame.meGame != eNewGame) { // If the screen Transition hasn't started yet if (!msTransition.bPerfromingTransition) { // Reset the Transition variables msTransition.Reset(); // Record that we are now performing a Transition msTransition.bPerfromingTransition = true; // Save which Game to switch to during the Transition msTransition.eGameToSwitchTo = eNewGame; // Set the color to fade with msTransition.sColor = Color.Black; // Set Duration based on which Game we are switching to switch (eNewGame) { case EGames.ProfileSettings: msTransition.iDurationInMilliseconds = 0; msTransition.fEndOpacity = 0.7f; break; default: msTransition.iDurationInMilliseconds = 500; break; } } // Else we are in the middle of the Transition else { // Check which Game to switch to switch (eNewGame) { default: case EGames.MainMenu: // Make sure the Windows Media Player controls are hidden and not playing playerWindowsMediaPlayer.Visible = false; playerWindowsMediaPlayer.Ctlcontrols.stop(); playerWindowsMediaPlayer.URL = ""; mcGame = new CMainMenu(); break; case EGames.Spong: mcGame = new CSpong(); break; case EGames.ShootingGallery: mcGame = new CShootingGallery(playerWindowsMediaPlayer); break; case EGames.PitchMatcher: mcGame = new CPitchMatcher(); break; case EGames.TargetPractice: mcGame = new CTargetPractice(); break; case EGames.HighScores: mcGame = new CHighScores(); break; case EGames.ProfileSettings: try { // Open and show the Profile Settings Form as a modal form formProfileSettings cProfileSettingsForm = new formProfileSettings(); cProfileSettingsForm.SetGameObjectHandle(ref mcGame); cProfileSettingsForm.ShowDialog(); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error generating Profile Settings Form"); } break; } } } }