Represents a single game level containing terrain tiles, item placements, and movement validation logic.
More...
|
| | Level (int width, int height) |
| | Initializes a new instance of the Level class.
|
| |
| Tile | GetTile (int x, int y) |
| | Retrieves the tile at the specified coordinates.
|
| |
| void | SetTile (int x, int y, Tile tile) |
| | Sets the tile at the specified coordinates.
|
| |
| void | TryMoveCharacter (Character.Character character, Position nPos) |
| | Attempts to move a character to a new position if the move is valid. Also handles item interactions for players.
|
| |
| bool | IsMoveValid (Character.Character character, Position nPos) |
| | Determines whether a character can move to the specified position.
|
| |
| bool | IsInBounds (Position pos) |
| | Checks whether the specified position lies within the level boundaries.
|
| |
| void | AddItem (Position pos, IItem item) |
| | Adds an item to the specified position in the level.
|
| |
| IReadOnlyList< IItem > | GetItemsAt (Position pos) |
| | Retrieves all items located at a given position.
|
| |
| IItem? | GetTopItem (Position pos) |
| | Retrieves the top item at a position without removing it.
|
| |
| IItem? | TakeTopItem (Position pos) |
| | Removes and returns the top item at a given position.
|
| |
| int | TotalItemsAt (Position pos) |
| | Returns the total number of items at a given position.
|
| |
| bool | HasItems (Position pos) |
| | Determines whether any items exist at a given position.
|
| |
|
|
int | Width [get] |
| | Width of the level in tiles.
|
| |
|
int | Height [get] |
| | Height of the level in tiles.
|
| |
Represents a single game level containing terrain tiles, item placements, and movement validation logic.
The Level class acts as the central authority for world state. It manages:
- Tile grid storage
- Item placement on the ground
- Movement validation for characters
The class enforces boundary rules and ensures characters cannot move into non-walkable or occupied tiles.
◆ Level()
| RpgGame.Core.Level.Level |
( |
int |
width, |
|
|
int |
height |
|
) |
| |
|
inline |
Initializes a new instance of the Level class.
- Parameters
-
| width | Width of the level grid. |
| height | Height of the level grid. |
◆ AddItem()
| void RpgGame.Core.Level.AddItem |
( |
Position |
pos, |
|
|
IItem |
item |
|
) |
| |
|
inline |
Adds an item to the specified position in the level.
- Parameters
-
| pos | The position where the item should be placed. |
| item | The item to add. |
◆ GetItemsAt()
| IReadOnlyList< IItem > RpgGame.Core.Level.GetItemsAt |
( |
Position |
pos | ) |
|
|
inline |
Retrieves all items located at a given position.
- Parameters
-
| pos | The position to query. |
- Returns
- A read-only list of items at the specified position. Returns an empty list if no items are present.
◆ GetTile()
| Tile RpgGame.Core.Level.GetTile |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
|
inline |
Retrieves the tile at the specified coordinates.
- Parameters
-
| x | Horizontal coordinate. |
| y | Vertical coordinate. |
- Returns
- The tile located at the given position.
◆ GetTopItem()
| IItem? RpgGame.Core.Level.GetTopItem |
( |
Position |
pos | ) |
|
|
inline |
Retrieves the top item at a position without removing it.
- Parameters
-
| pos | The position to query. |
- Returns
- The first item in the stack if present; otherwise null.
◆ HasItems()
| bool RpgGame.Core.Level.HasItems |
( |
Position |
pos | ) |
|
|
inline |
Determines whether any items exist at a given position.
- Parameters
-
| pos | The position to check. |
- Returns
- True if items exist; otherwise false.
◆ IsInBounds()
| bool RpgGame.Core.Level.IsInBounds |
( |
Position |
pos | ) |
|
|
inline |
Checks whether the specified position lies within the level boundaries.
- Parameters
-
| pos | The position to check. |
- Returns
- True if the position is within bounds; otherwise false.
◆ IsMoveValid()
Determines whether a character can move to the specified position.
- Parameters
-
| character | The character attempting to move. |
| nPos | The target position. |
- Returns
- True if the move is within bounds, walkable, and unoccupied; otherwise false.
◆ SetTile()
| void RpgGame.Core.Level.SetTile |
( |
int |
x, |
|
|
int |
y, |
|
|
Tile |
tile |
|
) |
| |
|
inline |
Sets the tile at the specified coordinates.
- Parameters
-
| x | Horizontal coordinate. |
| y | Vertical coordinate. |
| tile | The tile to assign. |
- Exceptions
-
| ArgumentNullException | Thrown if the tile parameter is null. |
◆ TakeTopItem()
| IItem? RpgGame.Core.Level.TakeTopItem |
( |
Position |
pos | ) |
|
|
inline |
Removes and returns the top item at a given position.
- Parameters
-
| pos | The position from which to take the item. |
- Returns
- The removed item if present; otherwise null.
◆ TotalItemsAt()
| int RpgGame.Core.Level.TotalItemsAt |
( |
Position |
pos | ) |
|
|
inline |
Returns the total number of items at a given position.
- Parameters
-
| pos | The position to query. |
- Returns
- The number of items at that position.
◆ TryMoveCharacter()
Attempts to move a character to a new position if the move is valid. Also handles item interactions for players.
- Parameters
-
| character | The character attempting to move. |
| nPos | The target position. |
The documentation for this class was generated from the following file: