Class GameTile
Represents a single tile in a grid-based game system. Flexible design supports board games, 2D adventure games, puzzles, and more.
public class GameTile
- Inheritance
-
GameTile
- Inherited Members
Constructors
GameTile(int, int, Vector3, Vector2)
Creates a new GameTile with specified position and size.
public GameTile(int gridX, int gridY, Vector3 worldPosition, Vector2 size)
Parameters
gridXintGrid X coordinate
gridYintGrid Y coordinate
worldPositionVector33D world position
sizeVector2Tile size (width, height)
Properties
Bounds
public BoundingBox Bounds { get; set; }
Property Value
- BoundingBox
GridX
public int GridX { get; set; }
Property Value
GridY
public int GridY { get; set; }
Property Value
IsDropTarget
public bool IsDropTarget { get; set; }
Property Value
IsHighlighted
public bool IsHighlighted { get; set; }
Property Value
IsInteractable
public bool IsInteractable { get; set; }
Property Value
IsOccupied
public bool IsOccupied { get; set; }
Property Value
IsWalkable
public bool IsWalkable { get; set; }
Property Value
Metadata
public object? Metadata { get; set; }
Property Value
Occupant
public object? Occupant { get; set; }
Property Value
Position
public Vector3 Position { get; set; }
Property Value
Size
public Vector2 Size { get; set; }
Property Value
Type
public TileType Type { get; set; }
Property Value
Methods
ClearOccupant()
Removes any occupant from this tile.
public object? ClearOccupant()
Returns
- object
The removed occupant, if any
ContainsPosition(Vector3)
Checks if a world position is within this tile's bounds.
public bool ContainsPosition(Vector3 worldPosition)
Parameters
worldPositionVector33D world position to test
Returns
- bool
True if position is within tile bounds
GetGridDistance(GameTile)
Gets the 2D distance from this tile to another tile (grid coordinates).
public float GetGridDistance(GameTile other)
Parameters
otherGameTileOther tile
Returns
- float
Grid distance
GetWorldDistance(GameTile)
Gets the world distance from this tile's center to another tile's center.
public float GetWorldDistance(GameTile other)
Parameters
otherGameTileOther tile
Returns
- float
World distance
SetOccupant(object?)
Places an occupant on this tile, removing any previous occupant.
public object? SetOccupant(object? occupant)
Parameters
occupantobjectObject to place on this tile
Returns
- object
The previous occupant, if any
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.