From 06647b11ee163bc40daf454d87e1fcae563c3ced Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 23 May 2024 14:11:43 +0200 Subject: update --- Scenes/Components/TileMap.gd | 1 + Scenes/Entities/Bombs/Bomb.gd | 2 +- Scenes/Entities/Enemies/Components/Health.gd | 5 +- Scenes/Entities/Enemies/Projectile.gd | 2 +- Scenes/Entities/Enemies/Tree.gd | 5 ++ Scenes/Entities/Enemies/Tree.tscn | 2 +- Scenes/Entities/Objects/BaseDoor.tscn | 1 + Scenes/Entities/Objects/Tree.tscn | 1 + Scenes/Entities/Player.gd | 63 +++++++++++--------- Scenes/Entities/Player.tscn | 1 - Scenes/Maps/Base01.gd | 32 +++++----- Scenes/Maps/Base01.tscn | 2 +- Scenes/Maps/World3.gd | 12 ---- Scenes/Maps/World3.tscn | 2 +- Scenes/UI/Menu.gd | 88 +++++++++++++++++++++++----- Scenes/UI/Menu.tscn | 51 ++++++++++++++++ Scenes/Utilities.gd | 16 ++++- 17 files changed, 208 insertions(+), 78 deletions(-) (limited to 'Scenes') diff --git a/Scenes/Components/TileMap.gd b/Scenes/Components/TileMap.gd index 961bf5e..aea3677 100644 --- a/Scenes/Components/TileMap.gd +++ b/Scenes/Components/TileMap.gd @@ -2,4 +2,5 @@ extends TileMap func _ready(): + process_mode = Node.PROCESS_MODE_DISABLED visible = false diff --git a/Scenes/Entities/Bombs/Bomb.gd b/Scenes/Entities/Bombs/Bomb.gd index 7a1a9eb..0456c15 100644 --- a/Scenes/Entities/Bombs/Bomb.gd +++ b/Scenes/Entities/Bombs/Bomb.gd @@ -18,7 +18,7 @@ enum COMPONENT_TYPE { var ExplosionScene = preload("res://Scenes/Entities/Bombs/Explosion.tscn") var power: int = 2 -var components: Array[COMPONENT_TYPE] = [] +var components: Dictionary = {} func _ready(): diff --git a/Scenes/Entities/Enemies/Components/Health.gd b/Scenes/Entities/Enemies/Components/Health.gd index 6f65e79..2bd2447 100644 --- a/Scenes/Entities/Enemies/Components/Health.gd +++ b/Scenes/Entities/Enemies/Components/Health.gd @@ -21,6 +21,8 @@ var drop_items = [ preload("res://Scenes/Entities/Objects/Coin.tscn"), ] +var is_dying = false + func _ready(): if component_movement_path: @@ -30,11 +32,12 @@ func _ready(): func take_damage(): health -= 1 - if health <= 0: + if health <= 0 and not is_dying: death() func death(): + is_dying = true emit_signal("died") if component_movement: # stop all movement diff --git a/Scenes/Entities/Enemies/Projectile.gd b/Scenes/Entities/Enemies/Projectile.gd index af283b4..02a1470 100644 --- a/Scenes/Entities/Enemies/Projectile.gd +++ b/Scenes/Entities/Enemies/Projectile.gd @@ -13,7 +13,7 @@ func _ready(): velocity = position.direction_to(target) * speed -func _physics_process(delta): +func _physics_process(_delta): $AnimatedSprite2D.play("default") move_and_slide() diff --git a/Scenes/Entities/Enemies/Tree.gd b/Scenes/Entities/Enemies/Tree.gd index 5572e02..bbd02a9 100644 --- a/Scenes/Entities/Enemies/Tree.gd +++ b/Scenes/Entities/Enemies/Tree.gd @@ -3,6 +3,7 @@ extends CharacterBody2D @onready var component_collision: ComponentCollision = $Collision @onready var component_movement: ComponentMovement = $Movement +@onready var component_health: ComponentHealth = $Health func _ready(): @@ -16,6 +17,10 @@ func _ready(): $AnimatedSprite2D.play("spawn") $AnimatedSprite2D.stop() $AnimatedSprite2D.set_frame_and_progress(0, 0) + + $Health.connect("died", func(): + $Detection.set_collision_mask_value(Utilities.Collision.Layer.PLAYER, false) + ) func _physics_process(delta): diff --git a/Scenes/Entities/Enemies/Tree.tscn b/Scenes/Entities/Enemies/Tree.tscn index 3a0de4a..f216159 100644 --- a/Scenes/Entities/Enemies/Tree.tscn +++ b/Scenes/Entities/Enemies/Tree.tscn @@ -141,7 +141,7 @@ script = ExtResource("1_ktvfx") texture_filter = 1 position = Vector2(0, -8) sprite_frames = SubResource("SpriteFrames_c5ryj") -animation = &"spawn" +animation = &"death_post" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, -8) diff --git a/Scenes/Entities/Objects/BaseDoor.tscn b/Scenes/Entities/Objects/BaseDoor.tscn index 845c35d..3a1fcc4 100644 --- a/Scenes/Entities/Objects/BaseDoor.tscn +++ b/Scenes/Entities/Objects/BaseDoor.tscn @@ -7,6 +7,7 @@ size = Vector2(16, 16) [node name="BaseDoor" type="StaticBody2D"] +z_index = -2 collision_layer = 8 collision_mask = 0 script = ExtResource("1_silnh") diff --git a/Scenes/Entities/Objects/Tree.tscn b/Scenes/Entities/Objects/Tree.tscn index fdffec1..09e4fee 100644 --- a/Scenes/Entities/Objects/Tree.tscn +++ b/Scenes/Entities/Objects/Tree.tscn @@ -15,6 +15,7 @@ a = Vector2(0, -18) b = Vector2(0, 1) [node name="Tree" type="StaticBody2D"] +z_index = -1 texture_filter = 1 collision_layer = 8 collision_mask = 32 diff --git a/Scenes/Entities/Player.gd b/Scenes/Entities/Player.gd index 1e4b0c2..e8e9fbb 100644 --- a/Scenes/Entities/Player.gd +++ b/Scenes/Entities/Player.gd @@ -14,10 +14,11 @@ const THROW_DISTANCE = 3 @export var BombScene: PackedScene = preload("res://Scenes/Entities/Bombs/Bomb__Normal.tscn") @export var bomb_power: int = 2 @export var max_bombs: int = 5 -@export var bomb_components: Array[Bomb.COMPONENT_TYPE] = [ - Bomb.COMPONENT_TYPE.REMOTE_CONTROL, - Bomb.COMPONENT_TYPE.REMOTE_DETONATE -] +@export var bomb_components: Dictionary = { + 0: Bomb.COMPONENT_TYPE.REMOTE_CONTROL, + 1: Bomb.COMPONENT_TYPE.REMOTE_DETONATE, + 2: -1, +} var bombs: Array = [] var last_planted_bomb: Bomb @@ -52,14 +53,16 @@ func _ready(): func _process(delta): - if (self.bomb_components.has(Bomb.COMPONENT_TYPE.REMOTE_DETONATE) + if (self.bomb_components.find_key(Bomb.COMPONENT_TYPE.REMOTE_DETONATE) != null and Input.is_action_just_pressed("ui_cancel")): if self.bombs.size() > 0: - self.bombs[self.bombs.size() - 1].explode() + #self.bombs[self.bombs.size() - 1].explode() + self.bombs[0].explode() - if (self.bomb_components.has(Bomb.COMPONENT_TYPE.REMOTE_CONTROL) + if (self.bomb_components.find_key(Bomb.COMPONENT_TYPE.REMOTE_CONTROL) != null and self.last_planted_bomb and Input.is_action_pressed("ui_accept") and self.just_planted_bomb and self.accumulated_bomb_wait_delta >= delta * self.bomb_wait_delta_mutiplier): + play_idle() if Input.is_action_pressed("ui_left"): self.last_planted_bomb.position.x -= SPEED * delta if Input.is_action_pressed("ui_right"): @@ -79,22 +82,24 @@ func _process(delta): self.DIRECTIONS = [] if Input.is_action_pressed("ui_left"): - velocity.x -= SPEED + velocity.x -= 1 self.DIRECTIONS.append(Vector2.LEFT) self.DIRECTION = Vector2.LEFT if Input.is_action_pressed("ui_right"): - velocity.x += SPEED + velocity.x += 1 self.DIRECTIONS.append(Vector2.RIGHT) self.DIRECTION = Vector2.RIGHT if Input.is_action_pressed("ui_up"): - velocity.y -= SPEED + velocity.y -= 1 self.DIRECTIONS.append(Vector2.UP) self.DIRECTION = Vector2.UP if Input.is_action_pressed("ui_down"): - velocity.y += SPEED + velocity.y += 1 self.DIRECTION = Vector2.DOWN self.DIRECTIONS.append(Vector2.DOWN) + velocity = velocity.normalized() * SPEED + var last_animation = $AnimatedSprite2D.animation var frame = $AnimatedSprite2D.frame var progress = $AnimatedSprite2D.frame_progress @@ -117,22 +122,7 @@ func _process(delta): $AnimatedSprite2D.play("bottom_right") else: - if self.LAST_DIRECTIONS == [Vector2.LEFT]: - $AnimatedSprite2D.play("idle_left") - elif self.LAST_DIRECTIONS == [Vector2.RIGHT]: - $AnimatedSprite2D.play("idle_right") - elif self.LAST_DIRECTIONS == [Vector2.UP]: - $AnimatedSprite2D.play("idle_up") - elif self.LAST_DIRECTIONS == [Vector2.DOWN]: - $AnimatedSprite2D.play("idle_down") - elif self.LAST_DIRECTIONS == [Vector2.LEFT, Vector2.UP]: - $AnimatedSprite2D.play("idle_top_left") - elif self.LAST_DIRECTIONS == [Vector2.RIGHT, Vector2.UP]: - $AnimatedSprite2D.play("idle_top_right") - elif self.LAST_DIRECTIONS == [Vector2.LEFT, Vector2.DOWN]: - $AnimatedSprite2D.play("idle_bottom_left") - elif self.LAST_DIRECTIONS == [Vector2.RIGHT, Vector2.DOWN]: - $AnimatedSprite2D.play("idle_bottom_right") + play_idle() if last_animation != $AnimatedSprite2D.animation: $AnimatedSprite2D.set_frame_and_progress(frame, progress) @@ -296,6 +286,25 @@ func heal(amount: int): self.emit_signal("health_changed", self.health) +func play_idle(): + if self.LAST_DIRECTIONS == [Vector2.LEFT]: + $AnimatedSprite2D.play("idle_left") + elif self.LAST_DIRECTIONS == [Vector2.RIGHT]: + $AnimatedSprite2D.play("idle_right") + elif self.LAST_DIRECTIONS == [Vector2.UP]: + $AnimatedSprite2D.play("idle_up") + elif self.LAST_DIRECTIONS == [Vector2.DOWN]: + $AnimatedSprite2D.play("idle_down") + elif self.LAST_DIRECTIONS == [Vector2.LEFT, Vector2.UP]: + $AnimatedSprite2D.play("idle_top_left") + elif self.LAST_DIRECTIONS == [Vector2.RIGHT, Vector2.UP]: + $AnimatedSprite2D.play("idle_top_right") + elif self.LAST_DIRECTIONS == [Vector2.LEFT, Vector2.DOWN]: + $AnimatedSprite2D.play("idle_bottom_left") + elif self.LAST_DIRECTIONS == [Vector2.RIGHT, Vector2.DOWN]: + $AnimatedSprite2D.play("idle_bottom_right") + + func is_in_interaction_area(): if collision_area.has_overlapping_areas(): for area in collision_area.get_overlapping_areas(): diff --git a/Scenes/Entities/Player.tscn b/Scenes/Entities/Player.tscn index 4d92b3a..caf6c7c 100644 --- a/Scenes/Entities/Player.tscn +++ b/Scenes/Entities/Player.tscn @@ -240,7 +240,6 @@ size = Vector2(14, 14) collision_layer = 2 collision_mask = 236 motion_mode = 1 -wall_min_slide_angle = 1.5708 script = ExtResource("1_2xulf") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] diff --git a/Scenes/Maps/Base01.gd b/Scenes/Maps/Base01.gd index 83947e4..96e5520 100644 --- a/Scenes/Maps/Base01.gd +++ b/Scenes/Maps/Base01.gd @@ -69,18 +69,20 @@ func place_boxes( var tile_size = tilemap.tile_set.tile_size for entity in entry_entities: placeable_cells.erase(tilemap.local_to_map(entity.position)) - placeable_cells.erase(tilemap.local_to_map( - entity.position + Vector2(0, tile_size.y) - )) - placeable_cells.erase(tilemap.local_to_map( - entity.position + Vector2(tile_size.x, 0) - )) - placeable_cells.erase(tilemap.local_to_map( - entity.position + Vector2(0, -tile_size.y) - )) - placeable_cells.erase(tilemap.local_to_map( - entity.position + Vector2(-tile_size.x, 0) - )) + # erase in 2 times around + for n in range(1, 3): + placeable_cells.erase(tilemap.local_to_map( + entity.position + Vector2(0, tile_size.y * n) + )) + placeable_cells.erase(tilemap.local_to_map( + entity.position + Vector2(tile_size.x * n, 0) + )) + placeable_cells.erase(tilemap.local_to_map( + entity.position + Vector2(0, -tile_size.y * n) + )) + placeable_cells.erase(tilemap.local_to_map( + entity.position + Vector2(-tile_size.x * n, 0) + )) if include_edges: var rect := tilemap.get_used_rect() @@ -103,14 +105,12 @@ func handle_doors(doors: Array, condition): for door in doors: door.enable() - if condition.check(): - for door in doors: - door.disable() - condition.fulfilled.connect(func(): for door in doors: door.disable() ) + + condition.check() func door_condition_enemies(enemies: Array): var condition = Utilities.Condition.new() diff --git a/Scenes/Maps/Base01.tscn b/Scenes/Maps/Base01.tscn index 129a7fe..a8d209a 100644 --- a/Scenes/Maps/Base01.tscn +++ b/Scenes/Maps/Base01.tscn @@ -133,7 +133,7 @@ position = Vector2(-360, -440) shape = SubResource("RectangleShape2D_gndue") [node name="InitialPlayerPosition" type="Node2D" parent="."] -position = Vector2(-120, -328) +position = Vector2(-120, -376) [editable path="Areas/MapArea"] [editable path="Areas/MapArea2"] diff --git a/Scenes/Maps/World3.gd b/Scenes/Maps/World3.gd index d9e8399..1daecb9 100644 --- a/Scenes/Maps/World3.gd +++ b/Scenes/Maps/World3.gd @@ -31,31 +31,19 @@ func _ready(): get_node("Areas/Beta01/Transitions/Height1").body_entered.connect(func(body): body.z_index = 3 - if body is Player: - print(body.z_index) ) get_node("Areas/Beta01/Transitions/Height1").body_exited.connect(func(body): body.z_index = 0 - if body is Player: - print(body.z_index) ) get_node("Areas/Beta01/Transitions/Height2").body_entered.connect(func(body): body.z_index = 5 - if body is Player: - print(body.z_index) ) get_node("Areas/Beta01/Transitions/Height2").body_exited.connect(func(body): body.z_index = 3 - if body is Player: - print(body.z_index) ) get_node("Areas/Beta02/Transitions/Height1").body_entered.connect(func(body): body.z_index = 3 - if body is Player: - print(body.z_index) ) get_node("Areas/Beta02/Transitions/Height1").body_exited.connect(func(body): body.z_index = 0 - if body is Player: - print(body.z_index) ) diff --git a/Scenes/Maps/World3.tscn b/Scenes/Maps/World3.tscn index 0962a38..698a979 100644 --- a/Scenes/Maps/World3.tscn +++ b/Scenes/Maps/World3.tscn @@ -480,7 +480,7 @@ collision_mask = 18 polygon = PackedVector2Array(-1296, -592, -1160, -592, -1160, -636, -1328, -637, -1328, -616, -1368, -616, -1368, -496, -1352, -496, -1352, -464, -1256, -464, -1256, -504, -1288, -504, -1288, -488, -1320, -488, -1320, -520, -1336, -520, -1336, -592) [node name="InitialPlayerPosition" type="Node2D" parent="."] -position = Vector2(-1416, -528) +position = Vector2(24, 128) [editable path="Areas/Alpha"] [editable path="Areas/LForest1"] diff --git a/Scenes/UI/Menu.gd b/Scenes/UI/Menu.gd index ce45a26..9b41b20 100644 --- a/Scenes/UI/Menu.gd +++ b/Scenes/UI/Menu.gd @@ -3,24 +3,39 @@ extends TabContainer @onready var audio_bus = AudioServer.get_bus_index("Master") +@onready var focused_tab = 0 +@onready var focused_tab_elements: Dictionary = { + 0: $Bombs/Panel/HBoxContainer/VBoxContainer/ButtonBombNormal, + 1: $System/Panel/VBoxContainer/ButtonResume, +} +@onready var exclude_from_focus = [ + %BombComponents, +] + +var current_slot_idx = 0 + func _ready(): hide() self._ready_bombs() self._ready_system() + + var tabs = get_children() + for idx in tabs.size(): + for child in Utilities.get_all_children(tabs[idx]): + if child is Control and not exclude_from_focus.has(child): + child.focus_entered.connect(func(): + focused_tab_elements[idx] = child + ) func _input(event: InputEvent): if event.is_action_pressed("ui_menu"): - print(Global.player.position) - print("pressed") if get_tree().paused: # game is paused self.close_menu() - print("was paused") else: # game is running self.open_menu() - print("was running") if event.is_action_pressed("ui_menu_left"): if get_current_tab() > 0: @@ -29,29 +44,29 @@ func _input(event: InputEvent): if get_current_tab() < get_tab_count() - 1: set_current_tab(get_current_tab() + 1) - connect("tab_changed", func(tab_id): - if tab_id == 0: - (func(): $Bombs/Panel/HBoxContainer/VBoxContainer/ButtonBombNormal.grab_focus()).call_deferred() - elif tab_id == 1: - (func(): $System/Panel/VBoxContainer/ButtonResume.grab_focus()).call_deferred() + tab_changed.connect(func(tab_idx): + focused_tab = tab_idx + (func(): focused_tab_elements[tab_idx].grab_focus()).call_deferred() ) + + _input_bombs(event) func open_menu(): get_tree().paused = true + tab_changed.emit(focused_tab) show() - - (func(): $Bombs/Panel/HBoxContainer/VBoxContainer/ButtonBombNormal.grab_focus()).call_deferred() func close_menu(): + %BombComponents.hide() + hide() get_tree().paused = false func get_player(): return Global.player - #return get_tree().get_current_scene().get_node("Player") ### Bombs ### @@ -61,6 +76,19 @@ func _ready_bombs(): for component in Bomb.COMPONENT_TYPE: var idx = Bomb.COMPONENT_TYPE[component] $Bombs/Panel/HBoxContainer/VBoxContainer3/BombComponents.set_item_text(idx, component.capitalize()) + + for idx in Global.player.bomb_components.size(): + var component = Bomb.COMPONENT_TYPE.find_key(Global.player.bomb_components[idx]) + if component: + $Bombs/Panel/HBoxContainer/VBoxContainer3/VBoxContainer.get_node("Slot" + str(idx+1)).text = component.capitalize() + + %BombComponents.item_activated.connect(Callable(self, "_on_bomb_components_item_selected")) + + +func _input_bombs(event): + if %BombComponents.visible and event.is_action_pressed("ui_cancel"): + %BombComponents.hide() + focused_tab_elements[focused_tab].grab_focus() func _on_button_bomb_normal_pressed(): @@ -77,9 +105,39 @@ func _on_bomb_power_item_selected(index): func _on_bomb_components_multi_selected(_index, _selected): - Global.player.bomb_components = [] - for idx in $Bombs/Panel/HBoxContainer/VBoxContainer3/BombComponents.get_selected_items(): - Global.player.bomb_components.append(idx) # same as enum idx + pass + #Global.player.bomb_components = {} + #for idx in $Bombs/Panel/HBoxContainer/VBoxContainer3/BombComponents.get_selected_items(): + #Global.player.bomb_components.append(idx) # same as enum idx + + +func _on_slot_pressed(slot_idx): + %BombComponents.clear() + + for component in Bomb.COMPONENT_TYPE: + var idx = Bomb.COMPONENT_TYPE[component] + %BombComponents.add_item( + component.capitalize(), + null, + Global.player.bomb_components.find_key(idx) == null + ) + # todo position swap + # make all selectable + # but when already in bomb_components, swap position + # nonetheless, hightlight already selected item differently + + %BombComponents.show() + %BombComponents.force_update_list_size() + %BombComponents.grab_focus() + + current_slot_idx = slot_idx + + +func _on_bomb_components_item_selected(idx): + Global.player.bomb_components[current_slot_idx] = idx + %BombComponents.hide() + $Bombs/Panel/HBoxContainer/VBoxContainer3/VBoxContainer.get_node("Slot" + str(current_slot_idx+1)).grab_focus() + $Bombs/Panel/HBoxContainer/VBoxContainer3/VBoxContainer.get_node("Slot" + str(current_slot_idx+1)).text = Bomb.COMPONENT_TYPE.find_key(idx).capitalize() ### System ### diff --git a/Scenes/UI/Menu.tscn b/Scenes/UI/Menu.tscn index 38c3ee4..e7c7b13 100644 --- a/Scenes/UI/Menu.tscn +++ b/Scenes/UI/Menu.tscn @@ -32,6 +32,7 @@ theme_override_font_sizes/font_size = 5 theme_override_styles/panel = SubResource("StyleBoxFlat_flq5r") theme_override_styles/tabbar_background = SubResource("StyleBoxFlat_u0ugs") clip_tabs = false +tab_focus_mode = 0 script = ExtResource("1_vwah3") [node name="Bombs" type="MarginContainer" parent="."] @@ -101,6 +102,7 @@ text = "Components" label_settings = SubResource("LabelSettings_qokw0") [node name="BombComponents" type="ItemList" parent="Bombs/Panel/HBoxContainer/VBoxContainer3"] +visible = false layout_mode = 2 theme_override_font_sizes/font_size = 4 select_mode = 1 @@ -114,6 +116,52 @@ item_2/text = "RemoteDetonate" item_3/text = "Water" item_4/text = "Salt" +[node name="VBoxContainer" type="VBoxContainer" parent="Bombs/Panel/HBoxContainer/VBoxContainer3"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="Slot1" type="Button" parent="Bombs/Panel/HBoxContainer/VBoxContainer3/VBoxContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 4 +text = "Empty" +flat = true + +[node name="Slot2" type="Button" parent="Bombs/Panel/HBoxContainer/VBoxContainer3/VBoxContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 4 +text = "Empty" +flat = true + +[node name="Slot3" type="Button" parent="Bombs/Panel/HBoxContainer/VBoxContainer3/VBoxContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 4 +text = "Empty" +flat = true + +[node name="MarginContainer" type="MarginContainer" parent="Bombs/Panel"] +layout_mode = 2 +offset_right = 232.0 +offset_bottom = 136.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="CenterContainer" type="CenterContainer" parent="Bombs/Panel/MarginContainer"] +layout_mode = 2 + +[node name="BombComponents" type="ItemList" parent="Bombs/Panel/MarginContainer/CenterContainer"] +unique_name_in_owner = true +visible = false +custom_minimum_size = Vector2(50, 0) +layout_mode = 2 +theme_override_font_sizes/font_size = 4 +auto_height = true +text_overrun_behavior = 0 +fixed_column_width = 500 + [node name="System" type="MarginContainer" parent="."] visible = false layout_mode = 2 @@ -167,6 +215,9 @@ step = 0.05 [connection signal="pressed" from="Bombs/Panel/HBoxContainer/VBoxContainer/ButtonBombBreakables" to="." method="_on_button_bomb_breakables_pressed"] [connection signal="item_selected" from="Bombs/Panel/HBoxContainer/VBoxContainer2/BombPower" to="." method="_on_bomb_power_item_selected"] [connection signal="multi_selected" from="Bombs/Panel/HBoxContainer/VBoxContainer3/BombComponents" to="." method="_on_bomb_components_multi_selected"] +[connection signal="pressed" from="Bombs/Panel/HBoxContainer/VBoxContainer3/VBoxContainer/Slot1" to="." method="_on_slot_pressed" binds= [0]] +[connection signal="pressed" from="Bombs/Panel/HBoxContainer/VBoxContainer3/VBoxContainer/Slot2" to="." method="_on_slot_pressed" binds= [1]] +[connection signal="pressed" from="Bombs/Panel/HBoxContainer/VBoxContainer3/VBoxContainer/Slot3" to="." method="_on_slot_pressed" binds= [2]] [connection signal="pressed" from="System/Panel/VBoxContainer/ButtonResume" to="." method="_on_button_resume_pressed"] [connection signal="pressed" from="System/Panel/VBoxContainer/ButtonQuit" to="." method="_on_button_quit_pressed"] [connection signal="value_changed" from="System/Panel/VBoxContainer2/SliderVolume" to="." method="_on_slider_volume_value_changed"] diff --git a/Scenes/Utilities.gd b/Scenes/Utilities.gd index 87c3539..092e853 100644 --- a/Scenes/Utilities.gd +++ b/Scenes/Utilities.gd @@ -106,6 +106,16 @@ func get_enemy_children(parent: Node): ) +func get_all_children(parent: Node): + var children = [] + + for child in parent.get_children(): + children.append(child) + children += get_all_children(child) + + return children + + func get_collision_shape_bounds(collision_shape: CollisionShape2D): var shape: Shape2D = collision_shape.shape var bounds @@ -188,4 +198,8 @@ class Condition: var function: Callable func check(): - return function.call() + var is_fulfilled = function.call() + if is_fulfilled: + fulfilled.emit() + + return is_fulfilled -- cgit v1.2.3