C# Class SGDE.Physics.Collision.CollisionUnit

Defines the collision properties and methods to check collisions for an Entity.
Inheritance: SceneNode
Afficher le fichier Open project: sgdc/sgdc-old Class Usage Examples

Méthodes publiques

Méthode Description
AddCollision ( CollisionUnit other ) : void

Add a collision to with another unit.

ClearCheckedUnits ( ) : void

Clear the list of checked units.

ClearCollisions ( ) : void

Clear any collisions, whether they occured or not.

CollidesWith ( CollisionUnit other ) : bool

Determine if this CollisionUnit collides with another.

CollisionUnit ( System.Entity owner, Vector2 location, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System

Instantiate a new CollisionUnit. This constructor is for circle based collisions.

CollisionUnit ( System.Entity owner, Vector2 point1, Vector2 point2, CollisionType collisionType, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System

Instantiate a new CollisionUnit. This constructor is for line and box based collisions.

CollisionUnit ( System.Entity owner, Vector2 center, int radius, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System

Instantiate a new CollisionUnit. This constructor is for circle based collisions.

CollisionsChanged ( int timeStamp ) : bool

Get if collisions changed since the last time checked.

CollisionsChanged ( bool bChanged ) : void

Set if collisions changed on this unit.

GetCheckTimeStamp ( ) : int

Get the last time that the collision unit was checked.

GetCheckedUnits ( ) : List

Get the last CollisionUnits that this collision unit was checked with.

GetCircleCenter ( ) : Vector2

For circle based collisions, get the circle center.

GetCircleRadius ( ) : int

For circle based collisions, get the circle radius.

GetCollisionPoint ( CollisionUnit other ) : Vector2

Get the point of collision with the other CollisionUnit. This does not do any real collision checks so the returned value might not be the actual collision point.

GetCollisionType ( ) : CollisionType

Get the CollisionUnit type.

GetCollisions ( ) : List

Get a list of all collisions.

GetFullCheckTimeStamp ( ) : int

Get the last time the collision unit was updated.

GetHeight ( ) : int

For box based collisions, get the height of the box. For circle based collisions, get the circle diameter.

GetLastCheckedBy ( ) : CollisionUnit

Get the last collision unit that was checked with this collision unit.

GetLineEnd ( ) : Vector2

For line based collisions, get the line end.

GetLineStart ( ) : Vector2

For line based collisions, get the line start.

GetLowerRight ( ) : Vector2

For box based collisions, get the lower-right corner of the box. For circle based collisions, get the lower-right bound of the circle.

GetOwner ( ) : System.Entity

Get the "owner" Entity of this CollisionUnit.

GetUpperLeft ( ) : Vector2

For box based collisions, get the upper-left corner of the box. For circle based collisions, get the upper-left bound of the circle.

GetWidth ( ) : int

For box based collisions, get the width of the box. For circle based collisions, get the circle diameter.

HasCollisions ( ) : bool

Get if the CollisionUnit has collisions.

IsSolid ( ) : bool

Get if the collision unit is solid.

NeedsCollisionUpdate ( ) : bool

Get if the CollisionUnit needs to be updated.

NeedsCollisionUpdate ( bool needsUpdate ) : void

Set if the CollisionUnit needs to be updated.

RemoveCollision ( CollisionUnit other ) : void

Remove a collision with another unit.

Rotate ( float rotation ) : void

Rotate the CollisionUnit a specified amount.

Scale ( Vector2 scale ) : void

Scale the CollisionUnit a specified amount.

SetCheckTimeStamp ( int timeStamp ) : void

Set the last time the collision unit was checked.

SetFullCheckTimeStamp ( int timeStamp ) : void

Set the last time the collision unit was updated.

SetLastCheckedBy ( CollisionUnit unit ) : void

Set the last collision unit to be checked with this collision unit.

SetSolid ( bool blockOthers ) : void

Set if the collision unit is solid.

Translate ( Vector2 translation ) : void

Translate the CollisionUnit a specified amount.

UpdateCollisionsWith ( CollisionUnit other ) : void

Update the collision status between this and the other CollisionUnit.

UsesPixelCollision ( ) : bool

Get is pixel-perfect collisions are enabled.

Private Methods

Méthode Description
CalculateCircle ( Vector2 location ) : void
CircleBoxCollision ( Vector2 circleCenter, int circleRadius, Vector2 boxUpperLeft, Vector2 boxLowerRight ) : bool
InitializeCommonStuff ( System.Entity owner, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : void

Method Details

AddCollision() public méthode

Add a collision to with another unit.
public AddCollision ( CollisionUnit other ) : void
other CollisionUnit The CollisionUnit that was collided with.
Résultat void

ClearCheckedUnits() public méthode

Clear the list of checked units.
public ClearCheckedUnits ( ) : void
Résultat void

ClearCollisions() public méthode

Clear any collisions, whether they occured or not.
public ClearCollisions ( ) : void
Résultat void

CollidesWith() public méthode

Determine if this CollisionUnit collides with another.
public CollidesWith ( CollisionUnit other ) : bool
other CollisionUnit The CollisionUnit to check for collision.
Résultat bool

CollisionUnit() public méthode

Instantiate a new CollisionUnit. This constructor is for circle based collisions.
public CollisionUnit ( System.Entity owner, Vector2 location, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System
owner System.Entity The "owner" Entity that this CollisionUnit will be for.
location Vector2 The top-left corner of the .
collisionMask Microsoft.Xna.Framework.Graphics.Texture2D Collision mask for the object.
bUsePixelCollision bool Is pixel-perfect collisions should be used.
Résultat System

CollisionUnit() public méthode

Instantiate a new CollisionUnit. This constructor is for line and box based collisions.
public CollisionUnit ( System.Entity owner, Vector2 point1, Vector2 point2, CollisionType collisionType, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System
owner System.Entity The "owner" Entity that this COllisionUnit will be for.
point1 Vector2 A point on the line or a corner of the box. For line, this is the start. For box, this is the upper-left corner.
point2 Vector2 A point on the line or a corner of the box. For line, this is the end. For box, this is the lower-right corner.
collisionType CollisionType /// The collision type to use. The only accepted value is , which makes this a line based collision unit. All other values default to box based collision. ///
collisionMask Microsoft.Xna.Framework.Graphics.Texture2D Collision mask for the object.
bUsePixelCollision bool Is pixel-perfect collisions should be used.
Résultat System

CollisionUnit() public méthode

Instantiate a new CollisionUnit. This constructor is for circle based collisions.
public CollisionUnit ( System.Entity owner, Vector2 center, int radius, Microsoft.Xna.Framework.Graphics.Texture2D collisionMask, bool bUsePixelCollision ) : System
owner System.Entity The "owner" Entity that this CollisionUnit will be for.
center Vector2 The location of the circle center.
radius int The radius of the circle.
collisionMask Microsoft.Xna.Framework.Graphics.Texture2D Collision mask for the object.
bUsePixelCollision bool Is pixel-perfect collisions should be used.
Résultat System

CollisionsChanged() public méthode

Get if collisions changed since the last time checked.
public CollisionsChanged ( int timeStamp ) : bool
timeStamp int The current timestamp.
Résultat bool

CollisionsChanged() public méthode

Set if collisions changed on this unit.
public CollisionsChanged ( bool bChanged ) : void
bChanged bool true if the collisions changed, false if otherwise.
Résultat void

GetCheckTimeStamp() public méthode

Get the last time that the collision unit was checked.
public GetCheckTimeStamp ( ) : int
Résultat int

GetCheckedUnits() public méthode

Get the last CollisionUnits that this collision unit was checked with.
public GetCheckedUnits ( ) : List
Résultat List

GetCircleCenter() public méthode

For circle based collisions, get the circle center.
public GetCircleCenter ( ) : Vector2
Résultat Vector2

GetCircleRadius() public méthode

For circle based collisions, get the circle radius.
public GetCircleRadius ( ) : int
Résultat int

GetCollisionPoint() public méthode

Get the point of collision with the other CollisionUnit. This does not do any real collision checks so the returned value might not be the actual collision point.
public GetCollisionPoint ( CollisionUnit other ) : Vector2
other CollisionUnit The CollisionUnit to get the collision point from.
Résultat Vector2

GetCollisionType() public méthode

Get the CollisionUnit type.
public GetCollisionType ( ) : CollisionType
Résultat CollisionType

GetCollisions() public méthode

Get a list of all collisions.
public GetCollisions ( ) : List
Résultat List

GetFullCheckTimeStamp() public méthode

Get the last time the collision unit was updated.
public GetFullCheckTimeStamp ( ) : int
Résultat int

GetHeight() public méthode

For box based collisions, get the height of the box. For circle based collisions, get the circle diameter.
public GetHeight ( ) : int
Résultat int

GetLastCheckedBy() public méthode

Get the last collision unit that was checked with this collision unit.
public GetLastCheckedBy ( ) : CollisionUnit
Résultat CollisionUnit

GetLineEnd() public méthode

For line based collisions, get the line end.
public GetLineEnd ( ) : Vector2
Résultat Vector2

GetLineStart() public méthode

For line based collisions, get the line start.
public GetLineStart ( ) : Vector2
Résultat Vector2

GetLowerRight() public méthode

For box based collisions, get the lower-right corner of the box. For circle based collisions, get the lower-right bound of the circle.
public GetLowerRight ( ) : Vector2
Résultat Vector2

GetOwner() public méthode

Get the "owner" Entity of this CollisionUnit.
public GetOwner ( ) : System.Entity
Résultat System.Entity

GetUpperLeft() public méthode

For box based collisions, get the upper-left corner of the box. For circle based collisions, get the upper-left bound of the circle.
public GetUpperLeft ( ) : Vector2
Résultat Vector2

GetWidth() public méthode

For box based collisions, get the width of the box. For circle based collisions, get the circle diameter.
public GetWidth ( ) : int
Résultat int

HasCollisions() public méthode

Get if the CollisionUnit has collisions.
public HasCollisions ( ) : bool
Résultat bool

IsSolid() public méthode

Get if the collision unit is solid.
public IsSolid ( ) : bool
Résultat bool

NeedsCollisionUpdate() public méthode

Get if the CollisionUnit needs to be updated.
public NeedsCollisionUpdate ( ) : bool
Résultat bool

NeedsCollisionUpdate() public méthode

Set if the CollisionUnit needs to be updated.
public NeedsCollisionUpdate ( bool needsUpdate ) : void
needsUpdate bool true if the unit needs to be updated, false if otherwise.
Résultat void

RemoveCollision() public méthode

Remove a collision with another unit.
public RemoveCollision ( CollisionUnit other ) : void
other CollisionUnit The CollisionUnit to remove the collision from.
Résultat void

Rotate() public méthode

Rotate the CollisionUnit a specified amount.
public Rotate ( float rotation ) : void
rotation float The delta rotation of the CollisionUnit, in radians.
Résultat void

Scale() public méthode

Scale the CollisionUnit a specified amount.
public Scale ( Vector2 scale ) : void
scale Vector2 The delta scale of the CollisionUnit.
Résultat void

SetCheckTimeStamp() public méthode

Set the last time the collision unit was checked.
public SetCheckTimeStamp ( int timeStamp ) : void
timeStamp int The last time the collision unit was checked.
Résultat void

SetFullCheckTimeStamp() public méthode

Set the last time the collision unit was updated.
public SetFullCheckTimeStamp ( int timeStamp ) : void
timeStamp int The last time the collision unit was updated.
Résultat void

SetLastCheckedBy() public méthode

Set the last collision unit to be checked with this collision unit.
public SetLastCheckedBy ( CollisionUnit unit ) : void
unit CollisionUnit The last checked collision unit.
Résultat void

SetSolid() public méthode

Set if the collision unit is solid.
public SetSolid ( bool blockOthers ) : void
blockOthers bool true if the collision unit is solid, false if otherwise.
Résultat void

Translate() public méthode

Translate the CollisionUnit a specified amount.
public Translate ( Vector2 translation ) : void
translation Vector2 The delta translation to move the unit.
Résultat void

UpdateCollisionsWith() public méthode

Update the collision status between this and the other CollisionUnit.
public UpdateCollisionsWith ( CollisionUnit other ) : void
other CollisionUnit The CollisionUnit to update.
Résultat void

UsesPixelCollision() public méthode

Get is pixel-perfect collisions are enabled.
public UsesPixelCollision ( ) : bool
Résultat bool