Nostalgia  2.1.5
Map Class Reference

Components of 2D tile map. More...

Inheritance diagram for Map:

Classes

class  CellResult
 Class that will contain the result of Map.FindCell (). More...
 

Public Types

enum  HorizontalPivot { Left, Center, Right }
 Specifies the pivot in the horizontal direction. More...
 
enum  VerticalPivot { Top, Center, Bottom }
 Specifies the pivot in the vertical direction. More...
 

Public Member Functions

delegate void OnRepainted ()
 Callback delegate when repainted More...
 
Cell GetCell (int index)
 Get the Cell from the index . More...
 
Chunk GetChunk (int index)
 Get the chunk from the index . More...
 
MapCollider GetMapCollider (int index)
 Get the MapCollider from the index . More...
 
Stamp GetStamp (int index)
 Get the chunk from the index . More...
 
int IndexOfStamp (Stamp stamp)
 Get the index from the Stamp. More...
 
Cell GetCell (Point2 pos)
 Gets the Cell. More...
 
Cell GetCellFromWorldPos (Vector3 worldPos)
 Gets the cell from world position. More...
 
Cell GetCellFromCollider (Collider2D collider)
 Gets the Cell from collider. More...
 
Tile GetTile (Point2 pos)
 Gets the tile. More...
 
Vector3 MapPointToLocalPoint (Point2 pos)
 Maps the point to local point. More...
 
Vector3 MapPointToWorldPoint (Point2 pos)
 Maps the point to world point. More...
 
Point2 LocalPointToMapPoint (Vector3 localPos)
 Locals the point to map point. More...
 
Point2 WorldPointToMapPoint (Vector3 worldPos)
 Worlds the point to map point. More...
 
bool RayToPoint (Ray ray, out Point2 pos)
 Raies to point. More...
 
bool Raycast (Ray ray, ref Vector2 localPos)
 Raies to local point. More...
 
void Resize (int width, int height, HorizontalPivot horizontalPivot, VerticalPivot verticalPivot)
 Resize. More...
 
void InsertCell (Point2 pos, Point2 size)
 To insert cells. More...
 
void RemoveCell (Point2 pos, Point2 size)
 To remove cells More...
 
bool PutTile (Point2 pos, Tile tile, int partsID, Point2 tilePos, bool autoTiling, bool changeParts, bool isCreateCellObject)
 Puts the tile. More...
 
bool FillTile (Point2 pos, int width, int height, Tile tile, int partsID, bool autoTiling, bool isCreateCellObject)
 Fills the tile. More...
 
Async FillTileAsync (Point2 pos, int width, int height, Tile tile, int partsID, bool autoTiling, bool isCreateCellObject)
 Fills the tile (Async). More...
 
Stamp CreateStamp (Point2 pos, int width, int height)
 To create a stamp More...
 
void RemoveStamp (Stamp stamp)
 To remove the stamp More...
 
bool PutStamp (Point2 pos, Stamp stamp, bool autoTiling, bool isCreateCellObject)
 Fills the tile from stamp. More...
 
bool UpdateAutoTiles (HashSet< Point2 > points, bool aroundOnly=false)
 Update process of the Cell by auto tile More...
 
bool BucketTile (Point2 pos, Tile tile, int partsID, bool autoTiling, bool isCreateCellObject)
 Buckets the tile. More...
 
Async BucketTileAsync (Point2 pos, Tile tile, int partsID, bool autoTiling, bool isCreateCellObject)
 Buckets the tile (Async). More...
 
bool RemoveTile (Cell cell, bool autoTiling)
 Removes the tile. More...
 
bool RemoveTile (Point2 pos, bool autoTiling)
 Removes the tile. More...
 
bool RemoveRectangleTile (Point2 pos, int width, int height, bool autoTiling)
 Tile remove of a rectangle specified. More...
 
Async RemoveRectangleTileAsync (Point2 pos, int width, int height, bool autoTiling)
 Tile remove of a rectangle specified (Async). More...
 
bool RemoveBucketTile (Point2 pos, bool autoTiling)
 Tile deletion in bucket form. More...
 
Async RemoveBucketTileAsync (Point2 pos, bool autoTiling)
 Tile deletion in bucket form(Async). More...
 
bool ColorBrush (Vector2 center, float radius, Color color, bool halftile)
 Colors the brush. More...
 
bool ColorBrushRectangle (Vector2 pos, float width, float height, Color color, bool halftile)
 Paint a vertex color rectangle specified. More...
 
void AllClear ()
 Alls the clear. More...
 
