From e02a5edea8650875bf261bac58813fa3d4698259 Mon Sep 17 00:00:00 2001 From: Matteo Balugani Date: Sun, 1 Oct 2023 11:37:38 +0200 Subject: [PATCH] new branch with experimental valuable e evaluator --- Convertitore.gd | 19 ------------------- convertitore.tscn | 2 +- value/evaluator.gd | 30 ++++++++++++++++++++++++++++++ value/evaluator.tscn | 10 ++++++++++ value/valuable.gd | 10 ++++++++++ value/valuable.tscn | 6 ++++++ 6 files changed, 57 insertions(+), 20 deletions(-) delete mode 100644 Convertitore.gd create mode 100644 value/evaluator.gd create mode 100644 value/evaluator.tscn create mode 100644 value/valuable.gd create mode 100644 value/valuable.tscn diff --git a/Convertitore.gd b/Convertitore.gd deleted file mode 100644 index fd728c5..0000000 --- a/Convertitore.gd +++ /dev/null @@ -1,19 +0,0 @@ -extends Node2D -var conta_soldi: int = 0 - -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass - - -func _on_ingresso_body_shape_entered(body_rid, body, body_shape_index, local_shape_index): - body.queue_free() - conta_soldi+=1 - if conta_soldi>=10: - conta_soldi=0 - diff --git a/convertitore.tscn b/convertitore.tscn index 95f36ae..a4b80f1 100644 --- a/convertitore.tscn +++ b/convertitore.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=3 format=3 uid="uid://d34gt53jcq1uw"] +[gd_scene load_steps=3 format=3 uid="uid://ei1b0ity3nwg"] [ext_resource type="Script" path="res://Convertitore.gd" id="1_7de38"] [ext_resource type="Texture2D" uid="uid://cxsl5yvdhswc7" path="res://icon.png" id="2_8bfs6"] diff --git a/value/evaluator.gd b/value/evaluator.gd new file mode 100644 index 0000000..a16124f --- /dev/null +++ b/value/evaluator.gd @@ -0,0 +1,30 @@ +extends Area2D +class_name Evaluator +## aggiunge al totale i valori dei Valuable che ci body_enterano e sottrae quelli che ci body_exitano + + +## The current amount of value evaluated. +var total_value: int = 0 + +## The types of [Collectible]s to value. +## +## The strings will match only if exactly the same. +@export var collecting_types: Array[StringName] + +## The collision mask to check colliding body against. +@export_flags_2d_physics var collecting_collision_mask: int + + +## The evaluator has added the value of an object. +signal added(what: PhysicsBody2D) + +## The evaluator has removed the value of an object. +signal removed(what: PhysicsBody2D) + + +func _on_body_entered(body: Node2D): + pass + + + + diff --git a/value/evaluator.tscn b/value/evaluator.tscn new file mode 100644 index 0000000..5016a5e --- /dev/null +++ b/value/evaluator.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://beg758fa6o0cs"] + +[ext_resource type="Script" path="res://value/evaluator.gd" id="1_sjx78"] + +[node name="Evaluator" type="Node2D"] +script = ExtResource("1_sjx78") + +[node name="Area2D" type="Area2D" parent="."] + +[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"] diff --git a/value/valuable.gd b/value/valuable.gd new file mode 100644 index 0000000..a5e8162 --- /dev/null +++ b/value/valuable.gd @@ -0,0 +1,10 @@ +extends Node +class_name Valuable + +@export var value: int + +#signal object_value +# +# +#func collect(): +# emit_signal("collected") diff --git a/value/valuable.tscn b/value/valuable.tscn new file mode 100644 index 0000000..6a66261 --- /dev/null +++ b/value/valuable.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://ujpra0s1kpqi"] + +[ext_resource type="Script" path="res://value/valuable.gd" id="1_mr62g"] + +[node name="Valuable" type="Node2D"] +script = ExtResource("1_mr62g")