diff --git a/scenes/combatUIScene.tscn b/scenes/combatUIScene.tscn index f7fe1e1..3313a64 100644 --- a/scenes/combatUIScene.tscn +++ b/scenes/combatUIScene.tscn @@ -195,6 +195,7 @@ alignment = 1 custom_minimum_size = Vector2(64, 64) layout_mode = 2 attack_range = 9999 +auto_damage = 1000 [node name="AbilityA2" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("6_8hwtc")] visible = false @@ -296,5 +297,6 @@ size_flags_horizontal = 3 layout_mode = 2 theme = ExtResource("4_4e8vj") +[connection signal="pressed" from="MarginContainer/UITop/ContinueButton" to="." method="_on_continue_button_pressed"] [connection signal="pressed" from="MarginContainer/UIBottom/UIBottomCenter/MenuButtons/DebugMenu/ButtonTest" to="." method="_on_button_test_pressed"] [connection signal="pressed" from="MarginContainer/UIBottom/UIBottomCenter/MenuButtons/DebugMenu/ButtonExit" to="." method="_on_button_exit_pressed"] diff --git a/scripts/Globals.gd b/scripts/Globals.gd index 215fabb..96ad293 100644 --- a/scripts/Globals.gd +++ b/scripts/Globals.gd @@ -46,3 +46,7 @@ class Ability: DOTB, DOTE } + +func debug_print(value) -> void: + if OS.is_debug_build(): + debug_print(value) diff --git a/scripts/NPCEnemy.gd b/scripts/NPCEnemy.gd index 8933ba3..28c39b4 100644 --- a/scripts/NPCEnemy.gd +++ b/scripts/NPCEnemy.gd @@ -46,7 +46,7 @@ func _process(_delta: float) -> void: func _physics_process(_delta): velocity = position.direction_to(target) * speed # look_at(target) - # FIXME: want enemy to stop when touching something, to prevent vibrating + # BUG: want enemy to stop when touching something, to prevent vibrating if position.distance_to(target) > 10 and get_slide_collision_count() == prevCollisions: move_and_slide() prevCollisions = get_slide_collision_count() diff --git a/scripts/SignalBus.gd b/scripts/SignalBus.gd index 29977ed..61d6500 100644 --- a/scripts/SignalBus.gd +++ b/scripts/SignalBus.gd @@ -10,3 +10,4 @@ signal enemy_died( signal enemy_damaged_player signal quest_generated(quest: Quest) signal quest_completed +signal area_continue_pressed() diff --git a/scripts/WorldArea.gd b/scripts/WorldArea.gd index f803926..b7b956f 100644 --- a/scripts/WorldArea.gd +++ b/scripts/WorldArea.gd @@ -3,20 +3,22 @@ class_name WorldArea extends PanelContainer -enum GoalType { KILL, FIND } +enum GoalType {KILL, FIND} @export var area_type := Globals.World.AreaType.WILDS @export var spawnTimerValue = 10.0 -var middleX : float -var playerPos : Vector2 +var middleX: float +var playerPos: Vector2 func _ready() -> void: middleX = get_viewport_rect().size.x / 2 playerPos = Vector2(middleX, get_viewport_rect().size.y * (0.75)) + SignalBus.area_continue_pressed.connect(_on_area_continue_pressed) + _generate_quest() $SpawnTimer.start(spawnTimerValue) @@ -68,3 +70,13 @@ func _spawn_enemies(numEnemies: int) -> void: func _on_spawn_timer_timeout() -> void: _spawn_enemies(randi_range(1, 5)) + +func _on_area_continue_pressed() -> void: + $SpawnTimer.stop() + Globals.debug_print("spawn timer stopped") + while get_child_count() > 1: + await get_tree().create_timer(1.0).timeout + Globals.debug_print("waiting for children to go to 1 or less") + Globals.debug_print(get_child_count()) + self.queue_free() + Globals.debug_print("area queued tor free") diff --git a/scripts/combat_ui_scene.gd b/scripts/combat_ui_scene.gd index 59c0703..de83cfd 100644 --- a/scripts/combat_ui_scene.gd +++ b/scripts/combat_ui_scene.gd @@ -3,14 +3,13 @@ extends Control - var deltaCount := 0 var enemyMoveSpeed := 5.0 # var questComplete := false var canContinue := false -var middleX -var playerPos +var worldArea: WorldArea +var currentAreaQuest: Quest func _ready() -> void: @@ -31,7 +30,7 @@ func _process(_delta: float) -> void: func _create_area() -> void: - var worldArea = load("res://scenes/world_area.tscn").instantiate() + worldArea = load("res://scenes/world_area.tscn").instantiate() add_child(worldArea) move_child(worldArea, 0) @@ -48,14 +47,31 @@ func _continue_show() -> void: %UITop/ContinueButton.modulate.a += 0.05 +func _go_next_area() -> void: + var prevAreaQuest = currentAreaQuest + # FIXME: breaks at some point? + SignalBus.area_continue_pressed.emit() + Globals.debug_print("gna signal emitted") + %QuestsContainer.remove_child(prevAreaQuest) + Globals.debug_print("gna quest removed") + prevAreaQuest.queue_free() + Globals.debug_print("gna quest queued to free") + _create_area() + Globals.debug_print("gna new area created") + + func _on_quest_generated(quest) -> void: - %QuestsContainer.add_child(quest) + currentAreaQuest = quest + %QuestsContainer.add_child(currentAreaQuest) # TODO: move all quest stuff to quest class? func _on_quest_completed() -> void: if %UITop/AutoCheck.button_pressed: - # TODO: eventually add new area progress trigger - pass + _go_next_area() else: canContinue = true + + +func _on_continue_button_pressed() -> void: + _go_next_area()