1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-21 23:34:18 +00:00
This commit is contained in:
Matteo Balugani 2023-10-02 22:31:43 +02:00
commit 929256dd5f
10 changed files with 113 additions and 56 deletions

View file

@ -1,34 +1,50 @@
extends StaticBody2D extends StaticBody2D
class_name Converter class_name Converter
var coda : int = 0
@export var sprite_front: AnimatedSprite2D @export var sprite_front: AnimatedSprite2D
@export var sprite_back: AnimatedSprite2D @export var sprite_back: AnimatedSprite2D
@export var conversion_timer: Timer @export var conversion_timer: Timer
@export var sound_working: AudioStreamPlayer @export var sound_working: AudioStreamPlayer
@export var sound_complete: AudioStreamPlayer @export var sound_complete: AudioStreamPlayer
@export var spawner: Spawner @export var spawner: Spawner
@export var spawner_alt: Spawner
@export_range(0.0, 1.0, 0.01) var spawner_alt_chance: float
## 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(): func _on_collector_goal():
coda+=1 to_produce += 1
func _process(_delta): func _physics_process(_delta):
if coda>=1 and conversion_timer.is_stopped(): if to_produce >= 1 and conversion_timer.is_stopped():
to_produce -= 1
produce()
func produce():
conversion_timer.start()
if sprite_front:
sprite_front.play() sprite_front.play()
if not sprite_back==null: if sprite_back:
sprite_back.play() sprite_back.play()
conversion_timer.start() if sound_working:
sound_working.play() sound_working.play()
func _on_timer_timeout(): func _on_timer_timeout():
coda-=1 if spawner_alt and Randomizer.rng.randf() < spawner_alt_chance:
sprite_front.stop() spawner_alt.spawn()
if not sprite_back==null: else:
spawner.spawn()
if sprite_front:
sprite_front.stop()
if sprite_back:
sprite_back.stop() sprite_back.stop()
sound_working.stop() if sound_working:
sound_complete.play() sound_working.stop()
spawner.spawn()
var is_pending_deletion: bool = false var is_pending_deletion: bool = false
@ -40,7 +56,7 @@ func ending_deletion():
sprite_front.modulate = Color.WHITE sprite_front.modulate = Color.WHITE
is_pending_deletion = false is_pending_deletion = false
func _on_input_event(viewport: Node, event: InputEvent, shape_idx: int): func _on_input_event(_viewport: Node, event: InputEvent, _shape_idx: int):
if is_pending_deletion: if is_pending_deletion:
if event is InputEventMouseButton or event is InputEventScreenTouch: if event is InputEventMouseButton or event is InputEventScreenTouch:
queue_free() queue_free()

View file