Async AllClearAsync ()
 
bool UpdateCollider (Cell cell)
 To update the status of the Collider of the Cell. More...
 
MapCollider GetMapCollider (PolygonCollider2D collider)
 Get MapCollider from PolygonCollider2D. More...
 
MapCollider GetMapCollider (Cell cell)
 Get MapCollider from Cell. More...
 
void UpdateMapCollider ()
 Update MapColliders More...
 
bool Refresh ()
 Refresh this instance. More...
 
Async RefreshAsync ()
 Rebuild the Cell asynchronously. More...
 
void SetDirty (bool repaint)
 You set up to rebuild the mesh. More...
 
void Repaint ()
 Repaint More...
 
void Copy (Map source)
 Copy the Map. More...
 
void DestroySubComponents ()
 Destroies the sub components. More...
 

Static Public Member Functions

static Map GetMap (int index)
 Get the Map from the index . More...
 
static CellResult FindCell (Vector3 worldPos)
 Finds the Cell from the world position. More...
 
static CellResult[] FindCells (Vector3 worldPos)
 Find Cell everything in the world coordinates to the specified. More...
 
static Cell FindCell (Collider2D collider)
 Find Cell from Collider 2D. More...
 

Properties

int width [get]
 Gets the width. More...
 
int height [get]
 Gets the height. More...
 
TileSet tileSet [get, set]
 Gets / Sets the tile set. More...
 
bool edgeCombine [get, set]
 Whether or not to combine auto tiles with map edges More...
 
bool isCanvas [get]
 Whether to render to a Canvas. More...
 
int cellCount [get]
 Get the number of Cells. More...
 
int chunkCount [get]
 Get the number of chunks. More...
 
int mapColliderCount [get]
 Get the number of MapColliders. More...
 
int stampCount [get]
 Get the number of stamps. More...
 
Color color [get, set]
 Gets or sets the material color. More...
 
int sortingLayerID [get, set]
 Gets or sets the sortingLayerID. More...
 
int sortingOrder [get, set]
 Gets or sets the sortingOrder. More...
 
static int mapCount [get]
 Get the number of Maps. More...
 
Material material [get]
 Gets the material. More...
 

Events

OnRepainted onRepainted
 Callback event when repainted More...
 

Detailed Description

Components of 2D tile map.

And it may be attached to a GameObject.

Member Enumeration Documentation

enum HorizontalPivot
strong

Specifies the pivot in the horizontal direction.

Use a Resize().

Enumerator
Left 

The left.

Center 

The center.

Right 

The right.

enum VerticalPivot
strong

Specifies the pivot in the vertical direction.

Use a Resize().

Enumerator
Top 

The top.

Center 

The center.

Bottom 

The bottom.

Member Function Documentation

void AllClear ( )

Alls the clear.

Async AllClearAsync ( )
bool BucketTile ( Point2  pos,
Tile  tile,
int  partsID,
bool  autoTiling,
bool  isCreateCellObject 
)

Buckets the tile.

Returns
true, if tile was bucketed, false otherwise.
Parameters
posPosition.
tileTile.
partsIDParts ID.
autoTilingIf set to true auto tiling.
isCreateCellObjectWhether you want to create a CellObject
Async BucketTileAsync ( Point2  pos,
Tile  tile,
int  partsID,
bool  autoTiling,
bool  isCreateCellObject 
)

Buckets the tile (Async).

Returns
Async instance to handle the asynchronous
Parameters
posPosition.
tileTile.
partsIDParts ID.
autoTilingIf set to true auto tiling.
isCreateCellObjectWhether you want to create a CellObject
bool ColorBrush ( Vector2  center,
float  radius,
Color  color,
bool  halftile 
)

Colors the brush.

Returns
true, Changed. false otherwise.
Parameters
centerCenter.
radiusRadius.
colorColor.
halftileFill half per tile.
bool ColorBrushRectangle ( Vector2  pos,
float  width,
float  height,
Color  color,
bool  halftile 
)

Paint a vertex color rectangle specified.

Returns
true, Changed. false otherwise.
Parameters
posPosition.
widthWidth.
heightHeight.
colorColor.
halftileFill half per tile.
void Copy ( Map  source)

Copy the Map.

Parameters
sourceCopy source Map
Stamp CreateStamp ( Point2  pos,
int  width,
int  height 
)

To create a stamp

Parameters
posPosition
widthWidth
heightHeight
Returns
Stamp was created. If there is no Cell in the range null is returned.
void DestroySubComponents ( )

