MontyHallGame.MontyHallHelpScreen Class Reference

This screen implements the game help. More...

Inheritance diagram for MontyHallGame.MontyHallHelpScreen:
NewGamePhysics.StateManager.GameScreen

List of all members.

Public Member Functions

 MontyHallHelpScreen (string[] screenMessage)
 Constructor of the screen.
override void LoadContent ()
 Load graphics content for the game.
override void UnloadContent ()
 Unload graphics content used by the game.
override void Update (GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
 Updates the state of the screen.
override void HandleInput (InputState input)
 Lets the game respond to player input. Unlike the Update method, this will only be called when the gameplay screen is active.
override void Draw (GameTime gameTime)
 Draws the gameplay screen.

Detailed Description

This screen implements the game help.

Definition at line 25 of file MontyHallHelpScreen.cs.


Constructor & Destructor Documentation

MontyHallGame.MontyHallHelpScreen.MontyHallHelpScreen ( string[]  screenMessage  ) 

Constructor of the screen.

Parameters:
screenMessage The help message to display.

Definition at line 62 of file MontyHallHelpScreen.cs.

00063         {
00064             // New message list
00065             this.messages = new List<string>();
00066 
00067             // Store screen message
00068             this.messages.AddRange(screenMessage);
00069 
00070             // Add exit message
00071             string[] exitMessage = {"", "", "[Key] or (Button) to return to Main Menu"};
00072             this.messages.AddRange(exitMessage);
00073 
00074             TransitionOnTime = TimeSpan.FromSeconds(0.5);
00075             TransitionOffTime = TimeSpan.FromSeconds(0.5);
00076         }


Member Function Documentation

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

Draws the gameplay screen.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 172 of file MontyHallHelpScreen.cs.

00173         {
00174             // Get drawing helpers and textures
00175             PrimitiveBatch primitiveBatch = ScreenManager.PrimitiveBatch;
00176             SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
00177             Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
00178             SpriteFont font = ScreenManager.Fonts["game"];
00179 
00180             // Draw score summary
00181             Color color = Color.White;
00182             Vector2 origin = new Vector2(0, 0);
00183             Vector2 position = new Vector2(viewport.Width * 0.05f, viewport.Height * 0.05f);
00184             float scale = 0.5f;
00185             spriteBatch.Begin();
00186             for (int i=0; i<numRows; i++)
00187             {
00188                 string message = messages[i];
00189                 if (textAlpha[i] > 0.0f)
00190                 {
00191                     if (string.IsNullOrEmpty(message))
00192                     {
00193                         // Skip this row
00194                         position.Y += ((float)font.LineSpacing * 0.5f * scale);
00195                     }
00196                     else
00197                     {
00198                         color = new Color(Color.White, MathHelper.SmoothStep(0.0f, 1.0f, textAlpha[i]));
00199                         spriteBatch.DrawString(
00200                             font,
00201                             message,
00202                             position,
00203                             color,
00204                             0,
00205                             origin,
00206                             scale,
00207                             SpriteEffects.None,
00208                             0);
00209                         position.Y += ((float)font.LineSpacing * 1.2f * scale);
00210                     }
00211                 }
00212             }
00213             spriteBatch.End();
00214 
00215             // If the game is transitioning on or off, fade it out to black.
00216             if (TransitionPosition > 0)
00217             {
00218                 ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
00219             }
00220 
00221             base.Draw(gameTime);
00222         }

override void MontyHallGame.MontyHallHelpScreen.HandleInput ( InputState  input  )  [virtual]

Lets the game respond to player input. Unlike the Update method, this will only be called when the gameplay screen is active.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 141 of file MontyHallHelpScreen.cs.

00142         {
00143             if (input == null)
00144             {
00145                 throw new ArgumentNullException("input");
00146             }
00147 
00148             // Look up inputs for the active player profile.
00149             PlayerIndex playerIndex = ControllingPlayer.Value;
00150 
00151             KeyboardState keyboardState = input.CurrentKeyboardStates[(int)playerIndex];
00152             GamePadState gamePadState = input.CurrentGamePadStates[(int)playerIndex];
00153 
00154             // The game pauses either if the user presses the pause button, or if
00155             // they unplug the active gamepad. This requires us to keep track of
00156             // whether a gamepad was ever plugged in, because we don't want to pause
00157             // on PC if they are playing with a keyboard and have no gamepad at all!
00158             bool gamePadDisconnected = !gamePadState.IsConnected &&
00159                                        input.GamePadWasConnected[(int)playerIndex];
00160 
00161             // Back to main menu
00162             if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
00163             {
00164                 MontyHallLoadingScreen.Load(ScreenManager, false, null, new MontyHallBackgroundScreen(),
00165                                                                new MontyHallMainMenuScreen());
00166             }
00167         }

override void MontyHallGame.MontyHallHelpScreen.LoadContent (  )  [virtual]

Load graphics content for the game.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 81 of file MontyHallHelpScreen.cs.

00082         {
00083             if (this.contentManager == null)
00084             {
00085                 this.contentManager = new ContentManager(ScreenManager.Game.Services, "Content");
00086             }
00087 
00088             // Reset text fader 
00089             numRows = messages.Count;
00090             currentRow = 0;
00091             textAlpha = new float[numRows];
00092             for (int i = 0; i < numRows; i++)
00093             {
00094                 textAlpha[i] = 0.0f;
00095             }
00096 
00097             // Reset game time
00098             ScreenManager.Game.ResetElapsedTime();
00099         }

override void MontyHallGame.MontyHallHelpScreen.UnloadContent (  )  [virtual]

Unload graphics content used by the game.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 104 of file MontyHallHelpScreen.cs.

00105         {
00106             this.contentManager.Unload();
00107         }

override void MontyHallGame.MontyHallHelpScreen.Update ( GameTime  gameTime,
bool  otherScreenHasFocus,
bool  coveredByOtherScreen 
) [virtual]

Updates the state of the screen.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 116 of file MontyHallHelpScreen.cs.

00118         {
00119             base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
00120 
00121             if (IsActive)
00122             {
00123                 // Fade logic
00124                 if (currentRow < numRows)
00125                 {
00126                     textAlpha[currentRow] += fadeSpeed;
00127                     if (string.IsNullOrEmpty(messages[currentRow]) ||
00128                        (textAlpha[currentRow] >= 1.0f))
00129                     {
00130                         textAlpha[currentRow] = 1.0f;
00131                         currentRow++;
00132                     }
00133                 }
00134             }
00135         }


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

Generated by  doxygen 1.6.2