@ -71,7 +71,7 @@ script = ExtResource("1_mas6k")
sprite_front = NodePath("SpriteFront") sprite_front = NodePath("SpriteFront")
conversion_timer = NodePath("ConversionTimer") conversion_timer = NodePath("ConversionTimer")
sound_working = NodePath("SoundWorking") sound_working = NodePath("SoundWorking")
sound_complete = NodePath("SoundComplete") sound_complete = NodePath("Spawner/SoundComplete")
spawner = NodePath("Spawner") spawner = NodePath("Spawner")
[node name="SpriteBack" type="Sprite2D" parent="."] [node name="SpriteBack" type="Sprite2D" parent="."]
@ -110,7 +110,7 @@ collecting_amount = 10
shape = SubResource("RectangleShape2D_k11if") shape = SubResource("RectangleShape2D_k11if")
debug_color = Color(0, 0.701961, 0.188235, 0.419608) debug_color = Color(0, 0.701961, 0.188235, 0.419608)
[node name="Spawner" parent="." instance=ExtResource("9_2wvgu")] [node name="Spawner" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("9_2wvgu")]
position = Vector2(0, 8) position = Vector2(0, 8)
scene = ExtResource("2_h5aul") scene = ExtResource("2_h5aul")
buffer_cap = 1 buffer_cap = 1
@ -118,6 +118,7 @@ spawn_rect = Rect2(-8, 0, 16, 4)
spawn_rotation_degrees_min = 80.0 spawn_rotation_degrees_min = 80.0
spawn_rotation_degrees_max = 100.0 spawn_rotation_degrees_max = 100.0
overlapping_body_count_limit = 4 overlapping_body_count_limit = 4
sound_complete = NodePath("SoundComplete")
[node name="PreventSpawnShape" type="CollisionShape2D" parent="Spawner"] [node name="PreventSpawnShape" type="CollisionShape2D" parent="Spawner"]
z_index = 3 z_index = 3
@ -125,6 +126,10 @@ position = Vector2(0, 3.5)
shape = SubResource("RectangleShape2D_jeo5f") shape = SubResource("RectangleShape2D_jeo5f")
debug_color = Color(0.701961, 0, 0, 0.419608) debug_color = Color(0.701961, 0, 0, 0.419608)
[node name="SoundComplete" type="AudioStreamPlayer" parent="Spawner"]
stream = ExtResource("11_r8505")
max_polyphony = 4
[node name="ConversionTimer" type="Timer" parent="."] [node name="ConversionTimer" type="Timer" parent="."]
wait_time = 0.5 wait_time = 0.5
one_shot = true one_shot = true
@ -132,9 +137,6 @@ one_shot = true
[node name="SoundWorking" type="AudioStreamPlayer" parent="."] [node name="SoundWorking" type="AudioStreamPlayer" parent="."]
stream = ExtResource("10_6hhch") stream = ExtResource("10_6hhch")
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
stream = ExtResource("11_r8505")
[node name="ConverterPlacementBody" parent="." instance=ExtResource("12_5qhgs")] [node name="ConverterPlacementBody" parent="." instance=ExtResource("12_5qhgs")]
[connection signal="input_event" from="." to="." method="_on_input_event"] [connection signal="input_event" from="." to="." method="_on_input_event"]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=3 uid="uid://clanhkk4sg47w"] [gd_scene load_steps=26 format=3 uid="uid://clanhkk4sg47w"]
[ext_resource type="Script" path="res://converters/converter.gd" id="1_mf1ls"] [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"] [ext_resource type="Texture2D" uid="uid://2dhqp2liete7" path="res://converters/gold_to_coaldiamond/diamond_converter_back.png" id="2_nj8gd"]
@ -11,7 +11,8 @@
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="8_yel0k"] [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="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="PackedScene" uid="uid://diy8fj7mcc00p" path="res://entity/coal_diamond/coal.tscn" id="10_ry7ak"]
[ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="11_5c46k"] [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"] [ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="12_xld3l"]
[ext_resource type="AudioStream" uid="uid://du16ilpv6gmxd" path="res://audio/conversione/drop_in_lava.wav" id="13_jvouj"] [ext_resource type="AudioStream" uid="uid://du16ilpv6gmxd" path="res://audio/conversione/drop_in_lava.wav" id="13_jvouj"]
@ -55,7 +56,7 @@ animations = [{
}], }],
"loop": true, "loop": true,
"name": &"default", "name": &"default",
"speed": 15.0 "speed": 10.0
}] }]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_aslkt"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_aslkt"]
@ -71,16 +72,19 @@ size = Vector2(26, 5)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jeo5f"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_jeo5f"]
size = Vector2(26, 10) size = Vector2(26, 10)
[node name="CoalDiamondConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")] [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(3, 3)
collision_layer = 8 collision_layer = 8
collision_mask = 0 collision_mask = 0
input_pickable = true
script = ExtResource("1_mf1ls") script = ExtResource("1_mf1ls")
sprite_front = NodePath("SpriteFront") sprite_front = NodePath("SpriteFront")
conversion_timer = NodePath("ConversionTimer") conversion_timer = NodePath("ConversionTimer")
sound_working = NodePath("SoundWorking") sound_working = NodePath("SoundWorking")
sound_complete = NodePath("SoundComplete") sound_complete = NodePath("SpawnerAlt/SoundComplete")
spawner = NodePath("Spawner") spawner = NodePath("Spawner")
spawner_alt = NodePath("SpawnerAlt")
spawner_alt_chance = 0.12
[node name="SpriteBack" type="Sprite2D" parent="."] [node name="SpriteBack" type="Sprite2D" parent="."]
z_index = -2 z_index = -2
@ -111,7 +115,7 @@ shape = SubResource("RectangleShape2D_31dtl")
[node name="Collector" parent="." instance=ExtResource("7_rxm8j")] [node name="Collector" parent="." instance=ExtResource("7_rxm8j")]
z_index = 2 z_index = 2
collecting_types = Array[StringName]([&"Copper"]) collecting_types = Array[StringName]([&"Gold"])
collecting_amount = 10 collecting_amount = 10
[node name="CollectShape" type="CollisionShape2D" parent="Collector"] [node name="CollectShape" type="CollisionShape2D" parent="Collector"]
@ -133,15 +137,32 @@ position = Vector2(0, 3.5)
shape = SubResource("RectangleShape2D_jeo5f") shape = SubResource("RectangleShape2D_jeo5f")
debug_color = Color(0.701961, 0, 0, 0.419608) debug_color = Color(0.701961, 0, 0, 0.419608)
[node name="SpawnerAlt" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("8_yel0k")]
position = Vector2(0, 8)
scene = ExtResource("11_ekhmr")
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="SpawnerAlt"]
z_index = 3
position = Vector2(0, 3.5)
shape = SubResource("RectangleShape2D_jeo5f")
debug_color = Color(0.701961, 0, 0, 0.419608)
[node name="SoundComplete" type="AudioStreamPlayer" parent="SpawnerAlt"]
stream = ExtResource("12_pddsd")
[node name="ConversionTimer" type="Timer" parent="."] [node name="ConversionTimer" type="Timer" parent="."]
wait_time = 0.5
one_shot = true one_shot = true
[node name="SoundWorking" type="AudioStreamPlayer" parent="."] [node name="SoundWorking" type="AudioStreamPlayer" parent="."]
stream = ExtResource("10_hy4ck") stream = ExtResource("10_hy4ck")
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
stream = ExtResource("11_5c46k")
[node name="SoundAbsorb" type="AudioStreamPlayer" parent="."] [node name="SoundAbsorb" type="AudioStreamPlayer" parent="."]
stream = ExtResource("13_jvouj") stream = ExtResource("13_jvouj")
volume_db = -12.291 volume_db = -12.291

