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

@@ -2,13 +2,9 @@
[ext_resource type="PackedScene" uid="uid://cy7r0udfcsqbn" path="res://prefabs/combat_ui.tscn" id="1_5jbmu"]
[ext_resource type="PackedScene" uid="uid://dkhyh5ce4iuk3" path="res://prefabs/combat_map.tscn" id="1_7abyo"]
[ext_resource type="Script" uid="uid://c8xb86ty7rduf" path="res://scripts/test_map_generator.gd" id="2_ekcfv"]
[ext_resource type="Script" uid="uid://csdcbi2gtwrly" path="res://scripts/camera_controller.gd" id="3_cam"]
[ext_resource type="Script" uid="uid://dfojm3n0em4ef" path="res://nodes/player_controller.gd" id="4_s5ga2"]
[ext_resource type="AudioStream" uid="uid://dsikulned64qt" path="res://assets/music/combat_bgm_01.OGG" id="6_0yobm"]
[ext_resource type="PackedScene" uid="uid://b6a7nlnf58mc4" path="res://prefabs/unit.tscn" id="6_rfoto"]
[ext_resource type="Resource" uid="uid://dufi2h00j5vrq" path="res://resources/allegiance_types/player_allegiance.tres" id="7_0wg56"]
[ext_resource type="Resource" uid="uid://cuc7kkknpsr1g" path="res://resources/allegiance_types/enemy_allegiance.tres" id="8_w105o"]
[node name="CombatTest" type="Node2D" unique_id=855645983]
@@ -24,12 +20,6 @@ dl_map = NodePath("../CombatMap")
zoom = Vector2(1.5, 1.5)
script = ExtResource("3_cam")
[node name="TestMapGenerator" type="Node" parent="." unique_id=833658301 node_paths=PackedStringArray("dl_map")]
script = ExtResource("2_ekcfv")
dl_map = NodePath("../CombatMap")
unit_template = ExtResource("6_rfoto")
player_allegiance = ExtResource("7_0wg56")
enemy_allegiance = ExtResource("8_w105o")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="." unique_id=1057500234]
stream = ExtResource("6_0yobm")

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"]