C# Class Platformer.Levels.Level

A uniform grid of tiles with collections of gems and enemies. The level owns the player and controls the game's win and lose conditions as well as scoring.
Inheritance: IDisposable
Show file Open project: zmthy/play-dead Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void
DrawBehind ( GameTime gameTime, SpriteBatch spriteBatch ) : void

Draw everything in the level from background to foreground.

DrawInFront ( GameTime gameTime, SpriteBatch spriteBatch ) : void
GetBounds ( int x, int y ) : RectangleF

Gets the bounding rectangle of a tile in world space.

GetCollision ( int x, int y ) : TileCollision

Gets the collision mode of the tile at a particular location. This method handles tiles outside of the levels boundries by making it impossible to escape past the left or right edges, but allowing things to jump beyond the top of the level and fall off the bottom.

GetTileCollisionBehindPlayer ( Vector2 playerPosition ) : TileCollision
GetTileCollisionBelowPlayer ( Vector2 playerPosition ) : TileCollision
Level ( String name, int width, int height, Microsoft.Xna.Framework.Content.ContentManager content ) : System
LoadContent ( ) : void
Update ( Player player, GameTime gameTime, KeyboardState keyboardState, InputManager inputManager ) : void

Updates all objects in the world, performs collision between them, and handles the time limit with scoring.

UpdateSpawn ( Spawner spawner ) : void

Called by a Spawner when it has been activated.

activate ( string active ) : void

Activates a particular activatable.

addActivatable ( string tileID, IActivatable active ) : void

Adds and activatable item to the activatables list.

addActivator ( string tileID, Tiles actor ) : void

Adds an activator into the activators list.

addBind ( string actorName, string activeName ) : void

Binds and activator to a particular activatable.

addMoveable ( string tileID, MoveableTile mTile ) : void

Adds a moveable tile to the level. If the ID of the tile already exists then the tile is linked to the exiting tile as its leader.

addTile ( int x, int y ) : void

Adds an empty passable tile into the tile array.

addTile ( int x, int y, Tile newTile ) : void

Adds a tile into the tile array.

getGridPosition ( float x, float y ) : Vector2
getTile ( int x, int y ) : Tile
isTileInBounds ( int x, int y ) : bool

Method Details

Dispose() public method

public Dispose ( ) : void
return void

DrawBehind() public method

Draw everything in the level from background to foreground.
public DrawBehind ( GameTime gameTime, SpriteBatch spriteBatch ) : void
gameTime Microsoft.Xna.Framework.GameTime
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
return void

DrawInFront() public method

public DrawInFront ( GameTime gameTime, SpriteBatch spriteBatch ) : void
gameTime Microsoft.Xna.Framework.GameTime
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
return void

GetBounds() public method

Gets the bounding rectangle of a tile in world space.
public GetBounds ( int x, int y ) : RectangleF
x int
y int
return RectangleF

GetCollision() public method

Gets the collision mode of the tile at a particular location. This method handles tiles outside of the levels boundries by making it impossible to escape past the left or right edges, but allowing things to jump beyond the top of the level and fall off the bottom.
public GetCollision ( int x, int y ) : TileCollision
x int
y int
return TileCollision

GetTileCollisionBehindPlayer() public method

public GetTileCollisionBehindPlayer ( Vector2 playerPosition ) : TileCollision
playerPosition Vector2
return TileCollision

GetTileCollisionBelowPlayer() public method

public GetTileCollisionBelowPlayer ( Vector2 playerPosition ) : TileCollision
playerPosition Vector2
return TileCollision

Level() public method

public Level ( String name, int width, int height, Microsoft.Xna.Framework.Content.ContentManager content ) : System
name String
width int
height int
content Microsoft.Xna.Framework.Content.ContentManager
return System

LoadContent() public method

public LoadContent ( ) : void
return void

Update() public method

Updates all objects in the world, performs collision between them, and handles the time limit with scoring.
public Update ( Player player, GameTime gameTime, KeyboardState keyboardState, InputManager inputManager ) : void
player Player
gameTime Microsoft.Xna.Framework.GameTime
keyboardState Microsoft.Xna.Framework.Input.KeyboardState
inputManager InputManager
return void

UpdateSpawn() public method

Called by a Spawner when it has been activated.
public UpdateSpawn ( Spawner spawner ) : void
spawner Platformer.Tiles.Spawner The spawner to set as the active spawn point.
return void

activate() public method

Activates a particular activatable.
public activate ( string active ) : void
active string The ID of the activatable.
return void

addActivatable() public method

Adds and activatable item to the activatables list.
public addActivatable ( string tileID, IActivatable active ) : void
tileID string The ID of the tilwe.
active IActivatable The activatable instance.
return void

addActivator() public method

Adds an activator into the activators list.
public addActivator ( string tileID, Tiles actor ) : void
tileID string The ID of the tile.
actor Tiles The activator instance.
return void

addBind() public method

Binds and activator to a particular activatable.
public addBind ( string actorName, string activeName ) : void
actorName string The activator which will trigger.
activeName string The activatable which will be activated.
return void

addMoveable() public method

Adds a moveable tile to the level. If the ID of the tile already exists then the tile is linked to the exiting tile as its leader.
public addMoveable ( string tileID, MoveableTile mTile ) : void
tileID string The ID of the tile.
mTile Platformer.Tiles.MoveableTile The moveable tile instance.
return void

addTile() public method

Adds an empty passable tile into the tile array.
public addTile ( int x, int y ) : void
x int
y int
return void

addTile() public method

Adds a tile into the tile array.
public addTile ( int x, int y, Tile newTile ) : void
x int
y int
newTile Platformer.Tiles.Tile
return void

getGridPosition() public method

public getGridPosition ( float x, float y ) : Vector2
x float
y float
return Vector2

getTile() public method

public getTile ( int x, int y ) : Tile
x int
y int
return Platformer.Tiles.Tile

isTileInBounds() public method

public isTileInBounds ( int x, int y ) : bool
x int
y int
return bool