View file

@ -11,7 +11,7 @@
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="9_ojqfv"] [ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="9_ojqfv"]
[ext_resource type="PackedScene" uid="uid://bawprh8kluilq" path="res://entity/gem/gem.tscn" id="10_op7xt"] [ext_resource type="PackedScene" uid="uid://bawprh8kluilq" path="res://entity/gem/gem.tscn" id="10_op7xt"]
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="11_lofho"] [ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="11_lofho"]
[ext_resource type="AudioStream" uid="uid://7tw5efuo3gxj" path="res://audio/conversione/coin_to_coin.wav" id="12_vklpo"] [ext_resource type="AudioStream" uid="uid://cc4mqxq6mxmdg" path="res://audio/conversione/coin_to_gem.wav" id="11_sk30q"]
[ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="13_6o73w"] [ext_resource type="PackedScene" uid="uid://bevj27e1ha8m3" path="res://converters/converter_placement_body.tscn" id="13_6o73w"]
[sub_resource type="AtlasTexture" id="AtlasTexture_wy1v3"] [sub_resource type="AtlasTexture" id="AtlasTexture_wy1v3"]
@ -79,7 +79,7 @@ script = ExtResource("1_fgju3")
sprite_front = NodePath("SpriteFront") sprite_front = NodePath("SpriteFront")
conversion_timer = NodePath("ConversionTimer") conversion_timer = NodePath("ConversionTimer")
sound_working = NodePath("SoundWorking") sound_working = NodePath("SoundWorking")
sound_complete = NodePath("SoundComplete") sound_complete = NodePath("Spawner/SoundComplete")
spawner = NodePath("Spawner") spawner = NodePath("Spawner")
[node name="SpriteBack" type="Sprite2D" parent="."] [node name="SpriteBack" type="Sprite2D" parent="."]
@ -119,7 +119,7 @@ collecting_amount = 10
shape = SubResource("RectangleShape2D_k11if") shape = SubResource("RectangleShape2D_k11if")
debug_color = Color(0, 0.701961, 0.188235, 0.419608) debug_color = Color(0, 0.701961, 0.188235, 0.419608)
[node name="Spawner" parent="." instance=ExtResource("9_ojqfv")] [node name="Spawner" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("9_ojqfv")]
position = Vector2(0, 8) position = Vector2(0, 8)
scene = ExtResource("10_op7xt") scene = ExtResource("10_op7xt")
buffer_cap = 1 buffer_cap = 1
@ -127,6 +127,7 @@ spawn_rect = Rect2(-8, 0, 16, 4)
spawn_rotation_degrees_min = 80.0 spawn_rotation_degrees_min = 80.0
spawn_rotation_degrees_max = 100.0 spawn_rotation_degrees_max = 100.0
overlapping_body_count_limit = 4 overlapping_body_count_limit = 4
sound_complete = NodePath("SoundComplete")
[node name="PreventSpawnShape" type="CollisionShape2D" parent="Spawner"] [node name="PreventSpawnShape" type="CollisionShape2D" parent="Spawner"]
z_index = 3 z_index = 3
@ -134,6 +135,9 @@ position = Vector2(0, 3.5)
shape = SubResource("RectangleShape2D_jeo5f") shape = SubResource("RectangleShape2D_jeo5f")
debug_color = Color(0.701961, 0, 0, 0.419608) debug_color = Color(0.701961, 0, 0, 0.419608)
[node name="SoundComplete" type="AudioStreamPlayer" parent="Spawner"]
stream = ExtResource("11_sk30q")
[node name="ConversionTimer" type="Timer" parent="."] [node name="ConversionTimer" type="Timer" parent="."]
one_shot = true one_shot = true
@ -143,9 +147,6 @@ stream = ExtResource("11_lofho")
[node name="SoundWorking" type="AudioStreamPlayer" parent="."] [node name="SoundWorking" type="AudioStreamPlayer" parent="."]
stream = ExtResource("11_lofho") stream = ExtResource("11_lofho")
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
stream = ExtResource("12_vklpo")
[node name="ConverterPlacementBody" parent="." instance=ExtResource("13_6o73w")] [node name="ConverterPlacementBody" parent="." instance=ExtResource("13_6o73w")]
[connection signal="input_event" from="." to="." method="_on_input_event"] [connection signal="input_event" from="." to="." method="_on_input_event"]

