diff --git a/collector/collectible.tscn b/collector/collectible.tscn index 7f6b2a1..0713a93 100644 --- a/collector/collectible.tscn +++ b/collector/collectible.tscn @@ -1,6 +1,9 @@ -[gd_scene load_steps=2 format=3 uid="uid://bk1vvq5rug01m"] +[gd_scene load_steps=3 format=3 uid="uid://bk1vvq5rug01m"] [ext_resource type="Script" path="res://collector/collectible.gd" id="1_qilbk"] +[ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="2_2nvfu"] [node name="Collectible" type="Node"] script = ExtResource("1_qilbk") + +[node name="Valuable" parent="." instance=ExtResource("2_2nvfu")] diff --git a/collector/collector.gd b/collector/collector.gd index c9a4266..1f80778 100644 --- a/collector/collector.gd +++ b/collector/collector.gd @@ -31,9 +31,11 @@ func _on_body_entered(body: Node2D): if body.collision_layer & collecting_collision_mask: var collectible: Collectible = body.get_node("Collectible") if collectible.type in collecting_types: + print("collezionato") collected_count += 1 collectible.collect() emit_signal("collected", body) if collected_count >= collecting_amount: + print("goal") emit_signal("goal") collected_count = 0 diff --git a/collector/collector.tscn b/collector/collector.tscn index 0273735..85a12d3 100644 --- a/collector/collector.tscn +++ b/collector/collector.tscn @@ -1,8 +1,15 @@ -[gd_scene load_steps=2 format=3 uid="uid://c5w3b55aiui6c"] +[gd_scene load_steps=3 format=3 uid="uid://c5w3b55aiui6c"] [ext_resource type="Script" path="res://collector/collector.gd" id="1_1xtt5"] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_vcox2"] +size = Vector2(113, 65) + [node name="Collector" type="Area2D"] script = ExtResource("1_1xtt5") +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(87.5, 48.5) +shape = SubResource("RectangleShape2D_vcox2") + [connection signal="body_entered" from="." to="." method="_on_body_entered"]