# GravityChooser.GravityChooserGameplayScreen Class Reference

This screen implements the actual game logic for the gravity chooser. More...

Inheritance diagram for GravityChooser.GravityChooserGameplayScreen:

List of all members.

## Public Member Functions
| GravityChooserGameplayScreen ()
| 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 game. This method checks the GameScreen.IsActive property, so the game will stop updating when the pause menu is active, or if you tab away to a different application.
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 actual game logic for the gravity chooser.

Definition at line 23 of file GravityChooserGameplayScreen.cs.

## Constructor & Destructor Documentation

GravityChooser.GravityChooserGameplayScreen.GravityChooserGameplayScreen | ( |  | ) |

Constructor of the screen.

Definition at line 69 of file GravityChooserGameplayScreen.cs.

    00070         {
    00071             TransitionOnTime = TimeSpan.FromSeconds(1.5);
    00072             TransitionOffTime = TimeSpan.FromSeconds(0.5);
    00073         }

## Member Function Documentation

override void GravityChooser.GravityChooserGameplayScreen.Draw | ( | GameTime | gameTime | ) | `[virtual]`

Draws the gameplay screen.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 237 of file GravityChooserGameplayScreen.cs.

    00238         {
    00239             // Match transition to selector size
    00240             gravitySelector.DisplaySize = 1.0f - TransitionPosition;
    00241
    00242             // Draw gravity selector
    00243             gravitySelector.Draw(gameTime);
    00244
    00245             // If the game is transitioning on or off, fade it out to black.
    00246             if (TransitionPosition > 0)
    00247             {
    00248                 ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
    00249             }
    00250         }

override void GravityChooser.GravityChooserGameplayScreen.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 137 of file GravityChooserGameplayScreen.cs.

    00138         {
    00139             if (input == null)
    00140             {
    00141                 throw new ArgumentNullException("input");
    00142             }
    00143
    00144             // Look up inputs for the active player profile.
    00145             PlayerIndex playerIndex;
    00146             if (ControllingPlayer != null)
    00147             {
    00148                 playerIndex = ControllingPlayer.Value;
    00149             }
    00150             else
    00151             {
    00152                 playerIndex = 0;
    00153             }
    00154
    00155             KeyboardState keyboardState = input.CurrentKeyboardStates[(int)playerIndex];
    00156             GamePadState gamePadState = input.CurrentGamePadStates[(int)playerIndex];
    00157
    00158             // The game pauses either if the user presses the pause button, or if
    00159             // they unplug the active gamepad. This requires us to keep track of
    00160             // whether a gamepad was ever plugged in, because we don't want to pause
    00161             // on PC if they are playing with a keyboard and have no gamepad at all!
    00162             bool gamePadDisconnected = !gamePadState.IsConnected &&
    00163                                        input.GamePadWasConnected[(int)playerIndex];
    00164
    00165             if (input.IsInputCancel(ControllingPlayer) || gamePadDisconnected)
    00166             {
    00167                 ScreenManager.AddScreen(new GravityChooserPauseMenuScreen(), ControllingPlayer);
    00168             }
    00169             else
    00170             {
    00171                 if (input.IsInputSelect(ControllingPlayer))
    00172                 {
    00173                     // Capture selected value
    00174                     GravityChooser.state.CurrentGravity = gravitySelector.Gravity;
    00175
    00176                     // Quit to main menu
    00177                     GravityChooserLoadingScreen.Load(
    00178                         ScreenManager,
    00179                         false,
    00180                         null,
    00181                         new GravityChooserBackgroundScreen(),
    00182                         new GravityChooserMainMenuScreen());
    00183                 }
    00184
    00185                 // Keyboard speed adjustment
    00186                 if (input.IsInputLeft(null))
    00187                 {
    00188                     longitudeSpeed += speedStep;
    00189                 }
    00190                 else if (input.IsInputRight(null))
    00191
    00192                 {
    00193                     longitudeSpeed -= speedStep;
    00194                 }
    00195
    00196                 if (input.IsInputUp(null))
    00197                 {
    00198                     latitudeSpeed += speedStep;
    00199                 }
    00200                 else if (input.IsInputDown(null))
    00201                 {
    00202                     latitudeSpeed -= speedStep;
    00203                 }
    00204
    00205                 // Speed limiter
    00206                 if (longitudeSpeed < -speedMax)
    00207                 {
    00208                     longitudeSpeed = -speedMax;
    00209                 }
    00210                 else if (longitudeSpeed > speedMax)
    00211                 {
    00212                     longitudeSpeed = speedMax;
    00213                 }
    00214
    00215                 if (latitudeSpeed < -speedMax)
    00216                 {
    00217                     latitudeSpeed = -speedMax;
    00218                 }
    00219                 else if (latitudeSpeed > speedMax)
    00220                 {
    00221                     latitudeSpeed = speedMax;
    00222                 }
    00223
    00224                 // Update rotation
    00225                 gravitySelector.Longitude += longitudeSpeed;
    00226                 gravitySelector.Latitude += latitudeSpeed;
    00227
    00228                 // Drag speed
    00229                 longitudeSpeed *= speedDragFactor;
    00230                 latitudeSpeed *= speedDragFactor;
    00231             }
    00232         }

override void GravityChooser.GravityChooserGameplayScreen.LoadContent | ( |  | ) | `[virtual]`

Load graphics content for the game.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 78 of file GravityChooserGameplayScreen.cs.

    00079         {
    00080             if (this.contentManager == null)
    00081             {
    00082                 this.contentManager = new ContentManager(ScreenManager.Game.Services, "Content");
    00083             }
    00084
    00085             // Create physical element(s)
    00086             GravityCalculator gravityCalculator =
    00087                 new GravityCalculator(GravityChooser.state.CurrentCelestialObject);
    00088             if (GravityChooser.state.CurrentCelestialObject == CelestialObject.Earth)
    00089             {
    00090                 gravityCalculator.EarthGravityModel = GravityChooser.state.CurrentEarthGravityModel;
    00091             }
    00092
    00093             this.gravitySelector = new GravitySelector(
    00094                 ScreenManager,
    00095                 GravityChooser.state.CurrentCelestialObject,
    00096                 gravityCalculator);
    00097
    00098             // Reset game time
    00099             ScreenManager.Game.ResetElapsedTime();
    00100         }

override void GravityChooser.GravityChooserGameplayScreen.UnloadContent | ( |  | ) | `[virtual]`

Unload graphics content used by the game.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 106 of file GravityChooserGameplayScreen.cs.

    00107         {
    00108             this.contentManager.Unload();
    00109         }

override void GravityChooser.GravityChooserGameplayScreen.Update | ( | GameTime | gameTime,
|  | bool | otherScreenHasFocus,
|  | bool | coveredByOtherScreen |
| ) |  |  | `[virtual]`

Updates the state of the game. This method checks the GameScreen.IsActive property, so the game will stop updating when the pause menu is active, or if you tab away to a different application.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 120 of file GravityChooserGameplayScreen.cs.

    00122         {
    00123             base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
    00124
    00125             if (IsActive)
    00126             {
    00127                 // Animate gravity selector
    00128                 gravitySelector.Update(gameTime);
    00129             }
    00130         }

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

- C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/GravityChooser/Screens/GravityChooserGameplayScreen.cs