C# Класс SGDE.Physics.Collision.CollisionUnit

Defines the collision properties and methods to check collisions for an Entity.
Наследование: SceneNode
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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

Описание методов

AddCollision() публичный Метод

Add a collision to with another unit.
public AddCollision ( CollisionUnit other ) : void
other CollisionUnit The CollisionUnit that was collided with.
Результат void

ClearCheckedUnits() публичный Метод

Clear the list of checked units.
public ClearCheckedUnits ( ) : void
Результат void

ClearCollisions() публичный Метод

Clear any collisions, whether they occured or not.
public ClearCollisions ( ) : void
Результат void

CollidesWith() публичный Метод

Determine if this CollisionUnit collides with another.
public CollidesWith ( CollisionUnit other ) : bool
other CollisionUnit The CollisionUnit to check for collision.
Результат bool

CollisionUnit() публичный Метод

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.
Результат System

CollisionUnit() публичный Метод

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.
Результат System

CollisionUnit() публичный Метод

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.
Результат System

CollisionsChanged() публичный Метод

Get if collisions changed since the last time checked.
public CollisionsChanged ( int timeStamp ) : bool
timeStamp int The current timestamp.
Результат bool

CollisionsChanged() публичный Метод

Set if collisions changed on this unit.
public CollisionsChanged ( bool bChanged ) : void
bChanged bool true if the collisions changed, false if otherwise.
Результат void

GetCheckTimeStamp() публичный Метод

Get the last time that the collision unit was checked.
public GetCheckTimeStamp ( ) : int
Результат int

GetCheckedUnits() публичный Метод

Get the last CollisionUnits that this collision unit was checked with.
public GetCheckedUnits ( ) : List
Результат List

GetCircleCenter() публичный Метод

For circle based collisions, get the circle center.
public GetCircleCenter ( ) : Vector2
Результат Vector2

GetCircleRadius() публичный Метод

For circle based collisions, get the circle radius.
public GetCircleRadius ( ) : int
Результат int

GetCollisionPoint() публичный Метод

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.
Результат Vector2

GetCollisionType() публичный Метод

Get the CollisionUnit type.
public GetCollisionType ( ) : CollisionType
Результат CollisionType

GetCollisions() публичный Метод

Get a list of all collisions.
public GetCollisions ( ) : List
Результат List

GetFullCheckTimeStamp() публичный Метод

Get the last time the collision unit was updated.
public GetFullCheckTimeStamp ( ) : int
Результат int

GetHeight() публичный Метод

For box based collisions, get the height of the box. For circle based collisions, get the circle diameter.
public GetHeight ( ) : int
Результат int

GetLastCheckedBy() публичный Метод

Get the last collision unit that was checked with this collision unit.
public GetLastCheckedBy ( ) : CollisionUnit
Результат CollisionUnit

GetLineEnd() публичный Метод

For line based collisions, get the line end.
public GetLineEnd ( ) : Vector2
Результат Vector2

GetLineStart() публичный Метод

For line based collisions, get the line start.
public GetLineStart ( ) : Vector2
Результат Vector2

GetLowerRight() публичный Метод

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
Результат Vector2

GetOwner() публичный Метод

Get the "owner" Entity of this CollisionUnit.
public GetOwner ( ) : System.Entity
Результат System.Entity

GetUpperLeft() публичный Метод

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
Результат Vector2

GetWidth() публичный Метод

For box based collisions, get the width of the box. For circle based collisions, get the circle diameter.
public GetWidth ( ) : int
Результат int

HasCollisions() публичный Метод

Get if the CollisionUnit has collisions.
public HasCollisions ( ) : bool
Результат bool

IsSolid() публичный Метод

Get if the collision unit is solid.
public IsSolid ( ) : bool
Результат bool

NeedsCollisionUpdate() публичный Метод

Get if the CollisionUnit needs to be updated.
public NeedsCollisionUpdate ( ) : bool
Результат bool

NeedsCollisionUpdate() публичный Метод

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.
Результат void

RemoveCollision() публичный Метод

Remove a collision with another unit.
public RemoveCollision ( CollisionUnit other ) : void
other CollisionUnit The CollisionUnit to remove the collision from.
Результат void

Rotate() публичный Метод

Rotate the CollisionUnit a specified amount.
public Rotate ( float rotation ) : void
rotation float The delta rotation of the CollisionUnit, in radians.
Результат void

Scale() публичный Метод

Scale the CollisionUnit a specified amount.
public Scale ( Vector2 scale ) : void
scale Vector2 The delta scale of the CollisionUnit.
Результат void

SetCheckTimeStamp() публичный Метод

Set the last time the collision unit was checked.
public SetCheckTimeStamp ( int timeStamp ) : void
timeStamp int The last time the collision unit was checked.
Результат void

SetFullCheckTimeStamp() публичный Метод

Set the last time the collision unit was updated.
public SetFullCheckTimeStamp ( int timeStamp ) : void
timeStamp int The last time the collision unit was updated.
Результат void

SetLastCheckedBy() публичный Метод

Set the last collision unit to be checked with this collision unit.
public SetLastCheckedBy ( CollisionUnit unit ) : void
unit CollisionUnit The last checked collision unit.
Результат void

SetSolid() публичный Метод

Set if the collision unit is solid.
public SetSolid ( bool blockOthers ) : void
blockOthers bool true if the collision unit is solid, false if otherwise.
Результат void

Translate() публичный Метод

Translate the CollisionUnit a specified amount.
public Translate ( Vector2 translation ) : void
translation Vector2 The delta translation to move the unit.
Результат void

UpdateCollisionsWith() публичный Метод

Update the collision status between this and the other CollisionUnit.
public UpdateCollisionsWith ( CollisionUnit other ) : void
other CollisionUnit The CollisionUnit to update.
Результат void

UsesPixelCollision() публичный Метод

Get is pixel-perfect collisions are enabled.
public UsesPixelCollision ( ) : bool
Результат bool