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):