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"] diff --git a/root.tscn b/root.tscn index 0884c6b..1e12e02 100644 --- a/root.tscn +++ b/root.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=3 uid="uid://cbccs6kwwf265"] +[gd_scene load_steps=6 format=3 uid="uid://cbccs6kwwf265"] [ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"] [ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"] [ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"] [ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"] +[ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="5_c2ruc"] [node name="Root" type="Node"] @@ -55,6 +56,9 @@ spawn_rotation_range = 15.0 overlapping_bodies_collision_mask = 4 overlapping_body_count_limit = 4 +[node name="Collector" parent="UI/GameContainer/Game" instance=ExtResource("5_c2ruc")] +position = Vector2(-92, -257) + [node name="Rows" type="VBoxContainer" parent="UI"] layout_mode = 1 anchors_preset = 15