1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-25 09:04:19 +00:00
This commit is contained in:
Maxim Lobovsky 2023-10-02 23:35:18 +02:00
commit ba468f1504
25 changed files with 229 additions and 91 deletions

View file

@ -2,7 +2,7 @@
importer="wav" importer="wav"
type="AudioStreamWAV" type="AudioStreamWAV"
uid="uid://bdb07kes1tulq" uid="uid://db1i6rqitk0e"
path="res://.godot/imported/coal_funny.wav-d8d327344bf0d0b208564592ca1936e9.sample" path="res://.godot/imported/coal_funny.wav-d8d327344bf0d0b208564592ca1936e9.sample"
[deps] [deps]

View file

@ -3,12 +3,21 @@ class_name Colored
@export var shader: Shader @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() @onready var parent: Sprite2D = get_parent()
func _ready(): func _ready():
var material = ShaderMaterial.new() var material = ShaderMaterial.new()
hue = Randomizer.rng.randf()
material.shader = shader material.shader = shader
material.set_shader_parameter("hue", hue)
parent.material = material parent.material = material

View file

@ -13,9 +13,6 @@ class_name Converter
## Amount of scenes this converter should produce. ## Amount of scenes this converter should produce.
var to_produce: int = 0 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():
to_produce += 1 to_produce += 1

View file

@ -63,7 +63,7 @@ size = Vector2(26, 5)
size = Vector2(26, 10) size = Vector2(26, 10)
[node name="CopperConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")] [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_layer = 8
collision_mask = 0 collision_mask = 0
input_pickable = true input_pickable = true

View file

@ -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="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,6 +11,7 @@
[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://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="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="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"]
@ -73,7 +74,7 @@ size = Vector2(26, 5)
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", "spawner_alt")] [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_layer = 8
collision_mask = 0 collision_mask = 0
input_pickable = true input_pickable = true
@ -122,7 +123,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_yel0k")] [node name="Spawner" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("8_yel0k")]
position = Vector2(0, 8) position = Vector2(0, 8)
scene = ExtResource("10_ry7ak") scene = ExtResource("10_ry7ak")
buffer_cap = 1 buffer_cap = 1
@ -130,6 +131,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
@ -137,6 +139,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_601lg")
volume_db = -10.011
[node name="SpawnerAlt" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("8_yel0k")] [node name="SpawnerAlt" parent="." node_paths=PackedStringArray("sound_complete") instance=ExtResource("8_yel0k")]
position = Vector2(0, 8) position = Vector2(0, 8)
scene = ExtResource("11_ekhmr") scene = ExtResource("11_ekhmr")

View file

@ -71,7 +71,7 @@ size = Vector2(26, 5)
size = Vector2(26, 8.83334) size = Vector2(26, 8.83334)
[node name="GoldConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")] [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_layer = 8
collision_mask = 0 collision_mask = 0
input_pickable = true input_pickable = true

View file

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

View file

@ -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://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="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"] [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://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://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="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="PackedScene" uid="uid://d32fgw4klo4x3" path="res://entity/item/item_crown.tscn" id="14_mioqu"]
[ext_resource type="Texture2D" uid="uid://wpen8vmuyvqv" path="res://entity/item/item_chalice.png" id="15_4mivw"]
[ext_resource type="AudioStream" uid="uid://du16ilpv6gmxd" path="res://audio/conversione/drop_in_lava.wav" id="15_nahnf"] [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://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="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="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"] [sub_resource type="AtlasTexture" id="AtlasTexture_uqtie"]
atlas = ExtResource("2_136t7") atlas = ExtResource("2_136t7")
@ -67,7 +59,7 @@ animations = [{
}], }],
"loop": true, "loop": true,
"name": &"default", "name": &"default",
"speed": 5.0 "speed": 10.0
}] }]
[sub_resource type="AtlasTexture" id="AtlasTexture_qnpyk"] [sub_resource type="AtlasTexture" id="AtlasTexture_qnpyk"]
@ -110,7 +102,7 @@ animations = [{
}], }],
"loop": true, "loop": true,
"name": &"default", "name": &"default",
"speed": 5.0 "speed": 10.0
}] }]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_aslkt"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_aslkt"]
@ -123,37 +115,15 @@ size = Vector2(26, 4)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_k11if"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_k11if"]
size = Vector2(26, 5) 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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_jeo5f"]
size = Vector2(26, 8.83334) 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) scale = Vector2(2, 2)
collision_layer = 8 collision_layer = 8
collision_mask = 0 collision_mask = 0
input_pickable = true input_pickable = true
script = ExtResource("1_qln0a") script = ExtResource("1_o3eos")
sprite_front = NodePath("SpriteFront")
sprite_back = NodePath("SpriteBack")
conversion_timer = NodePath("ConversionTimer")
sound_working = NodePath("SoundWorking")
sound_complete = NodePath("SoundComplete")
spawner = NodePath("Spawner")
[node name="SpriteBack" type="AnimatedSprite2D" parent="."] [node name="SpriteBack" type="AnimatedSprite2D" parent="."]
texture_filter = 1 texture_filter = 1
@ -182,32 +152,76 @@ position = Vector2(0, 4.5)
rotation = 3.14159 rotation = 3.14159
shape = SubResource("RectangleShape2D_31dtl") 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 z_index = 2
collecting_types = Array[StringName]([&"Gold", &"Gem"]) collecting_types = Array[StringName]([&"Gold"])
sound_absorb = NodePath("../SoundAbsorb") 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") 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("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) position = Vector2(0, 8)
scene = SubResource("PackedScene_srx0t") scene = ExtResource("14_mioqu")
buffer_cap = 1 buffer_cap = 1
spawn_rect = Rect2(-8, 0, 16, 4) 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="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 z_index = 3
position = Vector2(0, 3.5) 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="ConversionTimer" type="Timer" parent="."] [node name="ConversionTimer" type="Timer" parent="."]
wait_time = 0.5
one_shot = true one_shot = true
[node name="SoundAbsorb" type="AudioStreamPlayer" parent="."] [node name="SoundAbsorb" type="AudioStreamPlayer" parent="."]
@ -228,6 +242,9 @@ frame_progress = 0.228399
[node name="ConverterPlacementBody" parent="." instance=ExtResource("17_udaa3")] [node name="ConverterPlacementBody" parent="." instance=ExtResource("17_udaa3")]
[connection signal="input_event" from="." to="." method="_on_input_event"] [connection signal="input_event" from="." to="." method="_on_input_event"]
[connection signal="collected" from="Collector" to="." method="_on_collector_collected" flags=18] [connection signal="collected" from="GoldCollector" to="." method="_on_gold_collector_collected"]
[connection signal="goal" from="Collector" to="." method="_on_collector_goal" flags=18] [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] [connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout" flags=18]

View file

@ -47,7 +47,7 @@ size = Vector2(26, 5)
size = Vector2(26, 10) size = Vector2(26, 10)
[node name="SilverConverter" type="StaticBody2D" node_paths=PackedStringArray("sprite_front", "conversion_timer", "sound_working", "sound_complete", "spawner")] [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_layer = 8
collision_mask = 0 collision_mask = 0
input_pickable = true input_pickable = true

View file

@ -17,7 +17,7 @@ linear_damp = 0.1
angular_damp = 0.1 angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionPolygon2D" parent="."] [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) 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"]

View file

@ -18,7 +18,7 @@ linear_damp = 0.1
angular_damp = 0.1 angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionPolygon2D" parent="."] [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) 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"]

