Otter  0.9.8.91
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.GridCollider Class Reference

Grid Collider. Can be mainly used to create collision to correspond to a Tilemap. More...

Inherits Otter.Collider.

Public Member Functions

int GridX (float x)
 Convert an X position to a tile on the grid. More...
 
int GridY (float y)
 Convert an Y position to a tile on the grid. More...
 
 GridCollider (int width, int height, int tileWidth, int tileHeight, params int[] tags)
 Create a new GridCollider. More...
 
 GridCollider (int width, int height, int tileWidth, int tileHeight, Enum tag, params Enum[] tags)
 
void SetTile (int x, int y, bool collidable=true)
 Set the collision status of a tile on the GridCollider. More...
 
void SetRect (int x, int y, int width, int height, bool collidable=true)
 Set the collision status of a rectangle area on the GridCollider. More...
 
void Clear (bool collidable=false)
 Clears the entire grid. More...
 
bool GetTile (int x, int y)
 Get the collision status of a tile on the GridCollider. More...
 
bool GetTileAtPosition (float x, float y)
 Get the collision status of a tile at a position in the Scene. More...
 
bool GetRect (float x, float y, float x2, float y2, bool usingGrid=true)
 Check for a collidable tile in a rectangle on the GridCollider. More...
 
void LoadString (string source, char empty= '0', char filled= '1')
 Convert a string into tiles on the GridCollider. More...
 
void LoadCSV (string source, string empty="0", string filled="1", char columnSep= ',', char rowSep= '\n')
 Convert a CSV file into tiles on the GridCollider. More...
 
void LoadTilemap (Tilemap source, int layerDepth)
 Load collision data from a Tilemap. More...
 
void LoadTilemap (Tilemap source, string layerName)
 Load collision data from a Tilemap. More...
 
void LoadTilemap (Tilemap source, Enum layerName)
 Load collision data from a Tilemap. More...
 
override void Render (Color color=null)
 Draw the collider for debug purposes. More...
 
- Public Member Functions inherited from Otter.Collider
bool Overlap (float x, float y, int px, int py)
 Checks for a collision with a specific point. More...
 
bool Overlap (float x, float y, params int[] tags)
 Checks for a collision against the specified tags and returns true or false. More...
 
bool Overlap (float x, float y, Collider c)
 Checks for a collision against a specific Collider and returns true or false. More...
 
bool Overlap (float x, float y, Entity e)
 Checks for a collision against a specific Entity and returns true or false. More...
 
bool Overlap (float x, float y, List< int > tags)
 Checks for a collision against a list of Collliders and returns true or false. More...
 
bool Overlap (float x, float y, params Enum[] tags)
 Checks for a collision against the specified tags and returns true or false. More...
 
bool Overlap (float x, float y, List< Enum > tags)
 Checks for a collision against the specified tags and returns true or false. More...
 
bool Overlap (float x, float y, List< Entity > entities)
 Checks for a collision against a list of Entities and all of their colliders. More...
 
bool Overlap< T > (float x, float y, List< T > entities)
 Checks for a collision against a list of Entities and all of their colliders. More...
 
Collider Collide (float x, float y, List< Entity > entities)
 Checks for a collision against a list of Entities and all of their colliders. More...
 
Collider Collide< T > (float x, float y, List< T > entities)
 
Collider Collide (float x, float y, params int[] tags)
 Checks for a collision against specified tags. More...
 
Collider Collide (float x, float y, params Enum[] tags)
 Checks for a collision against specified tags. More...
 
Collider Collide (float x, float y, Collider c)
 Checks for a collision with a specific collider. More...
 
Collider Collide (float x, float y, Entity e)
 Checks for a collision with a specific entity. More...
 
Collider Collide (float x, float y, List< int > tags)
 Checks for a collision with a list of tags. More...
 
Collider Collide (float x, float y, List< Enum > tags)
 Checks for a collision with a list of tags. More...
 
