C# Class Bricklayer.Client.Entities.Player

Represents a player/smiley in the game map
Inheritance: Common.Entities.Player
Exibir arquivo Open project: Cyral/Bricklayer Class Usage Examples

Public Properties

Property Type Description
LastColors float>.Dictionary

Public Methods

Method Description
Draw ( SpriteBatch spriteBatch, GameTime gameTime ) : void
Player ( Map map, Vector2 position, string name, int id ) : System
TileIntersectsPlayer ( Rectangle player, Rectangle block, CollisionDirection direction, Vector2 &depth ) : bool

Checks for tile intersections/collision depth between a player and a tile

Update ( GameTime gameTime ) : void

Updates the player physics, states, etc

Protected Methods

Method Description
DoJump ( float velocityY, GameTime gameTime ) : float

Calculates the Y velocity accounting for jumping and animates accordingly.

During the accent of a jump, the Y velocity is completely overridden by a power curve. During the decent, gravity takes over. The jump velocity is controlled by the jumpTime field which measures time into the accent of the current jump.

HandleCollisions ( CollisionDirection direction, GameTime gameTime ) : void

Detects and resolves all collisions between the player and his neighboring tiles. When a collision is detected, the player is pushed away along one axis to prevent overlapping. There is some special logic for the Y axis to handle platforms which behave differently depending on direction of movement.

Private Methods

Method Description
ApplyPhysics ( GameTime gameTime ) : void

Apply client-side physics to the character, calculate velocity from movement and gravity, handle collisions

DrawTag ( SpriteBatch spriteBatch, float elapsed ) : void

Draws the players username above them

HandleCollisions ( GameTime gameTime, CollisionDirection direction, BlockCollision collision, Rectangle tileBounds, Vector2 depth, bool intersects, int x, int y ) : bool

Handles collisions for a given block

HandleInput ( ) : bool

Handles movement of the character (Jumping, Moving, etc)

HorizontalCollision ( GameTime gameTime, float elapsed ) : void
Interpolate ( GameTime gameTime ) : void
VerticalCollision ( GameTime gameTime, float elapsed ) : void

Method Details

DoJump() protected method

Calculates the Y velocity accounting for jumping and animates accordingly.
During the accent of a jump, the Y velocity is completely overridden by a power curve. During the decent, gravity takes over. The jump velocity is controlled by the jumpTime field which measures time into the accent of the current jump.
protected DoJump ( float velocityY, GameTime gameTime ) : float
velocityY float /// The player's current velocity along the Y axis. ///
gameTime Microsoft.Xna.Framework.GameTime
return float

Draw() public method

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

HandleCollisions() protected method

Detects and resolves all collisions between the player and his neighboring tiles. When a collision is detected, the player is pushed away along one axis to prevent overlapping. There is some special logic for the Y axis to handle platforms which behave differently depending on direction of movement.
protected HandleCollisions ( CollisionDirection direction, GameTime gameTime ) : void
direction CollisionDirection
gameTime Microsoft.Xna.Framework.GameTime
return void

Player() public method

public Player ( Map map, Vector2 position, string name, int id ) : System
map Bricklayer.Client.World.Map
position Vector2
name string
id int
return System

TileIntersectsPlayer() public static method

Checks for tile intersections/collision depth between a player and a tile
public static TileIntersectsPlayer ( Rectangle player, Rectangle block, CollisionDirection direction, Vector2 &depth ) : bool
player Microsoft.Xna.Framework.Rectangle A player's bounding rectangle
block Microsoft.Xna.Framework.Rectangle A block's brounding rectangle
direction CollisionDirection Collision direction
depth Vector2 Returned depth of the collision
return bool

Update() public method

Updates the player physics, states, etc
public Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
return void

Property Details

LastColors public_oe property

Collection of the last positions the player was, for creating a fade effect on the minimap
public Dictionary LastColors
return float>.Dictionary