From 96b685d187550ae3ddefdf1b20ca0089a36a94f5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 2 Oct 2023 23:24:01 +0200 Subject: [PATCH 1/6] Fix stuff --- audio/conversione/coal_funny.wav.import | 24 ++++ color/Colored.gd | 13 ++- converters/converter.gd | 3 - .../coal_diamond_converter.tscn | 6 +- converters/item_converter/item_converter.gd | 87 ++++++++++++++ converters/item_converter/item_converter.tscn | 109 ++++++++++-------- entity/coin_gold/coin_gold.tscn | 2 +- entity/gem/gem.tscn | 4 +- entity/item/item_chalice.tscn | 10 +- entity/item/item_crown.tscn | 8 +- entity/item/item_ring.tscn | 4 +- game/game.gd | 12 +- game/game.tscn | 21 +++- main.gd | 3 + spawner/spawner.gd | 2 +- 15 files changed, 232 insertions(+), 76 deletions(-) create mode 100644 audio/conversione/coal_funny.wav.import create mode 100644 converters/item_converter/item_converter.gd diff --git a/audio/conversione/coal_funny.wav.import b/audio/conversione/coal_funny.wav.import new file mode 100644 index 0000000..e582dca --- /dev/null +++ b/audio/conversione/coal_funny.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://db1i6rqitk0e" +path="res://.godot/imported/coal_funny.wav-d8d327344bf0d0b208564592ca1936e9.sample" + +[deps] + +source_file="res://audio/conversione/coal_funny.wav" +dest_files=["res://.godot/imported/coal_funny.wav-d8d327344bf0d0b208564592ca1936e9.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/color/Colored.gd b/color/Colored.gd index 9f90406..02accbe 100644 --- a/color/Colored.gd +++ b/color/Colored.gd @@ -3,12 +3,21 @@ class_name Colored @export var shader: Shader -@onready var hue: float = Randomizer.rng.randf() +@onready var hue: float: + get: + return hue + set(value): + hue = value + if parent.material: + parent.material.set_shader_parameter("hue", value) + @onready var parent: Sprite2D = get_parent() func _ready(): var material = ShaderMaterial.new() + hue = Randomizer.rng.randf() material.shader = shader - material.set_shader_parameter("hue", hue) parent.material = material + + diff --git a/converters/converter.gd b/converters/converter.gd index 40c06a4..18ac54a 100644 --- a/converters/converter.gd +++ b/converters/converter.gd @@ -13,9 +13,6 @@ class_name Converter ## Amount of scenes this converter should produce. var to_produce: int = 0 -## Amount of scenes this converter should spawn. -var to_spawn: int = 0 - func _on_collector_goal(): to_produce += 1 diff --git a/converters/gold_to_coaldiamond/coal_diamond_converter.tscn b/converters/gold_to_coaldiamond/coal_diamond_converter.tscn index 53bee59..3483d2f 100644 --- a/converters/gold_to_coaldiamond/coal_diamond_converter.tscn +++ b/converters/gold_to_coaldiamond/coal_diamond_converter.tscn @@ -122,7 +122,7 @@ collecting_amount = 10 shape = SubResource("RectangleShape2D_k11if") debug_color = Color(0, 0.701961, 0.188235, 0.419608) -[node name="Spawner" parent="." instance=ExtResource("8_yel0k")] +[node name="Spawner" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("8_yel0k")] position = Vector2(0, 8) scene = ExtResource("10_ry7ak") buffer_cap = 1 @@ -130,6 +130,7 @@ spawn_rect = Rect2(-8, 0, 16, 4) spawn_rotation_degrees_min = 80.0 spawn_rotation_degrees_max = 100.0 overlapping_body_count_limit = 4 +sound_complete = NodePath("SoundComplete") [node name="PreventSpawnShape" type="CollisionShape2D" parent="Spawner"] z_index = 3 @@ -137,6 +138,9 @@ position = Vector2(0, 3.5) shape = SubResource("RectangleShape2D_jeo5f") debug_color = Color(0.701961, 0, 0, 0.419608) +[node name="SoundComplete" type="AudioStreamPlayer" parent="Spawner"] +stream = ExtResource("12_pddsd") + [node name="SpawnerAlt" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("8_yel0k")] position = Vector2(0, 8) scene = ExtResource("11_ekhmr") diff --git a/converters/item_converter/item_converter.gd b/converters/item_converter/item_converter.gd new file mode 100644 index 0000000..b44eaa6 --- /dev/null +++ b/converters/item_converter/item_converter.gd @@ -0,0 +1,87 @@ +extends StaticBody2D +class_name ItemConverter + +@onready var sprite_front: AnimatedSprite2D = $SpriteFront +@onready var sprite_back: AnimatedSprite2D = $SpriteBack +@onready var sound_working: AudioStreamPlayer = $SoundWorking + +@export var crown_chance: float = 0.1 +@export var chalice_chance: float = 0.4 + +@export var required_gold = 25 + +@onready var stored_gold: int = 0 +@onready var gem_hue_ready: Array[float] = [] +@onready var gem_hue_stored: Array[float] = [] +@onready var gem_hue_spawn: Array[float] = [] + +@onready var conversion_timer: Timer = $ConversionTimer +@onready var ring_spawner = $RingSpawner +@onready var chalice_spawner = $ChaliceSpawner +@onready var crown_spawner = $CrownSpawner + +func _physics_process(_delta): + if conversion_timer.is_stopped(): + var hue = gem_hue_stored.pop_front() + if hue: + gem_hue_spawn.append(hue) + conversion_timer.start() + if sprite_front: + sprite_front.play() + if sprite_back: + sprite_back.play() + if sound_working: + sound_working.play() + +func try_produce(): + if stored_gold >= required_gold and len(gem_hue_ready) >= 1: + stored_gold -= required_gold + gem_hue_stored.append(gem_hue_ready.pop_back()) + +func _on_timer_timeout(): + var rand = Randomizer.rng.randf() + if rand <= crown_chance: + crown_spawner.spawn() + elif rand <= chalice_chance: + chalice_spawner.spawn() + else: + ring_spawner.spawn() + if sprite_front: + sprite_front.stop() + if sprite_back: + sprite_back.stop() + if sound_working: + sound_working.stop() + + +var is_pending_deletion: bool = false + +func pending_deletion(): + sprite_front.modulate = Color.RED + is_pending_deletion = true + +func ending_deletion(): + sprite_front.modulate = Color.WHITE + is_pending_deletion = false + +func _on_input_event(_viewport: Node, event: InputEvent, _shape_idx: int): + if is_pending_deletion: + if event is InputEventMouseButton or event is InputEventScreenTouch: + queue_free() + +func _on_gem_collector_collected(body: RigidBody2D): + var colored: Colored = body.get_node("CollisionShape2D/Sprite/Colored") + gem_hue_ready.append(colored.hue) + try_produce() + +func _on_gold_collector_collected(_body: RigidBody2D): + stored_gold += 1 + try_produce() + +func _on_spawner_spawned(what: RigidBody2D): + var hue = gem_hue_spawn.pop_front() + if not hue: + push_error("Missing gem hue, defualting to red") + hue = 0 + var colored: Colored = what.get_node("CollisionShape2D/Sprite/Colored") + colored.hue = hue diff --git a/converters/item_converter/item_converter.tscn b/converters/item_converter/item_converter.tscn index 6e72e5a..a8d5256 100644 --- a/converters/item_converter/item_converter.tscn +++ b/converters/item_converter/item_converter.tscn @@ -1,6 +1,6 @@ -[gd_scene load_steps=45 format=3 uid="uid://ddrhfhebwtq5"] +[gd_scene load_steps=35 format=3 uid="uid://ddrhfhebwtq5"] -[ext_resource type="Script" path="res://converters/converter.gd" id="1_qln0a"] +[ext_resource type="Script" path="res://converters/item_converter/item_converter.gd" id="1_o3eos"] [ext_resource type="Texture2D" uid="uid://devcho3gaigt0" path="res://converters/item_converter/item_converter_back_1.png" id="2_136t7"] [ext_resource type="Texture2D" uid="uid://bq54rpw5jufyd" path="res://converters/item_converter/item_converter_back_2.png" id="3_6gyd6"] [ext_resource type="PackedScene" uid="uid://c5w3b55aiui6c" path="res://collector/collector.tscn" id="3_qehi7"] @@ -13,19 +13,11 @@ [ext_resource type="Texture2D" uid="uid://fqerky4lyps8" path="res://converters/item_converter/item_converter_front_3.png" id="9_88mk7"] [ext_resource type="Texture2D" uid="uid://bw0jgw0jen4lg" path="res://converters/item_converter/item_converter_front_4.png" id="10_fjv52"] [ext_resource type="Texture2D" uid="uid://4tg81ksibacf" path="res://converters/item_converter/item_converter_front_5.png" id="11_cg5dk"] -[ext_resource type="PhysicsMaterial" uid="uid://c6kn1an85lccr" path="res://entity/coin_physics_material.tres" id="14_t5rsp"] -[ext_resource type="Texture2D" uid="uid://wpen8vmuyvqv" path="res://entity/item/item_chalice.png" id="15_4mivw"] +[ext_resource type="PackedScene" uid="uid://d32fgw4klo4x3" path="res://entity/item/item_crown.tscn" id="14_mioqu"] [ext_resource type="AudioStream" uid="uid://du16ilpv6gmxd" path="res://audio/conversione/drop_in_lava.wav" id="15_nahnf"] -[ext_resource type="Texture2D" uid="uid://dvthocklcjh15" path="res://entity/item/item_chalice_gems.png" id="16_b46dj"] [ext_resource type="AudioStream" uid="uid://dv1e0wiiquxp0" path="res://audio/conversione/lava.wav" id="16_ptmks"] [ext_resource type="AudioStream" uid="uid://c0uhi1hrejyxg" path="res://audio/conversione/new_item.wav" id="17_4wm4w"] -[ext_resource type="PackedScene" uid="uid://vkvtap437nnf" path="res://color/colored.tscn" id="17_ickrn"] [ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="17_udaa3"] -[ext_resource type="Shader" path="res://entity/gem/gem_shading_material.gdshader" id="18_36lk7"] -[ext_resource type="PackedScene" uid="uid://bk1vvq5rug01m" path="res://collector/collectible.tscn" id="19_ih6j4"] -[ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="20_rkbv1"] -[ext_resource type="Script" path="res://entity/gem/RandomValue.gd" id="21_wmo4c"] -[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="22_5s1fv"] [sub_resource type="AtlasTexture" id="AtlasTexture_uqtie"] atlas = ExtResource("2_136t7") @@ -67,7 +59,7 @@ animations = [{ }], "loop": true, "name": &"default", -"speed": 5.0 +"speed": 10.0 }] [sub_resource type="AtlasTexture" id="AtlasTexture_qnpyk"] @@ -110,7 +102,7 @@ animations = [{ }], "loop": true, "name": &"default", -"speed": 5.0 +"speed": 10.0 }] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_aslkt"] @@ -123,37 +115,15 @@ size = Vector2(26, 4) [sub_resource type="RectangleShape2D" id="RectangleShape2D_k11if"] size = Vector2(26, 5) -[sub_resource type="CircleShape2D" id="CircleShape2D_hwdjv"] -radius = 18.5017 - -[sub_resource type="PackedScene" id="PackedScene_srx0t"] -_bundled = { -"conn_count": 1, -"conns": PackedInt32Array(5, 5, 30, 29, 18, 0, 0), -"editable_instances": [], -"names": PackedStringArray("Item", "collision_layer", "collision_mask", "mass", "inertia", "physics_material_override", "continuous_cd", "linear_damp", "angular_damp", "RigidBody2D", "CollisionShape2D", "scale", "shape", "Sprite2D", "texture_filter", "texture", "Sprite", "Colored", "shader", "Collectible", "type", "Valuable", "value", "RandomValue", "script", "Node", "SoundWorking", "stream", "AudioStreamPlayer", "_on_done", "collected"), -"node_count": 9, -"node_paths": [], -"nodes": PackedInt32Array(-1, -1, 9, 0, -1, 8, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 6, 0, 0, 0, 10, 10, -1, 2, 11, 7, 12, 8, 0, 1, 0, 13, 13, -1, 2, 14, 5, 15, 9, 0, 1, 0, 13, 16, -1, 2, 14, 5, 15, 10, 0, 3, 0, 2147483647, 17, 11, 1, 18, 12, 0, 0, 0, 2147483647, 19, 13, 1, 20, 14, 0, 0, 0, 2147483647, 21, 15, 1, 22, 16, 0, 6, 0, 25, 23, -1, 1, 24, 17, 0, 0, 0, 28, 26, -1, 1, 27, 18, 0), -"variants": [5, 7, 1.5, 800.0, ExtResource("14_t5rsp"), 1, 0.1, Vector2(4, 4), SubResource("CircleShape2D_hwdjv"), ExtResource("15_4mivw"), ExtResource("16_b46dj"), ExtResource("17_ickrn"), ExtResource("18_36lk7"), ExtResource("19_ih6j4"), &"Gem", ExtResource("20_rkbv1"), 10, ExtResource("21_wmo4c"), ExtResource("22_5s1fv")], -"version": 3 -} - [sub_resource type="RectangleShape2D" id="RectangleShape2D_jeo5f"] size = Vector2(26, 8.83334) -[node name="ItemConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "sprite_back", "conversion_timer", "sound_working", "sound_complete", "spawner")] +[node name="ItemConverter" type="StaticBody2D"] scale = Vector2(3, 3) collision_layer = 8 collision_mask = 0 input_pickable = true -script = ExtResource("1_qln0a") -sprite_front = NodePath("SpriteFront") -sprite_back = NodePath("SpriteBack") -conversion_timer = NodePath("ConversionTimer") -sound_working = NodePath("SoundWorking") -sound_complete = NodePath("SoundComplete") -spawner = NodePath("Spawner") +script = ExtResource("1_o3eos") [node name="SpriteBack" type="AnimatedSprite2D" parent="."] texture_filter = 1 @@ -182,32 +152,76 @@ position = Vector2(0, 4.5) rotation = 3.14159 shape = SubResource("RectangleShape2D_31dtl") -[node name="Collector" parent="." node_paths=PackedStringArray("sound_absorb") instance=ExtResource("3_qehi7")] +[node name="GoldCollector" parent="." node_paths=PackedStringArray("sound_absorb") instance=ExtResource("3_qehi7")] z_index = 2 -collecting_types = Array[StringName]([&"Gold", &"Gem"]) +collecting_types = Array[StringName]([&"Gold"]) sound_absorb = NodePath("../SoundAbsorb") -collecting_amount = 10 +collecting_amount = 25 -[node name="CollectShape" type="CollisionShape2D" parent="Collector"] +[node name="CollectShape" type="CollisionShape2D" parent="GoldCollector"] shape = SubResource("RectangleShape2D_k11if") debug_color = Color(0, 0.701961, 0.188235, 0.419608) -[node name="Spawner" parent="." instance=ExtResource("4_ihtl7")] +[node name="GemCollector" parent="." node_paths=PackedStringArray("sound_absorb") instance=ExtResource("3_qehi7")] +z_index = 2 +collecting_types = Array[StringName]([&"Gem"]) +sound_absorb = NodePath("../SoundAbsorb") +collecting_amount = 10 + +[node name="CollectShape" type="CollisionShape2D" parent="GemCollector"] +shape = SubResource("RectangleShape2D_k11if") +debug_color = Color(0, 0.701961, 0.188235, 0.419608) + +[node name="RingSpawner" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("4_ihtl7")] position = Vector2(0, 8) -scene = SubResource("PackedScene_srx0t") +scene = ExtResource("14_mioqu") buffer_cap = 1 spawn_rect = Rect2(-8, 0, 16, 4) spawn_rotation_degrees_min = 80.0 spawn_rotation_degrees_max = 100.0 overlapping_body_count_limit = 4 +sound_complete = NodePath("../SoundComplete") -[node name="PreventSpawnShape" type="CollisionShape2D" parent="Spawner"] +[node name="PreventSpawnShape" type="CollisionShape2D" parent="RingSpawner"] +z_index = 3 +position = Vector2(0, 3.5) +shape = SubResource("RectangleShape2D_jeo5f") +debug_color = Color(0.701961, 0, 0, 0.419608) + +[node name="ChaliceSpawner" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("4_ihtl7")] +position = Vector2(0, 8) +scene = ExtResource("14_mioqu") +buffer_cap = 1 +spawn_rect = Rect2(-8, 0, 16, 4) +spawn_rotation_degrees_min = 80.0 +spawn_rotation_degrees_max = 100.0 +overlapping_body_count_limit = 4 +sound_complete = NodePath("../SoundComplete") + +[node name="PreventSpawnShape" type="CollisionShape2D" parent="ChaliceSpawner"] +z_index = 3 +position = Vector2(0, 3.5) +shape = SubResource("RectangleShape2D_jeo5f") +debug_color = Color(0.701961, 0, 0, 0.419608) + +[node name="CrownSpawner" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("4_ihtl7")] +position = Vector2(0, 8) +scene = ExtResource("14_mioqu") +buffer_cap = 1 +spawn_rect = Rect2(-8, 0, 16, 4) +spawn_rotation_degrees_min = 80.0 +spawn_rotation_degrees_max = 100.0 +overlapping_body_count_limit = 4 +sound_complete = NodePath("../SoundComplete") + +[node name="PreventSpawnShape" type="CollisionShape2D" parent="CrownSpawner"] z_index = 3 position = Vector2(0, 3.5) shape = SubResource("RectangleShape2D_jeo5f") debug_color = Color(0.701961, 0, 0, 0.419608) [node name="ConversionTimer" type="Timer" parent="."] +wait_time = 0.5 one_shot = true [node name="SoundAbsorb" type="AudioStreamPlayer" parent="."] @@ -228,6 +242,9 @@ frame_progress = 0.228399 [node name="ConverterPlacementBody" parent="." instance=ExtResource("17_udaa3")] [connection signal="input_event" from="." to="." method="_on_input_event"] -[connection signal="collected" from="Collector" to="." method="_on_collector_collected" flags=18] -[connection signal="goal" from="Collector" to="." method="_on_collector_goal" flags=18] +[connection signal="collected" from="GoldCollector" to="." method="_on_gold_collector_collected"] +[connection signal="collected" from="GemCollector" to="." method="_on_gem_collector_collected"] +[connection signal="spawned" from="RingSpawner" to="." method="_on_spawner_spawned"] +[connection signal="spawned" from="ChaliceSpawner" to="." method="_on_spawner_spawned"] +[connection signal="spawned" from="CrownSpawner" to="." method="_on_spawner_spawned"] [connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout" flags=18] diff --git a/entity/coin_gold/coin_gold.tscn b/entity/coin_gold/coin_gold.tscn index 011a7ee..2057d7f 100644 --- a/entity/coin_gold/coin_gold.tscn +++ b/entity/coin_gold/coin_gold.tscn @@ -7,7 +7,7 @@ [ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="5_palpv"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"] -size = Vector2(20, 16) +size = Vector2(27, 5) [node name="CoinGold" type="RigidBody2D"] collision_layer = 4 diff --git a/entity/gem/gem.tscn b/entity/gem/gem.tscn index c332612..e4cc75d 100644 --- a/entity/gem/gem.tscn +++ b/entity/gem/gem.tscn @@ -16,8 +16,8 @@ height = 9.0 [node name="Gem" type="RigidBody2D"] collision_layer = 4 collision_mask = 14 -mass = 2.5 -inertia = 500.0 +mass = 1.5 +inertia = 800.0 physics_material_override = ExtResource("1_vmemd") continuous_cd = 1 can_sleep = false diff --git a/entity/item/item_chalice.tscn b/entity/item/item_chalice.tscn index 6b910b5..2f3338e 100644 --- a/entity/item/item_chalice.tscn +++ b/entity/item/item_chalice.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://451ddbtq4163"] +[gd_scene load_steps=10 format=3 uid="uid://451ddbtq4163"] [ext_resource type="PhysicsMaterial" uid="uid://c6kn1an85lccr" path="res://entity/coin_physics_material.tres" id="1_vp2el"] [ext_resource type="Texture2D" uid="uid://wpen8vmuyvqv" path="res://entity/item/item_chalice.png" id="2_rnc33"] @@ -10,8 +10,6 @@ [ext_resource type="Script" path="res://entity/gem/RandomValue.gd" id="8_87qrp"] [ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="9_v6jws"] -[sub_resource type="ConcavePolygonShape2D" id="ConcavePolygonShape2D_n5iil"] - [node name="ItemChalice" type="RigidBody2D"] collision_layer = 5 collision_mask = 7 @@ -22,9 +20,9 @@ continuous_cd = 1 linear_damp = 0.1 angular_damp = 0.1 -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -scale = Vector2(4, 4) -shape = SubResource("ConcavePolygonShape2D_n5iil") +[node name="CollisionShape2D" type="CollisionPolygon2D" parent="."] +scale = Vector2(2, 2) +polygon = PackedVector2Array(0, -15, -11.5, -13, -10.5, -1, -2.5, 5, -2.5, 8, -8.5, 12, -4.5, 15, 4.5, 15, 8.5, 12, 2.5, 8, 2.5, 5, 10.5, -1, 11.5, -12.75) [node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"] texture_filter = 1 diff --git a/entity/item/item_crown.tscn b/entity/item/item_crown.tscn index 713528a..ac6f54c 100644 --- a/entity/item/item_crown.tscn +++ b/entity/item/item_crown.tscn @@ -10,11 +10,11 @@ [ext_resource type="Script" path="res://entity/gem/RandomValue.gd" id="8_utkrs"] [ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="9_6xmfi"] -[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_jkfas"] -radius = 13.25 -height = 32.0 +[sub_resource type="CircleShape2D" id="CircleShape2D_058rf"] +radius = 12.25 [node name="ItemCrown" type="RigidBody2D"] +scale = Vector2(2, 2) collision_layer = 5 collision_mask = 7 mass = 2.8 @@ -26,7 +26,7 @@ angular_damp = 0.1 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] scale = Vector2(4, 4) -shape = SubResource("CapsuleShape2D_jkfas") +shape = SubResource("CircleShape2D_058rf") [node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"] texture_filter = 1 diff --git a/entity/item/item_ring.tscn b/entity/item/item_ring.tscn index d27d398..f94208e 100644 --- a/entity/item/item_ring.tscn +++ b/entity/item/item_ring.tscn @@ -12,7 +12,7 @@ [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ka4h2"] radius = 5.64 -height = 17.01 +height = 14.5 [node name="ItemRing" type="RigidBody2D"] collision_layer = 5 @@ -25,7 +25,7 @@ linear_damp = 0.1 angular_damp = 0.1 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -scale = Vector2(4, 4) +scale = Vector2(2, 2) shape = SubResource("CapsuleShape2D_ka4h2") [node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"] diff --git a/game/game.gd b/game/game.gd index d2a7643..f07b0b3 100644 --- a/game/game.gd +++ b/game/game.gd @@ -99,19 +99,21 @@ func _on_ghost_materialize(): if not instantiated: print("[Game] The ghost can't materialize; the spawning is cancelled!") return - var spawner = instantiated.find_child("Spawner") - if spawner != null: + for spawner in instantiated.find_children("*", "Spawner", true, false): spawner.target = self - var spawner_alt = instantiated.find_child("SpawnerAlt") - if spawner_alt != null: - spawner_alt.target = self func _on_shop_ui_delete_begin(): var converters = find_children("*", "Converter", true, false) for converter in converters: converter.pending_deletion() + var item_converters = find_children("*", "ItemConverter", true, false) + for converter in item_converters: + converter.pending_deletion() func _on_shop_ui_delete_end(): var converters = find_children("*", "Converter", true, false) for converter in converters: converter.ending_deletion() + var item_converters = find_children("*", "ItemConverter", true, false) + for converter in item_converters: + converter.pending_deletion() diff --git a/game/game.tscn b/game/game.tscn index 973c3a1..542be23 100644 --- a/game/game.tscn +++ b/game/game.tscn @@ -17,8 +17,8 @@ [ext_resource type="Texture2D" uid="uid://c8pvjgtr2ufjl" path="res://interface/upgrade_copper.png" id="11_lt33g"] [ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper/coin_copper.tscn" id="13_4j8om"] [ext_resource type="Script" path="res://game/DebugTimer.gd" id="13_6ai3c"] -[ext_resource type="PackedScene" uid="uid://du3005kwybbrh" path="res://entity/coin_gold/coin_gold.tscn" id="13_8ux81"] [ext_resource type="PackedScene" uid="uid://qtk4tm6l367w" path="res://interface/ghost.tscn" id="16_8vhx6"] +[ext_resource type="PackedScene" uid="uid://ddrhfhebwtq5" path="res://converters/item_converter/item_converter.tscn" id="20_aqj42"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_rh35r"] size = Vector2(240, 384) @@ -67,7 +67,6 @@ debug_color = Color(0, 0.6, 0.701961, 0) [node name="TimeSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")] position = Vector2(136, 0) -scene = ExtResource("13_8ux81") target = NodePath("..") buffer_cap = 1 spawn_rect = Rect2(-20, 0, 40, 0) @@ -79,7 +78,6 @@ shape = SubResource("RectangleShape2D_4uksi") debug_color = Color(0, 0.6, 0.701961, 0) [node name="Timer" type="Timer" parent="TimeSpawner"] -one_shot = true [node name="DebugSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")] position = Vector2(136, 0) @@ -190,7 +188,24 @@ position = Vector2(405, 540) shape = SubResource("RectangleShape2D_jed57") debug_color = Color(0, 0, 0, 0.419608) +[node name="ItemConverter" parent="." instance=ExtResource("20_aqj42")] +position = Vector2(137, 368) + +[node name="GoldCollector" parent="ItemConverter" index="5"] +collecting_types = Array[StringName]([&"Copper"]) + +[node name="RingSpawner" parent="ItemConverter" index="7" node_paths=PackedStringArray("target")] +target = NodePath("../..") + +[node name="ChaliceSpawner" parent="ItemConverter" index="8" node_paths=PackedStringArray("target")] +target = NodePath("../..") + +[node name="CrownSpawner" parent="ItemConverter" index="9" node_paths=PackedStringArray("target")] +target = NodePath("../..") + [connection signal="changed" from="Bottle/Evaluator" to="." method="_on_score_changed"] [connection signal="timeout" from="TimeSpawner/Timer" to="TimeSpawner" method="spawn"] [connection signal="timeout" from="DebugSpawner/DebugTimer" to="DebugSpawner" method="spawn"] [connection signal="collected" from="StoreCollector" to="." method="_on_store_collector_collected"] + +[editable path="ItemConverter"] diff --git a/main.gd b/main.gd index 21296a8..b88f954 100644 --- a/main.gd +++ b/main.gd @@ -49,6 +49,9 @@ func _on_game_ui_shop_button_pressed(): func _on_shop_ui_purchase_begin(_what): ui_state = UIState.GAME +func _on_shop_ui_purchase_cancel(_what): + ui_state = UIState.GAME + func _on_shop_ui_delete_begin(): ui_state = UIState.GAME diff --git a/spawner/spawner.gd b/spawner/spawner.gd index 3f3cc8d..f56595f 100644 --- a/spawner/spawner.gd +++ b/spawner/spawner.gd @@ -73,7 +73,7 @@ func _do_spawn(): if sound_complete: sound_complete.pitch_scale = Randomizer.rng.randf_range(sound_complete_pitch_min, sound_complete_pitch_max) sound_complete.play() - spawned.emit() + spawned.emit(instantiated) buffer -= 1 func _physics_process(_delta): From 13d4b814dcdc2c7d9c6887bb07089831f48dec30 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 2 Oct 2023 23:25:40 +0200 Subject: [PATCH 2/6] Fix coal soudn --- converters/gold_to_coaldiamond/coal_diamond_converter.tscn | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/converters/gold_to_coaldiamond/coal_diamond_converter.tscn b/converters/gold_to_coaldiamond/coal_diamond_converter.tscn index 3483d2f..6a79cc4 100644 --- a/converters/gold_to_coaldiamond/coal_diamond_converter.tscn +++ b/converters/gold_to_coaldiamond/coal_diamond_converter.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=26 format=3 uid="uid://clanhkk4sg47w"] +[gd_scene load_steps=27 format=3 uid="uid://clanhkk4sg47w"] [ext_resource type="Script" path="res://converters/converter.gd" id="1_mf1ls"] [ext_resource type="Texture2D" uid="uid://2dhqp2liete7" path="res://converters/gold_to_coaldiamond/diamond_converter_back.png" id="2_nj8gd"] @@ -11,6 +11,7 @@ [ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="8_yel0k"] [ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="10_hy4ck"] [ext_resource type="PackedScene" uid="uid://diy8fj7mcc00p" path="res://entity/coal_diamond/coal.tscn" id="10_ry7ak"] +[ext_resource type="AudioStream" uid="uid://db1i6rqitk0e" path="res://audio/conversione/coal_funny.wav" id="11_601lg"] [ext_resource type="PackedScene" uid="uid://cr5tiep20hk0s" path="res://entity/coal_diamond/diamond.tscn" id="11_ekhmr"] [ext_resource type="AudioStream" uid="uid://cc4mqxq6mxmdg" path="res://audio/conversione/coin_to_gem.wav" id="12_pddsd"] [ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="12_xld3l"] @@ -139,7 +140,8 @@ shape = SubResource("RectangleShape2D_jeo5f") debug_color = Color(0.701961, 0, 0, 0.419608) [node name="SoundComplete" type="AudioStreamPlayer" parent="Spawner"] -stream = ExtResource("12_pddsd") +stream = ExtResource("11_601lg") +volume_db = -10.011 [node name="SpawnerAlt" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("8_yel0k")] position = Vector2(0, 8) From 1c35d5fcd1315cbc4e453fb939f67bd83af03f14 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 2 Oct 2023 23:26:21 +0200 Subject: [PATCH 3/6] Fix shop ui --- interface/shop_ui.gd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/shop_ui.gd b/interface/shop_ui.gd index 8dfe4c1..a126948 100644 --- a/interface/shop_ui.gd +++ b/interface/shop_ui.gd @@ -36,6 +36,7 @@ func _on_any_purchase_begin(what: Node): if not what is PurchasableItem: push_error("Purchase began outside a PurchasableItem") return + delete_button.disabled = true if what.item_scene: ghost_requested.emit(what.item_scene, what.item_icon) purchase_begin.emit(what) @@ -45,6 +46,7 @@ func _on_any_purchase_cancel(what: Node): if not what is PurchasableItem: push_error("Purchase cancelled outside a PurchasableItem") return + delete_button.disabled = false purchase_cancel.emit(what) set_all_can_buy(true, what) @@ -54,6 +56,7 @@ func _on_any_purchase_success(what: Node): return if what.item_scene: ghost_materialize.emit() + delete_button.disabled = false purchase_success.emit(what) set_all_can_buy(true, what) From c27f55c57713d0e073cbd62c2b3f66ccde2d6a1e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 2 Oct 2023 23:28:20 +0200 Subject: [PATCH 4/6] Fix delete unable to cancel --- game/game.gd | 2 +- main.tscn | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/game/game.gd b/game/game.gd index f07b0b3..b6b2fc7 100644 --- a/game/game.gd +++ b/game/game.gd @@ -110,7 +110,7 @@ func _on_shop_ui_delete_begin(): for converter in item_converters: converter.pending_deletion() -func _on_shop_ui_delete_end(): +func _on_shop_ui_delete_cancel(): var converters = find_children("*", "Converter", true, false) for converter in converters: converter.ending_deletion() diff --git a/main.tscn b/main.tscn index ee10b53..9b91a06 100644 --- a/main.tscn +++ b/main.tscn @@ -86,6 +86,7 @@ layout_mode = 2 [connection signal="delete_begin" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_shop_ui_delete_begin"] [connection signal="delete_begin" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameSafeUI/GameUI" method="_on_shop_ui_delete_begin"] [connection signal="delete_cancel" from="CustomUI/ShopSafeUI/ShopUI" to="." method="_on_shop_ui_delete_cancel"] +[connection signal="delete_cancel" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_shop_ui_delete_cancel"] [connection signal="delete_cancel" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameSafeUI/GameUI" method="_on_shop_ui_delete_cancel"] [connection signal="ghost_materialize" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_ghost_materialize"] [connection signal="ghost_requested" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_ghost_requested"] From 843ea8bd6c6f95bd5938de8378b6f7f93cb62b78 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 2 Oct 2023 23:28:49 +0200 Subject: [PATCH 5/6] Fix delete item conv --- game/game.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/game.gd b/game/game.gd index b6b2fc7..eb71316 100644 --- a/game/game.gd +++ b/game/game.gd @@ -116,4 +116,4 @@ func _on_shop_ui_delete_cancel(): converter.ending_deletion() var item_converters = find_children("*", "ItemConverter", true, false) for converter in item_converters: - converter.pending_deletion() + converter.ending_deletion() From bfad133eb0a717107e9b6a24845e1f8f95255c5a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 2 Oct 2023 23:33:32 +0200 Subject: [PATCH 6/6] scassa tutto --- converters/copper_to_silver/copper_converter.tscn | 2 +- converters/gold_to_coaldiamond/coal_diamond_converter.tscn | 2 +- converters/gold_to_gem/gold_converter.tscn | 2 +- converters/item_converter/item_converter.tscn | 2 +- converters/silver_to_gold/silver_converter.tscn | 2 +- entity/coal_diamond/coal.tscn | 2 +- entity/coal_diamond/diamond.tscn | 2 +- entity/coin_copper/coin_copper.tscn | 2 +- entity/coin_gold/coin_gold.tscn | 2 +- entity/coin_silver/coin_silver.tscn | 2 +- entity/gem/gem.tscn | 2 +- interface/ghost.tscn | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/converters/copper_to_silver/copper_converter.tscn b/converters/copper_to_silver/copper_converter.tscn index a2a9ea7..32c40de 100644 --- a/converters/copper_to_silver/copper_converter.tscn +++ b/converters/copper_to_silver/copper_converter.tscn @@ -63,7 +63,7 @@ size = Vector2(26, 5) size = Vector2(26, 10) [node name="CopperConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")] -scale = Vector2(3, 3) +scale = Vector2(2, 2) collision_layer = 8 collision_mask = 0 input_pickable = true diff --git a/converters/gold_to_coaldiamond/coal_diamond_converter.tscn b/converters/gold_to_coaldiamond/coal_diamond_converter.tscn index 6a79cc4..7d5aacb 100644 --- a/converters/gold_to_coaldiamond/coal_diamond_converter.tscn +++ b/converters/gold_to_coaldiamond/coal_diamond_converter.tscn @@ -74,7 +74,7 @@ size = Vector2(26, 5) size = Vector2(26, 10) [node name="CoalDiamondConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner", "spawner_alt")] -scale = Vector2(3, 3) +scale = Vector2(2, 2) collision_layer = 8 collision_mask = 0 input_pickable = true diff --git a/converters/gold_to_gem/gold_converter.tscn b/converters/gold_to_gem/gold_converter.tscn index ea753aa..b8cf29a 100644 --- a/converters/gold_to_gem/gold_converter.tscn +++ b/converters/gold_to_gem/gold_converter.tscn @@ -71,7 +71,7 @@ size = Vector2(26, 5) size = Vector2(26, 8.83334) [node name="GoldConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")] -scale = Vector2(3, 3) +scale = Vector2(2, 2) collision_layer = 8 collision_mask = 0 input_pickable = true diff --git a/converters/item_converter/item_converter.tscn b/converters/item_converter/item_converter.tscn index a8d5256..8569bdc 100644 --- a/converters/item_converter/item_converter.tscn +++ b/converters/item_converter/item_converter.tscn @@ -119,7 +119,7 @@ size = Vector2(26, 5) size = Vector2(26, 8.83334) [node name="ItemConverter" type="StaticBody2D"] -scale = Vector2(3, 3) +scale = Vector2(2, 2) collision_layer = 8 collision_mask = 0 input_pickable = true diff --git a/converters/silver_to_gold/silver_converter.tscn b/converters/silver_to_gold/silver_converter.tscn index 2b0fd6c..a0cba72 100644 --- a/converters/silver_to_gold/silver_converter.tscn +++ b/converters/silver_to_gold/silver_converter.tscn @@ -47,7 +47,7 @@ size = Vector2(26, 5) size = Vector2(26, 10) [node name="SilverConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")] -scale = Vector2(3, 3) +scale = Vector2(2, 2) collision_layer = 8 collision_mask = 0 input_pickable = true diff --git a/entity/coal_diamond/coal.tscn b/entity/coal_diamond/coal.tscn index 7416c8b..aec4bc1 100644 --- a/entity/coal_diamond/coal.tscn +++ b/entity/coal_diamond/coal.tscn @@ -17,7 +17,7 @@ linear_damp = 0.1 angular_damp = 0.1 [node name="CollisionShape2D" type="CollisionPolygon2D" parent="."] -scale = Vector2(2, 2) +scale = Vector2(1.5, 1.5) polygon = PackedVector2Array(-4.5, 8, 4.5, 8, 8.5, 4, 8.5, -3, 3.5, -8, -3.5, -8, -7.5, -4, -8.5, 0, -8.5, 3) [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] diff --git a/entity/coal_diamond/diamond.tscn b/entity/coal_diamond/diamond.tscn index 2de7878..448c0be 100644 --- a/entity/coal_diamond/diamond.tscn +++ b/entity/coal_diamond/diamond.tscn @@ -18,7 +18,7 @@ linear_damp = 0.1 angular_damp = 0.1 [node name="CollisionShape2D" type="CollisionPolygon2D" parent="."] -scale = Vector2(2, 2) +scale = Vector2(1.5, 1.5) polygon = PackedVector2Array(0, 8, 10, -2, 4, -8, -4, -8, -10, -2) [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] diff --git a/entity/coin_copper/coin_copper.tscn b/entity/coin_copper/coin_copper.tscn index def0919..c01b7de 100644 --- a/entity/coin_copper/coin_copper.tscn +++ b/entity/coin_copper/coin_copper.tscn @@ -21,7 +21,7 @@ linear_damp = 0.1 angular_damp = 0.1 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -scale = Vector2(2, 2) +scale = Vector2(1.5, 1.5) shape = SubResource("RectangleShape2D_c6byl") [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] diff --git a/entity/coin_gold/coin_gold.tscn b/entity/coin_gold/coin_gold.tscn index 2057d7f..8a628d9 100644 --- a/entity/coin_gold/coin_gold.tscn +++ b/entity/coin_gold/coin_gold.tscn @@ -21,7 +21,7 @@ linear_damp = 0.1 angular_damp = 0.1 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -scale = Vector2(2, 2) +scale = Vector2(1.5, 1.5) shape = SubResource("RectangleShape2D_c6byl") [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] diff --git a/entity/coin_silver/coin_silver.tscn b/entity/coin_silver/coin_silver.tscn index 8715912..e59973c 100644 --- a/entity/coin_silver/coin_silver.tscn +++ b/entity/coin_silver/coin_silver.tscn @@ -22,7 +22,7 @@ linear_damp = 0.1 angular_damp = 0.1 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -scale = Vector2(2, 2) +scale = Vector2(1.5, 1.5) shape = SubResource("RectangleShape2D_c6byl") [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] diff --git a/entity/gem/gem.tscn b/entity/gem/gem.tscn index e4cc75d..b6530bd 100644 --- a/entity/gem/gem.tscn +++ b/entity/gem/gem.tscn @@ -25,7 +25,7 @@ linear_damp = 0.1 angular_damp = 0.1 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -scale = Vector2(4, 4) +scale = Vector2(3, 3) shape = SubResource("CapsuleShape2D_jkfas") [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] diff --git a/interface/ghost.tscn b/interface/ghost.tscn index f3edebd..38f6d16 100644 --- a/interface/ghost.tscn +++ b/interface/ghost.tscn @@ -12,7 +12,7 @@ collision_mask_prevent_placement = 16 collision_mask_delete_placement = 4 [node name="PlacementShape" parent="." instance=ExtResource("3_lskcf")] -scale = Vector2(3, 3) +scale = Vector2(2, 2) [node name="PreviewSprite" type="Sprite2D" parent="PlacementShape"] modulate = Color(1, 1, 1, 0.5)