View file

@ -21,7 +21,7 @@ linear_damp = 0.1
angular_damp = 0.1 angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(2, 2) scale = Vector2(1.5, 1.5)
shape = SubResource("RectangleShape2D_c6byl") shape = SubResource("RectangleShape2D_c6byl")
[node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"]

View file

@ -7,7 +7,7 @@
[ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="5_palpv"] [ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="5_palpv"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"]
size = Vector2(20, 16) size = Vector2(27, 5)
[node name="CoinGold" type="RigidBody2D"] [node name="CoinGold" type="RigidBody2D"]
collision_layer = 4 collision_layer = 4
@ -21,7 +21,7 @@ linear_damp = 0.1
angular_damp = 0.1 angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(2, 2) scale = Vector2(1.5, 1.5)
shape = SubResource("RectangleShape2D_c6byl") shape = SubResource("RectangleShape2D_c6byl")
[node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"]

View file

@ -22,7 +22,7 @@ linear_damp = 0.1
angular_damp = 0.1 angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(2, 2) scale = Vector2(1.5, 1.5)
shape = SubResource("RectangleShape2D_c6byl") shape = SubResource("RectangleShape2D_c6byl")
[node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"]

View file

@ -16,8 +16,8 @@ height = 9.0
[node name="Gem" type="RigidBody2D"] [node name="Gem" type="RigidBody2D"]
collision_layer = 4 collision_layer = 4
collision_mask = 14 collision_mask = 14
mass = 2.5 mass = 1.5
inertia = 500.0 inertia = 800.0
physics_material_override = ExtResource("1_vmemd") physics_material_override = ExtResource("1_vmemd")
continuous_cd = 1 continuous_cd = 1
can_sleep = false can_sleep = false
@ -25,7 +25,7 @@ linear_damp = 0.1
angular_damp = 0.1 angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(4, 4) scale = Vector2(3, 3)
shape = SubResource("CapsuleShape2D_jkfas") shape = SubResource("CapsuleShape2D_jkfas")
[node name="Sprite" type="Sprite2D" parent="CollisionShape2D"] [node name="Sprite" type="Sprite2D" parent="CollisionShape2D"]

View file

@ -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="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"] [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="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"] [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"] [node name="ItemChalice" type="RigidBody2D"]
collision_layer = 5 collision_layer = 5
collision_mask = 7 collision_mask = 7
@ -22,9 +20,9 @@ continuous_cd = 1
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(4, 4) scale = Vector2(2, 2)
shape = SubResource("ConcavePolygonShape2D_n5iil") 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"] [node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"]
texture_filter = 1 texture_filter = 1

View file

@ -10,11 +10,11 @@
[ext_resource type="Script" path="res://entity/gem/RandomValue.gd" id="8_utkrs"] [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"] [ext_resource type="AudioStream" uid="uid://br25ip30mu174" path="res://audio/conversione/mechanic_sound.wav" id="9_6xmfi"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_jkfas"] [sub_resource type="CircleShape2D" id="CircleShape2D_058rf"]
radius = 13.25 radius = 12.25
height = 32.0
[node name="ItemCrown" type="RigidBody2D"] [node name="ItemCrown" type="RigidBody2D"]
scale = Vector2(2, 2)
collision_layer = 5 collision_layer = 5
collision_mask = 7 collision_mask = 7
mass = 2.8 mass = 2.8
@ -26,7 +26,7 @@ angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(4, 4) scale = Vector2(4, 4)
shape = SubResource("CapsuleShape2D_jkfas") shape = SubResource("CircleShape2D_058rf")
[node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"] [node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"]
texture_filter = 1 texture_filter = 1

View file

@ -12,7 +12,7 @@
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ka4h2"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ka4h2"]
radius = 5.64 radius = 5.64
height = 17.01 height = 14.5
[node name="ItemRing" type="RigidBody2D"] [node name="ItemRing" type="RigidBody2D"]
collision_layer = 5 collision_layer = 5
@ -25,7 +25,7 @@ linear_damp = 0.1
angular_damp = 0.1 angular_damp = 0.1
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2(4, 4) scale = Vector2(2, 2)
shape = SubResource("CapsuleShape2D_ka4h2") shape = SubResource("CapsuleShape2D_ka4h2")
[node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"] [node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"]

View file

@ -99,19 +99,21 @@ func _on_ghost_materialize():
if not instantiated: if not instantiated:
print("[Game] The ghost can't materialize; the spawning is cancelled!") print("[Game] The ghost can't materialize; the spawning is cancelled!")
return return
var spawner = instantiated.find_child("Spawner") for spawner in instantiated.find_children("*", "Spawner", true, false):
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)
for converter in converters: for converter in converters:
converter.pending_deletion() 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(): func _on_shop_ui_delete_cancel():
var converters = find_children("*", "Converter", true, false) var converters = find_children("*", "Converter", true, false)
for converter in converters: for converter in converters:
converter.ending_deletion() converter.ending_deletion()
var item_converters = find_children("*", "ItemConverter", true, false)
for converter in item_converters:
converter.ending_deletion()

View file

@ -17,8 +17,8 @@
[ext_resource type="Texture2D" uid="uid://c8pvjgtr2ufjl" path="res://interface/upgrade_copper.png" id="11_lt33g"] [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="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="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://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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_rh35r"]
size = Vector2(240, 384) 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")] [node name="TimeSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")]
position = Vector2(136, 0) position = Vector2(136, 0)
scene = ExtResource("13_8ux81")
target = NodePath("..") target = NodePath("..")
buffer_cap = 1 buffer_cap = 1
spawn_rect = Rect2(-20, 0, 40, 0) spawn_rect = Rect2(-20, 0, 40, 0)
@ -79,7 +78,6 @@ shape = SubResource("RectangleShape2D_4uksi")
debug_color = Color(0, 0.6, 0.701961, 0) debug_color = Color(0, 0.6, 0.701961, 0)
[node name="Timer" type="Timer" parent="TimeSpawner"] [node name="Timer" type="Timer" parent="TimeSpawner"]
one_shot = true
[node name="DebugSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")] [node name="DebugSpawner" parent="." node_paths=PackedStringArray("target") instance=ExtResource("3_qwsty")]
position = Vector2(136, 0) position = Vector2(136, 0)
@ -190,7 +188,24 @@ position = Vector2(405, 540)
shape = SubResource("RectangleShape2D_jed57") shape = SubResource("RectangleShape2D_jed57")
debug_color = Color(0, 0, 0, 0.419608) 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="changed" from="Bottle/Evaluator" to="." method="_on_score_changed"]
[connection signal="timeout" from="TimeSpawner/Timer" to="TimeSpawner" method="spawn"] [connection signal="timeout" from="TimeSpawner/Timer" to="TimeSpawner" method="spawn"]
[connection signal="timeout" from="DebugSpawner/DebugTimer" to="DebugSpawner" method="spawn"] [connection signal="timeout" from="DebugSpawner/DebugTimer" to="DebugSpawner" method="spawn"]
[connection signal="collected" from="StoreCollector" to="." method="_on_store_collector_collected"] [connection signal="collected" from="StoreCollector" to="." method="_on_store_collector_collected"]
[editable path="ItemConverter"]

View file

@ -12,7 +12,7 @@ collision_mask_prevent_placement = 16
collision_mask_delete_placement = 4 collision_mask_delete_placement = 4
[node name="PlacementShape" parent="." instance=ExtResource("3_lskcf")] [node name="PlacementShape" parent="." instance=ExtResource("3_lskcf")]
scale = Vector2(3, 3) scale = Vector2(2, 2)
[node name="PreviewSprite" type="Sprite2D" parent="PlacementShape"] [node name="PreviewSprite" type="Sprite2D" parent="PlacementShape"]
modulate = Color(1, 1, 1, 0.5) modulate = Color(1, 1, 1, 0.5)

View file

@ -36,6 +36,7 @@ func _on_any_purchase_begin(what: Node):
if not what is PurchasableItem: if not what is PurchasableItem:
push_error("Purchase began outside a PurchasableItem") push_error("Purchase began outside a PurchasableItem")
return return
delete_button.disabled = true
if what.item_scene: if what.item_scene:
ghost_requested.emit(what.item_scene, what.item_icon) ghost_requested.emit(what.item_scene, what.item_icon)
purchase_begin.emit(what) purchase_begin.emit(what)
@ -45,6 +46,7 @@ func _on_any_purchase_cancel(what: Node):
if not what is PurchasableItem: if not what is PurchasableItem:
push_error("Purchase cancelled outside a PurchasableItem") push_error("Purchase cancelled outside a PurchasableItem")
return return
delete_button.disabled = false
purchase_cancel.emit(what) purchase_cancel.emit(what)
set_all_can_buy(true, what) set_all_can_buy(true, what)
@ -54,6 +56,7 @@ func _on_any_purchase_success(what: Node):
return return
if what.item_scene: if what.item_scene:
ghost_materialize.emit() ghost_materialize.emit()
delete_button.disabled = false
purchase_success.emit(what) purchase_success.emit(what)
set_all_can_buy(true, what) set_all_can_buy(true, what)

View file

@ -49,6 +49,9 @@ func _on_game_ui_shop_button_pressed():
func _on_shop_ui_purchase_begin(_what): func _on_shop_ui_purchase_begin(_what):
ui_state = UIState.GAME ui_state = UIState.GAME
func _on_shop_ui_purchase_cancel(_what):
ui_state = UIState.GAME
func _on_shop_ui_delete_begin(): func _on_shop_ui_delete_begin():
ui_state = UIState.GAME ui_state = UIState.GAME

View file

@ -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/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_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="." 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="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_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"] [connection signal="ghost_requested" from="CustomUI/ShopSafeUI/ShopUI" to="CustomUI/GameViewport/Viewport/Game" method="_on_ghost_requested"]

View file

@ -73,7 +73,7 @@ func _do_spawn():
if sound_complete: if sound_complete:
sound_complete.pitch_scale = Randomizer.rng.randf_range(sound_complete_pitch_min, sound_complete_pitch_max) sound_complete.pitch_scale = Randomizer.rng.randf_range(sound_complete_pitch_min, sound_complete_pitch_max)
sound_complete.play() sound_complete.play()
spawned.emit() spawned.emit(instantiated)
buffer -= 1 buffer -= 1
func _physics_process(_delta): func _physics_process(_delta):