C# Class MrGravity.WorldSelect

Level selection menu that allows you to pick the level to start
Show file Open project: DizWARE/Mr-Gravity Class Usage Examples

Public Properties

Property Type Description
LevelDirectory string

Public Methods

Method Description
CheckForSave ( ) : bool

Checks if a save file for the game already exists - and loads it if so. Meant to be used solely on XBOX360. Should be used as soon as we know what PlayerIndex the "gamer" is using (IE right after the title screen). Note: if a save game does not exist the constructor for this class should have filled in the default values (0 stars, all but the first locked - on xbox our default xml file should always have the default values - we cannot save information to that file as it is a binary xnb file that can't be changed at run time) Do not call this until we know the PlayerIndex the player is using!

Draw ( SpriteBatch spriteBatch, Matrix scale ) : void

Draws the menu on the screen

GetLevelCollect ( ) : int
GetLevelDeath ( ) : int
GetLevelTime ( ) : int
Load ( Microsoft.Xna.Framework.Content.ContentManager content ) : void

Loads all the content needed for the levels

Reset ( ) : void

Resets the world system

Save ( ) : void

Saves level unlock and scoring information PC saving is straightforward - but xDoc.Save() will not work on xbox360. Instead we use the built in XmlSerializer class to serialize an element out to an xml file. We build our Xelement like normal - but instead of saving that directly using XDocument.Save() we place this XElement into a struct, and use XmlSerializer to serialize the data out into a storage device on the xbox.

UnlockWorld ( int world ) : void

Unlocks the given world

Update ( GameTime gameTime, GameStates &gameState, Level &currentLevel ) : void

Handle any changes while on the level selection menu

UpdateStarCount ( ) : void

Updates the star count.

WorldSelect ( IControlScheme controlScheme, GraphicsDeviceManager graphics ) : System

Constructs the menu screen that allows the player to select a level

Private Methods

Method Description
CreateRegions ( ) : void

Creates all the regions for the level editor for easy placement within the Title Safe area

DrawInfoBar ( SpriteBatch spriteBatch, int shiftValue ) : void

Draw info bar on the right

DrawLevelPanel ( SpriteBatch spriteBatch ) : void

Draws the levels in each of its panels

DrawTitleBar ( SpriteBatch spriteBatch ) : void

Draw the title bar to the screen

Exit ( GameStates &gameState ) : void

Exits the level selection

HandleAKey ( GameStates &gameState, Level &currentLevel ) : void

Handles when the A key is pressed

HandleBKey ( GameStates &gameState ) : void

Handles when user presses the back key

HandleDirectionKey ( ) : void

Handles the directional keys

SelectDevice ( IAsyncResult result ) : void

Method Details

CheckForSave() public method

Checks if a save file for the game already exists - and loads it if so. Meant to be used solely on XBOX360. Should be used as soon as we know what PlayerIndex the "gamer" is using (IE right after the title screen). Note: if a save game does not exist the constructor for this class should have filled in the default values (0 stars, all but the first locked - on xbox our default xml file should always have the default values - we cannot save information to that file as it is a binary xnb file that can't be changed at run time) Do not call this until we know the PlayerIndex the player is using!
public CheckForSave ( ) : bool
return bool

Draw() public method

Draws the menu on the screen
public Draw ( SpriteBatch spriteBatch, Matrix scale ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch Canvas we are drawing to
scale Matrix
return void

GetLevelCollect() public method

public GetLevelCollect ( ) : int
return int

GetLevelDeath() public method

public GetLevelDeath ( ) : int
return int

GetLevelTime() public method

public GetLevelTime ( ) : int
return int

Load() public method

Loads all the content needed for the levels
public Load ( Microsoft.Xna.Framework.Content.ContentManager content ) : void
content Microsoft.Xna.Framework.Content.ContentManager
return void

Reset() public method

Resets the world system
public Reset ( ) : void
return void

Save() public method

Saves level unlock and scoring information PC saving is straightforward - but xDoc.Save() will not work on xbox360. Instead we use the built in XmlSerializer class to serialize an element out to an xml file. We build our Xelement like normal - but instead of saving that directly using XDocument.Save() we place this XElement into a struct, and use XmlSerializer to serialize the data out into a storage device on the xbox.
public Save ( ) : void
return void

UnlockWorld() public method

Unlocks the given world
public UnlockWorld ( int world ) : void
world int The world.
return void

Update() public method

Handle any changes while on the level selection menu
public Update ( GameTime gameTime, GameStates &gameState, Level &currentLevel ) : void
gameTime Microsoft.Xna.Framework.GameTime Current time within the game
gameState GameStates Current gamestate of the game
currentLevel Level Current level of the game
return void

UpdateStarCount() public method

Updates the star count.
public UpdateStarCount ( ) : void
return void

WorldSelect() public method

Constructs the menu screen that allows the player to select a level
public WorldSelect ( IControlScheme controlScheme, GraphicsDeviceManager graphics ) : System
controlScheme IControlScheme Controls that the player are using
graphics GraphicsDeviceManager
return System

Property Details

LevelDirectory public static property

public static string LevelDirectory
return string