View file

@ -55,7 +55,7 @@ script = ExtResource("1_chhfg")
sprite_front = NodePath("SpriteFront") sprite_front = NodePath("SpriteFront")
conversion_timer = NodePath("ConversionTimer") conversion_timer = NodePath("ConversionTimer")
sound_working = NodePath("SoundWorking") sound_working = NodePath("SoundWorking")
sound_complete = NodePath("SoundComplete") sound_complete = NodePath("Spawner/SoundComplete")
spawner = NodePath("Spawner") spawner = NodePath("Spawner")
[node name="SpriteBack" type="Sprite2D" parent="."] [node name="SpriteBack" type="Sprite2D" parent="."]
@ -95,7 +95,7 @@ collecting_amount = 10
shape = SubResource("RectangleShape2D_k11if") shape = SubResource("RectangleShape2D_k11if")
debug_color = Color(0, 0.701961, 0.188235, 0.419608) debug_color = Color(0, 0.701961, 0.188235, 0.419608)
[node name="Spawner" parent="." instance=ExtResource("8_65kmt")] [node name="Spawner" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("8_65kmt")]
position = Vector2(0, 8) position = Vector2(0, 8)
scene = ExtResource("9_t8y3t") scene = ExtResource("9_t8y3t")
buffer_cap = 1 buffer_cap = 1
@ -103,6 +103,9 @@ spawn_rect = Rect2(-8, 0, 16, 4)
spawn_rotation_degrees_min = 80.0 spawn_rotation_degrees_min = 80.0
spawn_rotation_degrees_max = 100.0 spawn_rotation_degrees_max = 100.0
overlapping_body_count_limit = 4 overlapping_body_count_limit = 4
sound_complete = NodePath("SoundComplete")
sound_complete_pitch_min = 1.1
sound_complete_pitch_max = 1.14
[node name="PreventSpawnShape" type="CollisionShape2D" parent="Spawner"] [node name="PreventSpawnShape" type="CollisionShape2D" parent="Spawner"]
z_index = 3 z_index = 3
@ -110,6 +113,9 @@ position = Vector2(0, 3.5)
shape = SubResource("RectangleShape2D_jeo5f") shape = SubResource("RectangleShape2D_jeo5f")
debug_color = Color(0.701961, 0, 0, 0.419608) debug_color = Color(0.701961, 0, 0, 0.419608)
[node name="SoundComplete" type="AudioStreamPlayer" parent="Spawner"]
stream = ExtResource("11_ow0vy")
[node name="ConversionTimer" type="Timer" parent="."] [node name="ConversionTimer" type="Timer" parent="."]
wait_time = 0.5 wait_time = 0.5
one_shot = true one_shot = true
@ -117,9 +123,6 @@ one_shot = true
[node name="SoundWorking" type="AudioStreamPlayer" parent="."] [node name="SoundWorking" type="AudioStreamPlayer" parent="."]
stream = ExtResource("10_0dr47") stream = ExtResource("10_0dr47")
[node name="SoundComplete" type="AudioStreamPlayer" parent="."]
stream = ExtResource("11_ow0vy")
[node name="ConverterPlacementBody" parent="." instance=ExtResource("12_37x2h")] [node name="ConverterPlacementBody" parent="." instance=ExtResource("12_37x2h")]
[connection signal="input_event" from="." to="." method="_on_input_event"] [connection signal="input_event" from="." to="." method="_on_input_event"]

