Ejemplo n.º 1
0
 private void resultTimer_Tick(object sender, EventArgs e)
 {
     resultDelay -= 1.0f;
     if (resultDelay <= 0)
     {
         RepaintGame();
         //Stop the timer so it only checks once, and resets it for next use
         resultTimer.Stop();
         resultDelay = RESULTS_SCREEN_DELAY;
         if (currentGame.GameState == Game.State.Won)
         {
             //They've won their current match
             Player.matchWins += 1;
             if (matchIndex != NUMBER_OF_T_MATCHES - 1)
             {
                 //Asks the player if they want to play the next match of tournament
                 TournamentMatchPrompt tPrompt = new TournamentMatchPrompt();
                 tPrompt.ShowDialog();
                 //0 = Yes, 1 = No
                 if (tPrompt.selectedChoice == 0)
                 {
                     matchIndex++;
                     StartGame();
                 }
                 else
                 {
                     Player.tournamentsLost += 1;
                     this.Close();
                 }
                 //Clear the screen from memory
                 tPrompt.Dispose();
             }
             else
             {
                 //Win tournament
                 soundPlayer.Stop();
                 Player.tournamentsWon += 1;
                 //Win screen setup (lose screen similar)
                 GameEndScreen winScreen = new GameEndScreen();
                 winScreen.gameResult         = currentGame.GameState;
                 winScreen.soundPlayer.Stream = Properties.Resources.VictoryAnnouncer;
                 PictureBox winPicBox = (PictureBox)winScreen.Controls["resultPictureBox"];
                 winPicBox.Image = Properties.Resources.Victory;
                 winScreen.ShowDialog();
                 //See if user wants to play again or not
                 if (winScreen.selectedChoice == 0)
                 {
                     //Play the preparation music
                     soundPlayer.Stream = Properties.Resources.Preparation;
                     soundPlayer.Play();
                     StartGame();
                 }
                 else
                 {
                     this.Close();
                 }
                 //Clear the screen from memory
                 winScreen.Dispose();
             }
         }
         else if (currentGame.GameState == Game.State.Tie)
         {
             //Player needs to play until tie is broken.
             Player.matchTies += 1;
             MessageBox.Show("You have tied with the opponent. You need to rematch until there is a winner.");
             StartGame();
         }
         else if (currentGame.GameState == Game.State.Lost)
         {
             //Lost tournament
             soundPlayer.Stop();
             Player.matchLoss       += 1;
             Player.tournamentsLost += 1;
             GameEndScreen lostScreen = new GameEndScreen();
             lostScreen.gameResult         = currentGame.GameState;
             lostScreen.soundPlayer.Stream = Properties.Resources.DefeatAnnouncer;
             PictureBox losePicBox = (PictureBox)lostScreen.Controls["resultPictureBox"];
             losePicBox.Image = Properties.Resources.Defeat;
             lostScreen.ShowDialog();
             //If the user wants to play again, it will be with same piece
             if (lostScreen.selectedChoice == 0)
             {
                 //Play the preparation music
                 soundPlayer.Stream = Properties.Resources.Preparation;
                 soundPlayer.Play();
                 //Reset everything to defaults
                 matchIndex           = 0;
                 championMatchStarted = false;
                 championMusicPlayed  = false;
                 battleMusicPlayed    = false;
                 aiNameLabel.Text     = "AI";
                 aiPictureBox.Image   = Properties.Resources.aipicture;
                 StartGame();
             }
             else
             {
                 this.Close();
             }
             //Clear the screen from memory
             lostScreen.Dispose();
         }
     }
 }
Ejemplo n.º 2
0
 private void endScreenTimer_Tick(object sender, EventArgs e)
 {
     endScreenDelay -= 1.0f;
     if (endScreenDelay <= 0)
     {
         //Repaint the game again.
         RepaintGame();
         //Check only happens once, so we reset the timer.
         endScreenTimer.Stop();
         endScreenDelay = END_SCREEN_DELAY;
         GameEndScreen gameEndScreen    = new GameEndScreen();
         PictureBox    resultPictureBox = (PictureBox)gameEndScreen.Controls["resultPictureBox"];
         //Used to see if player wants to play again.
         bool quitting = false;
         if (currentGame.WinnerPiece == currentGame.PlayerPiece)
         {
             //Win screen
             Player.matchWins += 1;
             //Assign the appropriate info to the end screen
             gameEndScreen.soundPlayer.Stream = Properties.Resources.VictoryAnnouncer;
             gameEndScreen.gameResult         = currentGame.GameState;
             resultPictureBox.Image           = Properties.Resources.Victory;
             gameEndScreen.ShowDialog();
             //See if the player wants to play again
             if (gameEndScreen.selectedChoice == 0)
             {
                 quitting = false;
             }
             else
             {
                 quitting = true;
             }
         }
         else if (currentGame.WinnerPiece == Piece.None)
         {
             //Tie screen
             Player.matchTies        += 1;
             gameEndScreen.gameResult = currentGame.GameState;
             resultPictureBox.Image   = Properties.Resources.Tie;
             gameEndScreen.ShowDialog();
             if (gameEndScreen.selectedChoice == 0)
             {
                 quitting = false;
             }
             else
             {
                 quitting = true;
             }
         }
         else if (currentGame.WinnerPiece == currentGame.AIPiece)
         {
             //Make sure the board is up to date.
             RepaintGame();
             //Lose screen
             Player.matchLoss += 1;
             gameEndScreen.soundPlayer.Stream = Properties.Resources.DefeatAnnouncer;
             gameEndScreen.gameResult         = currentGame.GameState;
             resultPictureBox.Image           = Properties.Resources.Defeat;
             gameEndScreen.ShowDialog();
             //See if the player wants to play again
             if (gameEndScreen.selectedChoice == 0)
             {
                 quitting = false;
             }
             else
             {
                 quitting = true;
             }
         }
         //Clear the end screen from memory.
         gameEndScreen.Dispose();
         //Determine whether to restart the game or not
         if (quitting)
         {
             this.Close();
         }
         else
         {
             StartGame();
             //Repaint the grid so it's empty again
             RepaintGame();
         }
     }
 }