Entity CollideEntity (float x, float y, params int[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
CollideEntity< T > (float x, float y, params int[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
Entity CollideEntity (float x, float y, params Enum[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
CollideEntity< T > (float x, float y, params Enum[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
Entity CollideEntity (float x, float y, Entity e)
 Checks for a collision with a specific Entity and returns an Entity. More...
 
CollideEntity< T > (float x, float y, Entity e)
 Checks for a collision with a specific Entity and returns an Entity. More...
 
Entity CollideEntity (float x, float y, Collider c)
 Checks for a collision with a specific Collider and returns an Entity. More...
 
CollideEntity< T > (float x, float y, Collider c)
 Checks for a collision with a specific Collider and returns an Entity. More...
 
Entity CollideEntity (float x, float y, List< int > tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
CollideEntity< T > (float x, float y, List< int > tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
Entity CollideEntity (float x, float y, List< Entity > entities)
 Checks for a collision with a list of Entities and returns an Entity. More...
 
CollideEntity< T > (float x, float y, List< T > entities)
 Checks for a collision with a list of Entities and returns an Entity. More...
 
List< ColliderCollideList (float x, float y, params int[] tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< ColliderCollideList (float x, float y, params Enum[] tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< ColliderCollideList (float x, float y, List< Enum > tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< ColliderCollideList (float x, float y, List< int > tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< EntityCollideEntities (float x, float y, params int[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< EntityCollideEntities (float x, float y, params Enum[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< EntityCollideEntities (float x, float y, List< Enum > tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, params int[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, params Enum[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, List< Enum > tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, List< T > entities)
 Creates a list of Entities that the Collider has collided with. More...
 
List< EntityCollideEntities (float x, float y, List< int > tags)
 Creates a list of entities that the Collider has collided with. More...
 
virtual void Added ()
 Callback for when the Collider has been added to an Entity. More...
 
virtual void Removed ()
 Callback for when the Collider has been removed from an Entity. More...
 
Collider AddTag (int tag)
 Add a new tag to the Collider. More...
 
Collider AddTag (params Enum[] tags)
 Add new tags to the Collider. More...
 
bool HasTag (params Enum[] tags)
 
bool HasTag (params int[] tags)
 
Collider AddTag (params int[] tags)
 Add new tags to the Collider. More...
 
Collider RemoveTag (int tag)
 Remove a tag from the Collider. More...
 
Collider RemoveTag (params int[] tags)
 Remove tags from the Collider. More...
 
Collider RemoveTag (params Enum[] tags)
 Remove tags from the Collider. More...
 
virtual void CenterOrigin ()
 Center the origin of the Collider. Based off of Width and Height. More...
 
void SetPosition (float x, float y)
 Set the positon of the Collider. More...
 
void SetPosition (Vector2 xy)
 Set the position of the Collider. More...
 
void SetOrigin (float x, float y)
 Set the origin of the Collider More...
 
void SetOrigin (Vector2 xy)
 Set the origin of the Collider. More...
 

Properties

int TileWidth [get, set]
 The width of the tiles. More...
 
int TileHeight [get, set]
 The height of the tiles. More...
 
int TileRows [get, set]
 The total number of rows on the grid. More...
 
int TileColumns [get, set]
 The total number of columns on the grid. More...
 
override float Width [get]
 The width of the grid. (TileColumns * TileWidth) More...
 
override float Height [get]
 The height of the grid (TileRows * TileHeight) More...
 
int TileArea [get]
 The area in tile size. More...
 
int Area [get]
 The area in pixels. More...
 
- Properties inherited from Otter.Collider
List< int > Tags [get, set]
 The tags that this Collider is registered with. More...
 
virtual float Width [get, set]
 The width of the Collider. More...
 
virtual float Height [get, set]
 The height of the Collider. More...
 
virtual float CenterX [get]
 The X position of the center of the Collider. More...
 
virtual float CenterY [get]
 The Y position of the center of the Collider. More...
 
virtual float Left [get]
 The X position of the left side of the Collider. More...
 
virtual float Right [get]
 The X position of the right side of the Collider. More...
 
virtual float Top [get]
 The Y position of the top of the Collider. More...
 
virtual float Bottom [get]
 The Y position of the bottom of the Collider. More...
 
float HalfHeight [get]
 Half of the Collider's height. More...
 
float HalfWidth [get]
 Half of the Collider's width. More...
 

Additional Inherited Members

- Public Attributes inherited from Otter.Collider
float X
 The X position of the Collider relative to the Entity. More...
 
float Y
 The Y position of the Collider relative to the Entity. More...
 
float OriginX
 The OriginX of the Collider. More...
 
float OriginY
 The OriginY of the Collider. More...
 
Entity Entity
 The entity that this collider is parented to. More...
 
bool Collidable = true
 Determines if this collider is collidable. If false, it will not register collisions with other colliders, but can still check for collisions with other colliders. More...
 

Detailed Description

Grid Collider. Can be mainly used to create collision to correspond to a Tilemap.

Constructor & Destructor Documentation

Otter.GridCollider.GridCollider ( int  width,
int  height,
int  tileWidth,
int  tileHeight,
params int[]  tags 
)

Create a new GridCollider.

Parameters
widthThe width in pixels of the GridCollider.
heightThe height in pixels of the GridCollider.
tileWidthThe width of each tile on the grid.
tileHeightThe heigth of each tile on the grid.
tagsThe tags to register for the collider.

Member Function Documentation

void Otter.GridCollider.Clear ( bool  collidable = false)

Clears the entire grid.

Parameters
collidableOptionally set to true to clear grid with collidable cells.
bool Otter.GridCollider.GetRect ( float  x,
float  y,
float  x2,
float  y2,
bool  usingGrid = true 
)

Check for a collidable tile in a rectangle on the GridCollider.

Parameters
xThe X position of the top left corner of the rectangle.
yThe Y position of the top left corner of the rectangle.
widthThe width in tiles of the rectangle.
heightThe height in tiles of the rectangle.
collidableTrue if any tile in the rectangle is collidable.
bool Otter.GridCollider.GetTile ( int  x,
int  y 
)

Get the collision status of a tile on the GridCollider.

Parameters
xThe X position of the tile.
yThe Y position of the tile.
Returns
True if the tile is collidable.
bool Otter.GridCollider.GetTileAtPosition ( float  x,
float  y 
)

Get the collision status of a tile at a position in the Scene.

Parameters
xThe X position in the Scene.
yThe Y position in the Scene.
Returns
True if the tile at that position is collidable.
int Otter.GridCollider.GridX ( float  x)

Convert an X position to a tile on the grid.

Parameters
xThe position to convert.
Returns
The X position of the tile that was found at that position.
int Otter.GridCollider.GridY ( float  y)

Convert an Y position to a tile on the grid.

Parameters
yThe position to convert.
Returns
The Y position of the tile that was found at that position.
void Otter.GridCollider.LoadCSV ( string  source,
string  empty = "0",
string  filled = "1",
char  columnSep = ',',
char  rowSep = '\n' 
)

Convert a CSV file into tiles on the GridCollider.

Parameters
sourceThe source CSV data.
emptyString representing an empty space on the grid.
filledString representing a collidable space on the grid.
columnSepThe separator character for columns.
rowSepThe separator character for rows.
void Otter.GridCollider.LoadString ( string  source,
char  empty = '0',
char  filled = '1' 
)

Convert a string into tiles on the GridCollider.

Parameters
sourceThe source string data.
emptyThe character representing an empty space on the grid.
filledThe character representing a collidable space on the grid.
void Otter.GridCollider.LoadTilemap ( Tilemap  source,
int  layerDepth 
)

Load collision data from a Tilemap.

Parameters
sourceThe source Tilemap.
layerDepthThe layer of tiles to use to mark collisions.
void Otter.GridCollider.LoadTilemap ( Tilemap  source,
string  layerName 
)

Load collision data from a Tilemap.

Parameters
sourceThe source Tilemap.
layerNameThe layer of tiles to use to mark collisions.
void Otter.GridCollider.LoadTilemap ( Tilemap  source,
Enum  layerName 
)

Load collision data from a Tilemap.

Parameters
sourceThe source Tilemap.
layerNameThe layer of tiles to use to mark collisions.
override void Otter.GridCollider.Render ( Color  color = null)
virtual

Draw the collider for debug purposes.

Reimplemented from Otter.Collider.

void Otter.GridCollider.SetRect ( int  x,
int  y,
int  width,
int  height,
bool  collidable = true 
)

Set the collision status of a rectangle area on the GridCollider.

Parameters
xThe X position of the top left corner of the rectangle.
yThe Y position of the top left corner of the rectangle.
widthThe width in tiles of the rectangle.
heightThe height in tiles of the rectangle.
collidableTrue if collidable.
void Otter.GridCollider.SetTile ( int  x,
int  y,
bool  collidable = true 
)

Set the collision status of a tile on the GridCollider.

Parameters
xThe X position of the tile.
yThe Y position of the tile.
collidableTrue if collidable.

Property Documentation

int Otter.GridCollider.Area
get

The area in pixels.

override float Otter.GridCollider.Height
get

The height of the grid (TileRows * TileHeight)

int Otter.GridCollider.TileArea
get

The area in tile size.

int Otter.GridCollider.TileColumns
getset

The total number of columns on the grid.

int Otter.GridCollider.TileHeight
getset

The height of the tiles.

int Otter.GridCollider.TileRows
getset

The total number of rows on the grid.

int Otter.GridCollider.TileWidth
getset

The width of the tiles.

override float Otter.GridCollider.Width
get

The width of the grid. (TileColumns * TileWidth)


The documentation for this class was generated from the following file: