TopDown Engine  v4.1
MoreMountains.TopDownEngine.GridManager Class Reference

A manager required in your scenes that use CharacterGridMovement. More...

Inheritance diagram for MoreMountains.TopDownEngine.GridManager:
MoreMountains.Tools.MMSingleton< GridManager >

Public Types

enum  DebugDrawModes { DebugDrawModes.TwoD, DebugDrawModes.ThreeD }
 the possible types of debug modes More...
 

Public Member Functions

virtual bool CellIsOccupied (Vector3 cellCoordinates)
 Returns true if the cell at the specified coordinates is occupied, false otherwise More...
 
virtual void OccupyCell (Vector3 cellCoordinates)
 Marks the specified cell as occupied More...
 
virtual void FreeCell (Vector3 cellCoordinates)
 Marks the specified cell as unoccupied More...
 
virtual void SetNextPosition (GameObject trackedObject, Vector3Int cellCoordinates)
 Sets the next position of the specified object traveling on the grid. The next position is the position the object will be at when it reaches its destination grid cell More...
 
virtual void SetLastPosition (GameObject trackedObject, Vector3Int cellCoordinates)
 Sets the last position of the specified object traveling on the grid. The last position is the position the object was at the last time it passed on a perfect tile More...
 
virtual Vector3Int WorldToCellCoordinates (Vector3 worldPosition)
 Returns the corresponding world coordinates of a grid position More...
 
virtual Vector3 CellToWorldCoordinates (Vector3Int coordinates)
 Converts cell coordinates into their world position More...
 
virtual Vector3 ComputeGridPosition (Vector3 targetPosition)
 Returns the grid position of the specified vector in world position More...
 
virtual Vector3 ComputeWorldPosition (Vector3 targetPosition)
 Computes the grid position of a vector3 specified in grid units More...
 

Public Attributes

Transform GridOrigin
 the origin of the grid in world space More...
 
float GridUnitSize = 1f
 the size of each square grid cell More...
 
bool DrawDebugGrid = true
 whether or not to draw the debug grid More...
 
DebugDrawModes DebugDrawMode = DebugDrawModes.TwoD
 the mode in which to draw the debug grid More...
 
int DebugGridSize = 30
 the size (in squares of the debug grid) More...
 
Color CellBorderColor = new Color(60f, 221f, 255f, 1f)
 the color to use to draw the debug grid lines More...
 
Color InnerColor = new Color(60f, 221f, 255f, 0.3f)
 the color to use to draw the debug grid cells backgrounds More...
 
List< Vector3 > OccupiedGridCells
 a list of all cells currently occupied More...
 
Dictionary< GameObject, Vector3Int > LastPositions
 a dictionary holding all last positions registered by objects traveling on the grid More...
 
Dictionary< GameObject, Vector3Int > NextPositions
 a dictionary holding all next positions registered by objects traveling on the grid More...
 

Protected Member Functions

virtual void Start ()
 On start we initialize our lists and dictionaries More...
 
virtual void OnDrawGizmos ()
 On draw gizmos, draws a debug grid More...
 
virtual void DrawCell2D (int a, int b)
 Draws a 2D debug cell More...
 
virtual void DrawCell3D (int a, int b)
 Draws a 3D debug cell More...
 
- Protected Member Functions inherited from MoreMountains.Tools.MMSingleton< GridManager >
virtual void Awake ()
 On awake, we initialize our instance. Make sure to call base.Awake() in override if you need awake. More...
 
virtual void InitializeSingleton ()
 Initializes the singleton. More...
 

Static Protected Member Functions

static void InitializeStatics ()
 Statics initialization to support enter play modes More...
 

Protected Attributes

Vector3 _newGridPosition
 
Vector3 _debugOrigin = Vector3.zero
 
Vector3 _debugDestination = Vector3.zero
 
Vector3Int _workCoordinate = Vector3Int.zero
 

Additional Inherited Members

- Static Public Member Functions inherited from MoreMountains.Tools.MMSingleton< GridManager >
static T TryGetInstance ()
 
- Static Public Attributes inherited from MoreMountains.Tools.MMSingleton< GridManager >
static bool HasInstance
 
static T Current
 
- Static Protected Attributes inherited from MoreMountains.Tools.MMSingleton< GridManager >
static T _instance
 
- Properties inherited from MoreMountains.Tools.MMSingleton< GridManager >
static T Instance [get]
 Singleton design pattern More...
 

Detailed Description

A manager required in your scenes that use CharacterGridMovement.

Member Enumeration Documentation

◆ DebugDrawModes

the possible types of debug modes

Enumerator
TwoD 
ThreeD 

Member Function Documentation

◆ CellIsOccupied()

virtual bool MoreMountains.TopDownEngine.GridManager.CellIsOccupied ( Vector3  cellCoordinates)
virtual

Returns true if the cell at the specified coordinates is occupied, false otherwise

Parameters
cellCoordinates
Returns

◆ CellToWorldCoordinates()

virtual Vector3 MoreMountains.TopDownEngine.GridManager.CellToWorldCoordinates ( Vector3Int  coordinates)
virtual

