Files
MaidEngine/scripts/test_map_generator.gd
2026-04-01 17:16:58 -04:00

39 lines
1.3 KiB
GDScript

extends Node
const GRID_SIZE := 5
@export var dl_map: CombatMap
@export var unit_template: PackedScene
@export var player_allegiance: UnitAllegiance
@export var enemy_allegiance: UnitAllegiance
func _ready() -> void:
for x in GRID_SIZE:
for y in GRID_SIZE:
var pos := Vector2i(x, y)
var is_edge := x == 0 or x == GRID_SIZE - 1 or y == 0 or y == GRID_SIZE - 1
if is_edge:
dl_map.draw_wall(pos)
else:
dl_map.draw_floor(pos)
# Create a putit at the center belonging to the player
var center := Vector2i(GRID_SIZE / 2, GRID_SIZE / 2)
var unit: Unit = unit_template.instantiate()
unit.stat_template = UnitStats.new(50)
unit.info_template = UnitInfo.new()
unit.allegiance_template = player_allegiance
unit.info_template.name = "Putit"
unit.position = dl_map.coords_to_world(center)
get_parent().add_child.call_deferred(unit)
# Create a putit at one above the center belonging to the enemy
var center_enemy := Vector2i(GRID_SIZE / 2, (GRID_SIZE / 2) - 1)
var enemy_unit: Unit = unit_template.instantiate()
enemy_unit.stat_template = UnitStats.new(50)
enemy_unit.info_template = UnitInfo.new()
enemy_unit.allegiance_template = enemy_allegiance
enemy_unit.info_template.name = "Putit"
enemy_unit.position = dl_map.coords_to_world(center_enemy)
get_parent().add_child.call_deferred(enemy_unit)