Shows the GameOver screen. More...
Public Member Functions | |
| PendulumGameOverScreen () | |
| Constructor. | |
| override void | LoadContent () |
| Loads graphics content for this screen. The background texture is quite big, so we use our own local ContentManager to load it. This allows us to unload before going from the menus into the game itself, wheras if we used the shared ContentManager provided by the Game class, the content would remain loaded forever. | |
| override void | UnloadContent () |
| Unloads graphics content for this screen. | |
| override void | Update (GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) |
| Updates the background screen. Unlike most screens, this should not transition off even if it has been covered by another screen: it is supposed to be covered, after all! This overload forces the coveredByOtherScreen parameter to false in order to stop the base Update method wanting to transition off. | |
| 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. | |
Shows the GameOver screen.
Definition at line 19 of file PendulumGameOverScreen.cs.
| PendulumGame.PendulumGameOverScreen.PendulumGameOverScreen | ( | ) |
Constructor.
Definition at line 60 of file PendulumGameOverScreen.cs.
00061 : base("Game Over") 00062 { 00063 // Flag that there is no need for the game to transition 00064 // off when the pause menu is on top of it. 00065 IsPopup = true; 00066 00067 // Create our menu entries. 00068 MenuEntry playGameMenuEntry = new MenuEntry("Play Again"); 00069 MenuEntry returnMenuEntry = new MenuEntry("Return to Main Menu"); 00070 00071 // Hook up menu event handlers. 00072 playGameMenuEntry.Selected += PlayGameMenuEntrySelected; 00073 returnMenuEntry.Selected += OnContinue; 00074 00075 // Add entries to the menu. 00076 MenuEntries.Add(playGameMenuEntry); 00077 MenuEntries.Add(returnMenuEntry); 00078 }
| override void PendulumGame.PendulumGameOverScreen.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 190 of file PendulumGameOverScreen.cs.
00191 { 00192 // Dim background 00193 ScreenManager.FadeBackBufferToBlack(3 * TransitionAlpha / 4); 00194 00195 // Messages 00196 string[] messages = new string[5]; 00197 if (PendulumGame.State.Players[0].Points > PendulumGame.State.Players[1].Points) 00198 { 00199 messages[0] = "Player A wins!"; 00200 } 00201 else if (PendulumGame.State.Players[0].Points == PendulumGame.State.Players[1].Points) 00202 { 00203 messages[0] = "It is a Tie!"; 00204 } 00205 else 00206 { 00207 messages[0] = "Player B wins!"; 00208 } 00209 00210 messages[0] = "===[ " + messages[0] + " ]==="; 00211 messages[1] = "Player A got " + PendulumGame.State.Players[0].Points + " points"; 00212 messages[2] = "Player B got " + PendulumGame.State.Players[1].Points + " points"; 00213 messages[3] = PendulumGame.State.SubmittedEntropyBits + " bits of Entropy extracted from last round"; 00214 messages[4] = 00215 PendulumGame.State.PhysicalRandomNumberGenerator.RetrievedEntropyBits + " bits of " + 00216 PendulumGame.State.PhysicalRandomNumberGenerator.EntropySource.ToString() + " Entropy used in total"; 00217 00218 // Draw score summary 00219 SpriteBatch spriteBatch = ScreenManager.SpriteBatch; 00220 SpriteFont font = ScreenManager.Fonts["retro"]; 00221 Viewport viewport = ScreenManager.GraphicsDevice.Viewport; 00222 Rectangle fullscreen = new Rectangle(0, 0, viewport.Width, viewport.Height); 00223 Color color = Color.White; 00224 Vector2 origin = new Vector2(0, 0); 00225 Vector2 position = new Vector2(viewport.Width * 0.3f, viewport.Height * 0.65f); 00226 spriteBatch.Begin(); 00227 foreach (string message in messages) 00228 { 00229 spriteBatch.DrawString( 00230 font, 00231 message, 00232 position, 00233 color, 00234 0, 00235 origin, 00236 1.0f, 00237 SpriteEffects.None, 00238 0); 00239 position.Y += (viewport.Height * 0.05f); 00240 } 00241 00242 spriteBatch.Draw( 00243 frameTexture, 00244 fullscreen, 00245 Color.White); 00246 spriteBatch.End(); 00247 00248 // Render the video in it's orginal resolution 00249 // to the screen using SpriteBatch 00250 if (ScreenManager.VideoPlayer.State == MediaState.Playing) 00251 { 00252 int frameSize = (int)((float)viewport.Width * 0.3f); 00253 Rectangle videoFrame = 00254 new Rectangle( 00255 viewport.Width - frameSize - 10, 00256 viewport.Height / 2 - frameSize / 2 - 30, 00257 frameSize, 00258 frameSize); 00259 spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); 00260 effect.Begin(); 00261 float threshold = 0.33f; 00262 effect.Parameters["referenceColor"].SetValue(this.referenceColor.ToVector3()); 00263 effect.Parameters["threshold"].SetValue(threshold); 00264 foreach (EffectPass pass in effect.CurrentTechnique.Passes) 00265 { 00266 pass.Begin(); 00267 spriteBatch.Draw( 00268 ScreenManager.VideoPlayer.GetTexture(), 00269 videoFrame, 00270 Color.White); 00271 pass.End(); 00272 } 00273 effect.End(); 00274 spriteBatch.End(); 00275 } 00276 00277 // If the game is transitioning on or off, fade it out to black. 00278 if (TransitionPosition > 0) 00279 { 00280 ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha); 00281 } 00282 00283 base.Draw(gameTime); 00284 }
| override void PendulumGame.PendulumGameOverScreen.LoadContent | ( | ) | [virtual] |
Loads graphics content for this screen. The background texture is quite big, so we use our own local ContentManager to load it. This allows us to unload before going from the menus into the game itself, wheras if we used the shared ContentManager provided by the Game class, the content would remain loaded forever.
Reimplemented from NewGamePhysics.StateManager.GameScreen.
Definition at line 87 of file PendulumGameOverScreen.cs.
00088 { 00089 if (content == null) 00090 { 00091 content = new ContentManager(ScreenManager.Game.Services, "Content"); 00092 } 00093 00094 frameTexture = content.Load<Texture2D>(@"Sprites\frame"); 00095 00096 // Pick random video 00097 int videoNumber = PendulumGame.State.PhysicalRandomNumberGenerator.Next(0, 12); 00098 00099 videoFile = content.Load<Video>(@"Videos\Pendulum" + videoNumber); 00100 effect = content.Load<Effect>(@"Effects\ColorChromaKey"); 00101 00102 // Determine chromakey reference color by averaging 00103 // the color over the reference image 00104 Texture2D backgroundReference = 00105 content.Load<Texture2D>(@"Textures\PendulumBackgroundReference"); 00106 Color[] colors = TextureHelpers.TextureToColors(backgroundReference); 00107 ulong rSum = 0; 00108 ulong gSum = 0; 00109 ulong bSum = 0; 00110 ulong num = (ulong)colors.Length; 00111 foreach (Color color in colors) 00112 { 00113 rSum += (ulong)color.R; 00114 gSum += (ulong)color.G; 00115 bSum += (ulong)color.B; 00116 } 00117 00118 this.referenceColor = new Color( 00119 (byte)(rSum / num), 00120 (byte)(gSum / num), 00121 (byte)(bSum / num)); 00122 }
| override void PendulumGame.PendulumGameOverScreen.UnloadContent | ( | ) | [virtual] |
Unloads graphics content for this screen.
Reimplemented from NewGamePhysics.StateManager.GameScreen.
Definition at line 127 of file PendulumGameOverScreen.cs.
| override void PendulumGame.PendulumGameOverScreen.Update | ( | GameTime | gameTime, | |
| bool | otherScreenHasFocus, | |||
| bool | coveredByOtherScreen | |||
| ) | [virtual] |
Updates the background screen. Unlike most screens, this should not transition off even if it has been covered by another screen: it is supposed to be covered, after all! This overload forces the coveredByOtherScreen parameter to false in order to stop the base Update method wanting to transition off.
Reimplemented from NewGamePhysics.StateManager.MenuScreen.
Definition at line 165 of file PendulumGameOverScreen.cs.
00167 { 00168 if (!videoStarted) 00169 { 00170 ScreenManager.VideoPlayer.Play(videoFile); 00171 videoStarted = true; 00172 } 00173 else 00174 { 00175 if (ScreenManager.VideoPlayer.State == MediaState.Stopped) 00176 { 00177 // Return to main menu 00178 PendulumLoadingScreen.Load(ScreenManager, false, null, new PendulumBackgroundScreen(), 00179 new PendulumMainMenuScreen()); 00180 } 00181 } 00182 00183 base.Update(gameTime, otherScreenHasFocus, false); 00184 }
1.6.2