Change how map loading works

This commit is contained in:
gamer147
2026-04-01 17:48:47 -04:00
parent 0233cb6f46
commit 470e89b15b
6 changed files with 84 additions and 56 deletions

View File

@@ -7,9 +7,45 @@
resource_name = "StartButton"
script/source = "extends Button
const COMBAT_SCENE = preload(\"res://scenes/combat_test.tscn\")
const UNIT_SCENE = preload(\"res://prefabs/unit.tscn\")
const PLAYER_ALLEGIANCE = preload(\"res://resources/allegiance_types/player_allegiance.tres\")
const ENEMY_ALLEGIANCE = preload(\"res://resources/allegiance_types/enemy_allegiance.tres\")
const MAP_LAYOUT := \"\"\"\\
#####
#...#
#...#
#...#
#####\"\"\"
func _pressed() -> void:
get_parent().queue_free()
get_tree().change_scene_to_file(\"res://scenes/combat_test.tscn\")
var combat_instance := COMBAT_SCENE.instantiate()
var combat_map: CombatMap = combat_instance.find_child(\"CombatMap\")
combat_map.load_map(MAP_LAYOUT)
var player_unit: Unit = UNIT_SCENE.instantiate()
player_unit.stat_template = UnitStats.new(50)
player_unit.info_template = UnitInfo.new()
player_unit.info_template.name = \"Putit\"
player_unit.allegiance_template = PLAYER_ALLEGIANCE
combat_map.deploy_unit(player_unit, Vector2i(2, 2))
var enemy_unit: Unit = UNIT_SCENE.instantiate()
enemy_unit.stat_template = UnitStats.new(50)
enemy_unit.info_template = UnitInfo.new()
enemy_unit.info_template.name = \"Putit\"
enemy_unit.allegiance_template = ENEMY_ALLEGIANCE
combat_map.deploy_unit(enemy_unit, Vector2i(2, 1))
var tree := get_tree()
var root := tree.root
var current_scene := tree.current_scene
root.remove_child(current_scene)
current_scene.queue_free()
root.add_child(combat_instance)
tree.current_scene = combat_instance
"
[sub_resource type="GDScript" id="GDScript_ekxnf"]