1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-21 15:24:18 +00:00

trying to test collector and collectible

This commit is contained in:
Matteo Balugani 2023-10-01 11:56:54 +02:00
parent b1f651a01e
commit 373ed4057d
4 changed files with 19 additions and 3 deletions

View file

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

View file

@ -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

View file

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

View file

@ -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