Destroies the sub components.

Usually, you do not need to call.

bool FillTile ( Point2  pos,
int  width,
int  height,
Tile  tile,
int  partsID,
bool  autoTiling,
bool  isCreateCellObject 
)

Fills the tile.

Returns
true, if tile was filled, false otherwise.
Parameters
posPosition.
widthWidth.
heightHeight.
tileTile.
partsIDParts ID.
autoTilingIf set to true auto tiling.
isCreateCellObjectWhether you want to create a CellObject
Async FillTileAsync ( Point2  pos,
int  width,
int  height,
Tile  tile,
int  partsID,
bool  autoTiling,
bool  isCreateCellObject 
)

Fills the tile (Async).

Returns
Async instance to handle the asynchronous.
Parameters
posPosition.
widthWidth.
heightHeight.
tileTile.
partsIDParts ID.
autoTilingIf set to true auto tiling.
isCreateCellObjectWhether you want to create a CellObject
static CellResult FindCell ( Vector3  worldPos)
static

Finds the Cell from the world position.

Returns
CellResult is returned if you find. Null is returned if it does not exist.
Parameters
worldPosWorld position.
static Cell FindCell ( Collider2D  collider)
static

Find Cell from Collider 2D.

Parameters
colliderCollider2D to acquire Cell
Returns
Return Cell. It returns null if it can not be found.
static CellResult [] FindCells ( Vector3  worldPos)
static

Find Cell everything in the world coordinates to the specified.

Returns
Array of CellResult of Cell found.
Parameters
worldPosWorld position.
Cell GetCell ( int  index)

Get the Cell from the index .

Parameters
indexindex
Returns
Cell
Cell GetCell ( Point2  pos)

Gets the Cell.

Returns
The Cell. The return value may be null if it does not exist.
Parameters
posPosition.
Cell GetCellFromCollider ( Collider2D  collider)

Gets the Cell from collider.

Returns
The Cell from collider. The return value may be null if it does not exist.
Parameters
colliderCollider.
Cell GetCellFromWorldPos ( Vector3  worldPos)

Gets the cell from world position.

Returns
It is the Cell found. I return null if it does not.
Parameters
worldPosWorld position.
Chunk GetChunk ( int  index)

Get the chunk from the index .

Parameters
indexindex
Returns
chunk
static Map GetMap ( int  index)
static

Get the Map from the index .

Parameters
indexindex
Returns
Map
MapCollider GetMapCollider ( int  index)

Get the MapCollider from the index .

Parameters
indexindex
Returns
MapCollider
MapCollider GetMapCollider ( PolygonCollider2D  collider)

Get MapCollider from PolygonCollider2D.

Parameters
colliderPolygonCollider2D
Returns
MapCollider. If there is none, null is returned.
MapCollider GetMapCollider ( Cell  cell)

Get MapCollider from Cell.

Parameters
cellCell
Returns
MapCollider. If there is none, null is returned.
Stamp GetStamp ( int  index)

Get the chunk from the index .

Parameters
indexindex
Returns
stamp
Tile GetTile ( Point2  pos)

Gets the tile.

Returns
The tile. The return value may be null if it does not exist.
Parameters
posPosition.
int IndexOfStamp ( Stamp  stamp)

Get the index from the Stamp.

Parameters
stampstamp
Returns
index
void InsertCell ( Point2  pos,
Point2  size 
)

To insert cells.

Parameters
posPosition
sizeSize
Point2 LocalPointToMapPoint ( Vector3  localPos)

Locals the point to map point.

Returns
The point to map point.
Parameters
localPosLocal position.
Vector3 MapPointToLocalPoint ( Point2  pos)

Maps the point to local point.

Returns
The point to local point.
Parameters
posPosition.
Vector3 MapPointToWorldPoint ( Point2  pos)

Maps the point to world point.

Returns
The point to world point.
Parameters
posPosition.
delegate void OnRepainted ( )

Callback delegate when repainted

bool PutStamp ( Point2  pos,
Stamp  stamp,
bool  autoTiling,
bool  isCreateCellObject 
)

Fills the tile from stamp.

Returns
true, if tile was filled, false otherwise.
Parameters
posPosition.
stampStamp.
autoTilingIf set to true auto tiling.
isCreateCellObjectWhether you want to create a CellObject
bool PutTile ( Point2  pos,
Tile  tile,
int  partsID,
Point2  tilePos,
bool  autoTiling,
bool  changeParts,
bool  isCreateCellObject 
)

Puts the tile.