View file

@ -1,13 +1,10 @@
[gd_scene load_steps=6 format=3 uid="uid://diy8fj7mcc00p"] [gd_scene load_steps=5 format=3 uid="uid://diy8fj7mcc00p"]
[ext_resource type="PhysicsMaterial" uid="uid://c6kn1an85lccr" path="res://entity/coin_physics_material.tres" id="1_ftt7x"] [ext_resource type="PhysicsMaterial" uid="uid://c6kn1an85lccr" path="res://entity/coin_physics_material.tres" id="1_ftt7x"]
[ext_resource type="Texture2D" uid="uid://bnfwmlf7ems16" path="res://entity/coal_diamond/coal.png" id="2_dcrph"] [ext_resource type="Texture2D" uid="uid://bnfwmlf7ems16" path="res://entity/coal_diamond/coal.png" id="2_ok4kf"]
[ext_resource type="PackedScene" uid="uid://bk1vvq5rug01m" path="res://collector/collectible.tscn" id="4_e8hbs"] [ext_resource type="PackedScene" uid="uid://bk1vvq5rug01m" path="res://collector/collectible.tscn" id="4_e8hbs"]
[ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="5_3e4d8"] [ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="5_3e4d8"]
[sub_resource type="CircleShape2D" id="CircleShape2D_x6m8s"]
radius = 10.5
[node name="Coal" type="RigidBody2D"] [node name="Coal" type="RigidBody2D"]
collision_layer = 4 collision_layer = 4
collision_mask = 14 collision_mask = 14
@ -19,13 +16,13 @@ can_sleep = false
linear_damp = 0.1 linear_damp = 0.1
angular_damp = 0.1 angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionPolygon2D" parent="."]
scale = Vector2(2, 2) scale = Vector2(2, 2)
shape = SubResource("CircleShape2D_x6m8s") 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"] [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"]
texture_filter = 1 texture_filter = 1
texture = ExtResource("2_dcrph") texture = ExtResource("2_ok4kf")
[node name="Collectible" parent="." instance=ExtResource("4_e8hbs")] [node name="Collectible" parent="." instance=ExtResource("4_e8hbs")]
type = &"Coal" type = &"Coal"

View file

