MontyHallGame.MontyHallGameOverScreen Class Reference

Shows the GameOver screen. More...

Inheritance diagram for MontyHallGame.MontyHallGameOverScreen:
NewGamePhysics.StateManager.MenuScreen NewGamePhysics.StateManager.GameScreen

List of all members.

Public Member Functions

 MontyHallGameOverScreen (string title)
 Constructor.
override void Draw (GameTime gameTime)
 Draws the menu screen. This darkens down the gameplay screen that is underneath us, and then chains to the base MenuScreen.Draw.

Detailed Description

Shows the GameOver screen.

Definition at line 18 of file MontyHallGameOverScreen.cs.


Constructor & Destructor Documentation

MontyHallGame.MontyHallGameOverScreen.MontyHallGameOverScreen ( string  title  ) 

Constructor.

Definition at line 25 of file MontyHallGameOverScreen.cs.

00026             : base(title)
00027         {
00028             // Flag that there is no need for the game to transition
00029             // off when the pause menu is on top of it.
00030             IsPopup = true;
00031 
00032             // Create our menu entries.
00033             MenuEntry continueMenuEntry = new MenuEntry("Continue and Play Again");
00034             MenuEntry returnMenuEntry = new MenuEntry("Return to Main Menu");
00035 
00036             // Hook up menu event handlers.
00037             continueMenuEntry.Selected += OnContinue;
00038             returnMenuEntry.Selected += OnReturn;
00039 
00040             // Add entries to the menu.
00041             MenuEntries.Add(continueMenuEntry);
00042             MenuEntries.Add(returnMenuEntry);
00043         }


Member Function Documentation

override void MontyHallGame.MontyHallGameOverScreen.Draw ( GameTime  gameTime  )  [virtual]

Draws the menu screen. This darkens down the gameplay screen that is underneath us, and then chains to the base MenuScreen.Draw.

Reimplemented from NewGamePhysics.StateManager.MenuScreen.

Definition at line 78 of file MontyHallGameOverScreen.cs.

00079         {
00080             ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 4 / 5);
00081 
00082             // Messages
00083             string[] messages = new string[4];
00084             messages[0] = "Statistics:";
00085             messages[1] = "  Games Won: " + MontyHallGame.state.Wins;
00086             messages[2] = "  Games Lost: " + MontyHallGame.state.Losses;
00087             messages[3] = "  Switched Doors: " + MontyHallGame.state.Switches + " times";
00088 
00089             int totalGames = MontyHallGame.state.Wins + MontyHallGame.state.Losses;
00090             if (totalGames > 0)
00091             {
00092                 if (MontyHallGame.state.Wins > 0)
00093                 {
00094                     messages[1] += "    (" +
00095                         string.Format("{0:.%}", (double)MontyHallGame.state.Wins / (double)totalGames) +
00096                         " of games)";
00097                 }
00098 
00099                 if (MontyHallGame.state.Losses > 0)
00100                 {
00101                     messages[2] += "    (" +
00102                         string.Format("{0:.%}", (double)MontyHallGame.state.Losses / (double)totalGames) +
00103                         " of games)";
00104                 }
00105 
00106 
00107                 if (MontyHallGame.state.Switches > 0)
00108                 {
00109                     messages[3] += "    (" +
00110                         string.Format("{0:.%}", (double)MontyHallGame.state.Switches / (double)totalGames) +
00111                         " of games)";
00112                 }
00113             }
00114 
00115             // Draw score summary
00116             SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
00117             SpriteFont font = ScreenManager.Fonts["retro"];
00118             Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
00119             Color color = Color.White;
00120             Vector2 origin = new Vector2(0, 0);
00121             Vector2 position = new Vector2(viewport.Width * 0.25f, viewport.Height * 0.55f);
00122             spriteBatch.Begin();
00123             foreach (string message in messages)
00124             {
00125                 spriteBatch.DrawString(
00126                     font,
00127                     message,
00128                     position,
00129                     color,
00130                     0,
00131                     origin,
00132                     1.0f,
00133                     SpriteEffects.None,
00134                     0);
00135                 position.Y += (viewport.Height * 0.05f);
00136             }
00137             spriteBatch.End();
00138 
00139             base.Draw(gameTime);
00140         }


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2