C# Class SGDE.Physics.Collision.CollisionChief

The central class to compare collisions and determine if they actually collide or not.
Mostrar archivo Open project: sgdc/sgdc-old Class Usage Examples

Public Methods

Method Description
AddCollisionUnit ( CollisionUnit unit ) : void

Add a new CollisionUnit to the CollisionChief.

DrawCollisionGrid ( SpriteBatch spriteBatch, Microsoft.Xna.Framework.Graphics.Texture2D gridTexture ) : void

Helper function for debugging. Draws the collision units in the location of a collision cell on the collision grid.

GetInstance ( ) : CollisionChief

Get the CollisionChief singleton.

Initialize ( Vector2 worldSize, Vector2 cellSize ) : void

Initialize the CollisionChief.

RemoveCollisionUnit ( CollisionUnit unit ) : void

Remove a CollisionUnit from the CollisionChief.

RotateCollisionUnit ( CollisionUnit unit, float rotation ) : void

Rotate a CollisionUnit by the given amount.

ScaleCollisionUnit ( CollisionUnit unit, Vector2 scale ) : void

Scale a CollisionUnit by the given amount.

TranslateCollisionUnit ( CollisionUnit unit, Vector2 translation ) : void

Translate a CollisionUnit by the given amount.

Update ( ) : void

Update the CollisionChief.

UpdateUnit ( CollisionUnit unit ) : void

Add a specific CollisionUnit to a queue of units to update.

Private Methods

Method Description
CalculateCellPosition ( Vector2 position ) : Point
CalculateCircleBottomRightCell ( Vector2 circleCenter, int circleRadius ) : Point
CalculateCircleTopLeftCell ( Vector2 circleCenter, int circleRadius ) : Point
CollisionChief ( ) : System
NotifyEntities ( List entities ) : void
UpdateCollisions ( List entities ) : void

Method Details

AddCollisionUnit() public method

Add a new CollisionUnit to the CollisionChief.
public AddCollisionUnit ( CollisionUnit unit ) : void
unit CollisionUnit The CollisionUnit to add to the CollisionChief.
return void

DrawCollisionGrid() public method

Helper function for debugging. Draws the collision units in the location of a collision cell on the collision grid.
public DrawCollisionGrid ( SpriteBatch spriteBatch, Microsoft.Xna.Framework.Graphics.Texture2D gridTexture ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch The SpriteBatch used to draw the grid.
gridTexture Microsoft.Xna.Framework.Graphics.Texture2D A texture representing one cell in the collision grid.
return void

GetInstance() public static method

Get the CollisionChief singleton.
public static GetInstance ( ) : CollisionChief
return CollisionChief

Initialize() public method

Initialize the CollisionChief.
public Initialize ( Vector2 worldSize, Vector2 cellSize ) : void
worldSize Vector2 The size, in pixels, of the map. This defines the size of the collision grid.
cellSize Vector2 The size, in pixels, of a single cell in the collision grid.
return void

RemoveCollisionUnit() public method

Remove a CollisionUnit from the CollisionChief.
public RemoveCollisionUnit ( CollisionUnit unit ) : void
unit CollisionUnit The CollisionUnit to remove.
return void

RotateCollisionUnit() public method

Rotate a CollisionUnit by the given amount.
public RotateCollisionUnit ( CollisionUnit unit, float rotation ) : void
unit CollisionUnit The CollisionUnit to rotate.
rotation float The delta rotation to perform on the CollisionUnit (in radians).
return void

ScaleCollisionUnit() public method

Scale a CollisionUnit by the given amount.
public ScaleCollisionUnit ( CollisionUnit unit, Vector2 scale ) : void
unit CollisionUnit The CollisionUnit to scale.
scale Vector2 The delta scale to perform on the CollisionUnit.
return void

TranslateCollisionUnit() public method

Translate a CollisionUnit by the given amount.
public TranslateCollisionUnit ( CollisionUnit unit, Vector2 translation ) : void
unit CollisionUnit The CollisionUnit to translate.
translation Vector2 The delta translation to perform on the CollisionUnit.
return void

Update() public method

Update the CollisionChief.
public Update ( ) : void
return void

UpdateUnit() public method

Add a specific CollisionUnit to a queue of units to update.
public UpdateUnit ( CollisionUnit unit ) : void
unit CollisionUnit The CollisionUnit to get updated.
return void