Converts cell coordinates into their world position

Parameters
coordinates
Returns

◆ ComputeGridPosition()

virtual Vector3 MoreMountains.TopDownEngine.GridManager.ComputeGridPosition ( Vector3  targetPosition)
virtual

Returns the grid position of the specified vector in world position

Parameters
targetPosition
Returns

◆ ComputeWorldPosition()

virtual Vector3 MoreMountains.TopDownEngine.GridManager.ComputeWorldPosition ( Vector3  targetPosition)
virtual

Computes the grid position of a vector3 specified in grid units

Parameters
targetPosition
Returns

◆ DrawCell2D()

virtual void MoreMountains.TopDownEngine.GridManager.DrawCell2D ( int  a,
int  b 
)
protectedvirtual

Draws a 2D debug cell

Parameters
a
b

◆ DrawCell3D()

virtual void MoreMountains.TopDownEngine.GridManager.DrawCell3D ( int  a,
int  b 
)
protectedvirtual

Draws a 3D debug cell

Parameters
a
b

◆ FreeCell()

virtual void MoreMountains.TopDownEngine.GridManager.FreeCell ( Vector3  cellCoordinates)
virtual

Marks the specified cell as unoccupied

Parameters
cellCoordinates

◆ InitializeStatics()

static void MoreMountains.TopDownEngine.GridManager.InitializeStatics ( )
staticprotected

Statics initialization to support enter play modes

◆ OccupyCell()

virtual void MoreMountains.TopDownEngine.GridManager.OccupyCell ( Vector3  cellCoordinates)
virtual

Marks the specified cell as occupied

Parameters
cellCoordinates

◆ OnDrawGizmos()

virtual void MoreMountains.TopDownEngine.GridManager.OnDrawGizmos ( )
protectedvirtual

On draw gizmos, draws a debug grid

◆ SetLastPosition()

virtual void MoreMountains.TopDownEngine.GridManager.SetLastPosition ( GameObject  trackedObject,
Vector3Int  cellCoordinates 
)
virtual

Sets the last position of the specified object traveling on the grid. The last position is the position the object was at the last time it passed on a perfect tile

◆ SetNextPosition()

virtual void MoreMountains.TopDownEngine.GridManager.SetNextPosition ( GameObject  trackedObject,
Vector3Int  cellCoordinates 
)
virtual

Sets the next position of the specified object traveling on the grid. The next position is the position the object will be at when it reaches its destination grid cell

Parameters
trackedObject
cellCoordinates

◆ Start()

virtual void MoreMountains.TopDownEngine.GridManager.Start ( )
protectedvirtual

On start we initialize our lists and dictionaries

◆ WorldToCellCoordinates()

virtual Vector3Int MoreMountains.TopDownEngine.GridManager.WorldToCellCoordinates ( Vector3  worldPosition)
virtual

Returns the corresponding world coordinates of a grid position

Parameters
worldPosition
Returns

Member Data Documentation

◆ _debugDestination

Vector3 MoreMountains.TopDownEngine.GridManager._debugDestination = Vector3.zero
protected

◆ _debugOrigin

Vector3 MoreMountains.TopDownEngine.GridManager._debugOrigin = Vector3.zero
protected

◆ _newGridPosition

Vector3 MoreMountains.TopDownEngine.GridManager._newGridPosition
protected

◆ _workCoordinate

Vector3Int MoreMountains.TopDownEngine.GridManager._workCoordinate = Vector3Int.zero
protected

◆ CellBorderColor

Color MoreMountains.TopDownEngine.GridManager.CellBorderColor = new Color(60f, 221f, 255f, 1f)

the color to use to draw the debug grid lines

◆ DebugDrawMode

DebugDrawModes MoreMountains.TopDownEngine.GridManager.DebugDrawMode = DebugDrawModes.TwoD

the mode in which to draw the debug grid

◆ DebugGridSize

int MoreMountains.TopDownEngine.GridManager.DebugGridSize = 30

the size (in squares of the debug grid)

◆ DrawDebugGrid

bool MoreMountains.TopDownEngine.GridManager.DrawDebugGrid = true

whether or not to draw the debug grid

◆ GridOrigin

Transform MoreMountains.TopDownEngine.GridManager.GridOrigin

the origin of the grid in world space

◆ GridUnitSize

float MoreMountains.TopDownEngine.GridManager.GridUnitSize = 1f

the size of each square grid cell

◆ InnerColor

Color MoreMountains.TopDownEngine.GridManager.InnerColor = new Color(60f, 221f, 255f, 0.3f)

the color to use to draw the debug grid cells backgrounds

◆ LastPositions

Dictionary<GameObject, Vector3Int> MoreMountains.TopDownEngine.GridManager.LastPositions

a dictionary holding all last positions registered by objects traveling on the grid

◆ NextPositions

Dictionary<GameObject, Vector3Int> MoreMountains.TopDownEngine.GridManager.NextPositions

a dictionary holding all next positions registered by objects traveling on the grid

◆ OccupiedGridCells

List<Vector3> MoreMountains.TopDownEngine.GridManager.OccupiedGridCells

a list of all cells currently occupied


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