Returns
true, if tile was put, false otherwise.
Parameters
posPosition.
tileTile.
partsIDParts ID.
tilePosTile Position
autoTilingIf set to true auto tiling.
changePartsIf set to true change parts.
isCreateCellObjectWhether you want to create a CellObject
bool Raycast ( Ray  ray,
ref Vector2  localPos 
)

Raies to local point.

Parameters
rayRay.
localPosLocal position.
bool RayToPoint ( Ray  ray,
out Point2  pos 
)

Raies to point.

Returns
true, if to point was rayed, false otherwise.
Parameters
rayRay.
posPosition.
bool Refresh ( )

Refresh this instance.

Please Cell if you have updated the TileSet.

Rebuild the Cell asynchronously.

Please call if you have updated the TileSet.

bool RemoveBucketTile ( Point2  pos,
bool  autoTiling 
)

Tile deletion in bucket form.

Returns
true, if tile was removed, false otherwise.
Parameters
posPosition.
autoTilingIf set to true auto tiling.
Async RemoveBucketTileAsync ( Point2  pos,
bool  autoTiling 
)

Tile deletion in bucket form(Async).

Returns
Async instance to handle the asynchronous
Parameters
posPosition.
autoTilingIf set to true auto tiling.
void RemoveCell ( Point2  pos,
Point2  size 
)

To remove cells

Parameters
posPosition
sizeSize
bool RemoveRectangleTile ( Point2  pos,
int  width,
int  height,
bool  autoTiling 
)

Tile remove of a rectangle specified.

Returns
true, if tile was removed, false otherwise.
Parameters
posPosition.
widthWidth.
heightHeight.
autoTilingIf set to true auto tiling.
Async RemoveRectangleTileAsync ( Point2  pos,
int  width,
int  height,
bool  autoTiling 
)

Tile remove of a rectangle specified (Async).

Returns
Async instance to handle the asynchronous.
Parameters
posPosition.
widthWidth.
heightHeight.
autoTilingIf set to true auto tiling.
void RemoveStamp ( Stamp  stamp)

To remove the stamp

Parameters
stampStamp to be removed
bool RemoveTile ( Cell  cell,
bool  autoTiling 
)

Removes the tile.

Returns
true, if tile was removed, false otherwise.
Parameters
cellCell.
autoTilingIf set to true auto tiling.
bool RemoveTile ( Point2  pos,
bool  autoTiling 
)

Removes the tile.

Returns
true, if tile was removed, false otherwise.
Parameters
posPosition.
autoTilingIf set to true auto tiling.
void Repaint ( )

Repaint

void Resize ( int  width,
int  height,
HorizontalPivot  horizontalPivot,
VerticalPivot  verticalPivot 
)

Resize.

Parameters
widthWidth.
heightHeight.
horizontalPivotHorizontal pivot.
verticalPivotVertical pivot.
void SetDirty ( bool  repaint)

You set up to rebuild the mesh.

Please call when you directly modify the Cell.

Parameters
repaintWhether or not to repaint
bool UpdateAutoTiles ( HashSet< Point2 points,
bool  aroundOnly = false 
)

Update process of the Cell by auto tile

Parameters
pointsCoordinates to be updated
aroundOnlyWhether you want to update only the peripheral
Returns
Whether the update
bool UpdateCollider ( Cell  cell)

To update the status of the Collider of the Cell.

Parameters
cellCell to update the Collider
Returns
Whether the update
void UpdateMapCollider ( )

Update MapColliders

Point2 WorldPointToMapPoint ( Vector3  worldPos)

Worlds the point to map point.

Returns
The point to map point.
Parameters
worldPosWorld position.

Property Documentation

int cellCount
get

Get the number of Cells.

int chunkCount
get

Get the number of chunks.

Color color
getset

Gets or sets the material color.

bool edgeCombine
getset

Whether or not to combine auto tiles with map edges

int height
get

Gets the height.

The height.

bool isCanvas
get

Whether to render to a Canvas.

When the Map game object has RectTransform, it is in Canvas mode.

int mapColliderCount
get

Get the number of MapColliders.

int mapCount
staticget

Get the number of Maps.

Material material
get

Gets the material.

int sortingLayerID
getset

Gets or sets the sortingLayerID.

int sortingOrder
getset

Gets or sets the sortingOrder.

int stampCount
get

Get the number of stamps.

TileSet tileSet
getset

Gets / Sets the tile set.

The tile set.

int width
get

Gets the width.

The width.

Event Documentation

OnRepainted onRepainted

Callback event when repainted