@ -4,9 +4,7 @@
[ext_resource type="Texture2D" uid="uid://bquk2q5g6bst5" path="res://entity/coal_diamond/diamond.png" id="2_abwth"] [ext_resource type="Texture2D" uid="uid://bquk2q5g6bst5" path="res://entity/coal_diamond/diamond.png" id="2_abwth"]
[ext_resource type="PackedScene" uid="uid://bk1vvq5rug01m" path="res://collector/collectible.tscn" id="3_n4fa5"] [ext_resource type="PackedScene" uid="uid://bk1vvq5rug01m" path="res://collector/collectible.tscn" id="3_n4fa5"]
[ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="4_yfos5"] [ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="4_yfos5"]
[ext_resource type="Script" path="res://entity/gem/RandomValue.gd" id="5_g8xmh"]
[sub_resource type="CircleShape2D" id="CircleShape2D_x6m8s"]
radius = 10.5119
[node name="Diamond" type="RigidBody2D"] [node name="Diamond" type="RigidBody2D"]
collision_layer = 4 collision_layer = 4
@ -19,9 +17,9 @@ can_sleep = false
linear_damp = 0.1 linear_damp = 0.1
angular_damp = 0.1 angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionPolygon2D" parent="."]
scale = Vector2(2, 2) scale = Vector2(2, 2)
shape = SubResource("CircleShape2D_x6m8s") polygon = PackedVector2Array(0, 8, 10, -2, 4, -8, -4, -8, -10, -2)
[node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"]
texture_filter = 1 texture_filter = 1
@ -31,6 +29,11 @@ texture = ExtResource("2_abwth")
type = &"Diamond" type = &"Diamond"
[node name="Valuable" parent="." instance=ExtResource("4_yfos5")] [node name="Valuable" parent="." instance=ExtResource("4_yfos5")]
value = 1000 value = 10000
[node name="RandomValue" type="Node" parent="Valuable"]
script = ExtResource("5_g8xmh")
min_value = 9000
max_value = 16000
[connection signal="collected" from="Collectible" to="Collectible" method="_on_done" flags=18] [connection signal="collected" from="Collectible" to="Collectible" method="_on_done" flags=18]

View file

@ -10,8 +10,8 @@
[ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="6_svrnw"] [ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="6_svrnw"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_jkfas"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_jkfas"]
radius = 4.0 radius = 3.5
height = 10.0 height = 9.0
[node name="Gem" type="RigidBody2D"] [node name="Gem" type="RigidBody2D"]
collision_layer = 4 collision_layer = 4

View file

@ -102,6 +102,9 @@ func _on_ghost_materialize():
var spawner = instantiated.find_child("Spawner") var spawner = instantiated.find_child("Spawner")
if spawner != null: if spawner != null:
spawner.target = self spawner.target = self
var spawner_alt = instantiated.find_child("SpawnerAlt")
if spawner_alt != null:
spawner_alt.target = self
func _on_shop_ui_delete_begin(): func _on_shop_ui_delete_begin():
var converters = find_children("*", "Converter", true, false) var converters = find_children("*", "Converter", true, false)

View file

@ -27,6 +27,14 @@ var buffer: int = 0
## Maximum amount of bodies overlapping the spawner's area before the spawner stops spawning. ## Maximum amount of bodies overlapping the spawner's area before the spawner stops spawning.
@export_range(0, 16, 1, "or_greater") var overlapping_body_count_limit: int @export_range(0, 16, 1, "or_greater") var overlapping_body_count_limit: int
## Sound to play when spawning an item.
##
## Doesn't spawn anything if not set.
@export var sound_complete: AudioStreamPlayer
@export_range(0.01, 8.0, 0.01, "or_greater") var sound_complete_pitch_min: float = 1.00
@export_range(0.01, 8.0, 0.01, "or_greater") var sound_complete_pitch_max: float = 1.00
signal spawned(what: Node2D) signal spawned(what: Node2D)
@ -62,6 +70,9 @@ func _do_spawn():
instantiated.global_position = global_position + _select_spawn_position() instantiated.global_position = global_position + _select_spawn_position()
instantiated.rotation_degrees = _select_spawn_rotation() instantiated.rotation_degrees = _select_spawn_rotation()
target.add_child(instantiated) target.add_child(instantiated)
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()
buffer -= 1 buffer -= 1