- Introduced MapData, MapGenerator, and MapPainter classes for procedural map generation. - Implemented LevelManager to handle level initialization and navigation. - Created TurnManager for managing turn order in a turn-based system. - Added Player and Enemy character classes with movement and turn-taking capabilities. - Established pathfinding using AStar2D in PathfindingHandler. - Integrated new scenes for player and enemy characters, along with world setup. - Included a new tileset for futuristic Zelda-themed assets.
40 lines
1.3 KiB
GDScript
40 lines
1.3 KiB
GDScript
## MapData.gd
|
|
# Resource class that stores all data for a generated map, including tile types, rooms, and spawn points.
|
|
class_name MapData
|
|
extends Resource
|
|
|
|
# Enum for all possible tile types in the map grid.
|
|
# Used to distinguish between empty space, walkable floor, walls, doors, and stairs.
|
|
enum TileType {
|
|
VOID, # Unused/empty space
|
|
FLOOR, # Walkable floor tile
|
|
WALL, # Solid wall tile
|
|
DOOR, # Door tile (can be opened/closed)
|
|
STAIRS # Stairs tile (for level transitions)
|
|
}
|
|
|
|
# The main grid: Dictionary mapping Vector2i coordinates to TileType values.
|
|
# This is the authoritative source for the map's layout.
|
|
@export var grid: Dictionary = {}
|
|
|
|
# The number of rooms generated for this map (set during generation).
|
|
@export var room_count: int = 0
|
|
|
|
# List of all room rectangles (Rect2i) in the map, used for spawning and logic.
|
|
@export var rooms: Array[Rect2i] = []
|
|
|
|
# The starting position for the player (in grid coordinates).
|
|
@export var spawn_point: Vector2i = Vector2i.ZERO
|
|
|
|
# Returns true if the tile at 'coords' is of the given TileType.
|
|
# Used for pathfinding and logic checks.
|
|
func is_tile_type(coords: Vector2i, type: TileType) -> bool:
|
|
return grid.get(coords, TileType.VOID) == type
|
|
|
|
# Clears all map data so this resource can be reused for a new map.
|
|
func clear() -> void:
|
|
grid.clear()
|
|
rooms.clear()
|
|
room_count = 0
|
|
spawn_point = Vector2i.ZERO
|