From eaf4f6d15e9a3c60ce01173fc88ffdac10bde919 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 2 Oct 2023 21:25:11 +0200 Subject: [PATCH] fix stuff --- collector/collector.gd | 3 +- .../copper_to_silver/copper_converter.tscn | 1 - entity/coin_copper/coin_copper.tscn | 5 +-- entity/coin_gold/coin_gold.tscn | 2 +- entity/item/item_chalice.tscn | 6 +-- game/game.tscn | 16 +------- interface/ghost.gd | 32 +++++++++++++-- interface/shop_ui.tscn | 40 +++++++++++-------- main.tscn | 2 +- 9 files changed, 62 insertions(+), 45 deletions(-) diff --git a/collector/collector.gd b/collector/collector.gd index 78f6e9a..c749b45 100644 --- a/collector/collector.gd +++ b/collector/collector.gd @@ -31,7 +31,8 @@ func _on_body_entered(body: Node2D): collectible.collect() if sound_absorb: sound_absorb.play() - emit_signal("collected", body) + collected.emit(body) if collected_count >= collecting_amount: + goal.emit() emit_signal("goal") collected_count = 0 diff --git a/converters/copper_to_silver/copper_converter.tscn b/converters/copper_to_silver/copper_converter.tscn index a41706e..fc9aeff 100644 --- a/converters/copper_to_silver/copper_converter.tscn +++ b/converters/copper_to_silver/copper_converter.tscn @@ -136,6 +136,5 @@ stream = ExtResource("11_r8505") [node name="ConverterPlacementBody" parent="." instance=ExtResource("12_5qhgs")] -[connection signal="collected" from="Collector" to="." method="_on_collector_collected"] [connection signal="goal" from="Collector" to="." method="_on_collector_goal"] [connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout"] diff --git a/entity/coin_copper/coin_copper.tscn b/entity/coin_copper/coin_copper.tscn index 9297f4b..abd0c90 100644 --- a/entity/coin_copper/coin_copper.tscn +++ b/entity/coin_copper/coin_copper.tscn @@ -5,7 +5,7 @@ [ext_resource type="Texture2D" uid="uid://2vtvoj6ua3cb" path="res://entity/coin_copper/coin_copper_outline_2.png" id="3_dq1f7"] [ext_resource type="PackedScene" uid="uid://bk1vvq5rug01m" path="res://collector/collectible.tscn" id="4_npwn2"] [ext_resource type="PackedScene" uid="uid://ujpra0s1kpqi" path="res://value/valuable.tscn" id="5_fd0r7"] -[ext_resource type="AudioStream" uid="uid://wy7f2j0wg1ur" path="res://audio/tap/click5.wav" id="7_fxd28"] +[ext_resource type="AudioStream" uid="uid://ds2rl6eg5jr1" path="res://audio/tap/click5.wav" id="7_fxd28"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"] size = Vector2(14, 3) @@ -49,7 +49,4 @@ volume_db = -24.397 wait_time = 2.108 one_shot = true -[connection signal="body_entered" from="." to="." method="_on_body_entered"] -[connection signal="body_exited" from="." to="." method="_on_body_exited"] -[connection signal="sleeping_state_changed" from="." to="." method="_on_sleeping_state_changed"] [connection signal="collected" from="Collectible" to="Collectible" method="_on_done"] 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/item/item_chalice.tscn b/entity/item/item_chalice.tscn index 0c7bb12..684a80d 100644 --- a/entity/item/item_chalice.tscn +++ b/entity/item/item_chalice.tscn @@ -10,9 +10,7 @@ [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="CapsuleShape2D" id="CapsuleShape2D_6xf6v"] -radius = 12.95 -height = 42.31 +[sub_resource type="ConcavePolygonShape2D" id="ConcavePolygonShape2D_n5iil"] [node name="ItemChalice" type="RigidBody2D"] collision_layer = 5 @@ -26,7 +24,7 @@ angular_damp = 0.1 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] scale = Vector2(4, 4) -shape = SubResource("CapsuleShape2D_6xf6v") +shape = SubResource("ConcavePolygonShape2D_n5iil") [node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"] texture_filter = 1 diff --git a/game/game.tscn b/game/game.tscn index 390eaae..99e48c3 100644 --- a/game/game.tscn +++ b/game/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=25 format=3 uid="uid://c3rxmcwa5nqng"] +[gd_scene load_steps=23 format=3 uid="uid://c3rxmcwa5nqng"] [ext_resource type="Script" path="res://game/game.gd" id="1_i3ly0"] [ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_y7o2l"] @@ -16,9 +16,7 @@ [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://clanhkk4sg47w" path="res://converters/gold_to_coaldiamond/coal_diamond_converter.tscn" id="18_bjs6i"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_rh35r"] size = Vector2(240, 384) @@ -66,7 +64,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) @@ -78,7 +75,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) @@ -86,7 +82,7 @@ scene = ExtResource("13_4j8om") target = NodePath("..") buffer_cap = 1 spawn_rect = Rect2(-20, 0, 40, 0) -overlapping_body_count_limit = 128 +overlapping_body_count_limit = 16 metadata/_edit_lock_ = true [node name="NeckShape" type="CollisionShape2D" parent="DebugSpawner"] @@ -189,15 +185,7 @@ position = Vector2(405, 540) shape = SubResource("RectangleShape2D_jed57") debug_color = Color(0, 0, 0, 0.419608) -[node name="CoalDiamondConverter" parent="." instance=ExtResource("18_bjs6i")] -position = Vector2(140, 217) - -[node name="Spawner" parent="CoalDiamondConverter" index="6" 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="CoalDiamondConverter"] diff --git a/interface/ghost.gd b/interface/ghost.gd index cb2e766..474ad97 100644 --- a/interface/ghost.gd +++ b/interface/ghost.gd @@ -43,6 +43,9 @@ var can_place: bool: ## The last input event of the input that's dragging the ghost around, or null if the ghost isn't being dragged. var last_input_event: InputEvent +## The last alternate input event. +var last_alternate_event: InputEvent + func _ready(): collision_mask = collision_mask_prevent_placement | collision_mask_delete_placement @@ -55,10 +58,32 @@ func _input(event: InputEvent): last_input_event = event if event.pressed else null # Handle touch begin elif event is InputEventScreenTouch: - last_input_event = event if event.pressed else null + print("Event: ", event) + print("Last: ", last_input_event) + print("Alt: ", last_alternate_event) + if not last_input_event: + last_input_event = event if event.pressed else null + elif event.index == last_input_event.index: + last_input_event = event if event.pressed else null + last_alternate_event = null + else: + last_alternate_event = event if event.pressed else null + # If is pinching + if last_alternate_event: + if event.index == last_input_event.index: + var last_vector: Vector2 = last_alternate_event.position - last_input_event.position + var vector: Vector2 = last_alternate_event.position - event.position + var angle = vector.angle_to(last_vector) + rotation += angle + else: + var last_vector: Vector2 = last_alternate_event.position - last_input_event.position + var vector: Vector2 = event.position - last_input_event.position + var angle = vector.angle_to(last_vector) + rotation += angle + # If is dragging - if last_input_event: + elif last_input_event: # Handle mouse drag if last_input_event is InputEventMouse and event is InputEventMouse: var delta = event.position - last_input_event.position @@ -70,6 +95,8 @@ func _input(event: InputEvent): var delta = event.position - last_input_event.position position += delta last_input_event = event + else: + last_alternate_event = event ## Update the value of [can_place]. # DIRTY HACK: Relies on the placeable area being perfectly surrounded by solid bodies. @@ -89,7 +116,6 @@ func update_can_place(): if area is PlaceableArea: is_in_placeable_area = true - print("[Ghost] No overlap: ", no_overlapping_bodies, " | In area: ", is_in_placeable_area) can_place = no_overlapping_bodies and is_in_placeable_area diff --git a/interface/shop_ui.tscn b/interface/shop_ui.tscn index a52768f..02943d0 100644 --- a/interface/shop_ui.tscn +++ b/interface/shop_ui.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://cklkdygv61bny"] +[gd_scene load_steps=22 format=3 uid="uid://cklkdygv61bny"] [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_qdf0y"] [ext_resource type="PackedScene" uid="uid://dul1fpyh733t7" path="res://interface/purchasable_item.tscn" id="2_2dtc0"] @@ -20,6 +20,7 @@ [ext_resource type="Texture2D" uid="uid://bktdm8yu8tdfn" path="res://converters/item_converter/item_converter.png" id="14_1p6uj"] [ext_resource type="PackedScene" uid="uid://ddrhfhebwtq5" path="res://converters/item_converter/item_converter.tscn" id="14_tgckt"] [ext_resource type="Texture2D" uid="uid://caljydl4v2smk" path="res://converters/gold_to_coaldiamond/diamond_converter.png" id="15_ecie1"] +[ext_resource type="PackedScene" uid="uid://clanhkk4sg47w" path="res://converters/gold_to_coaldiamond/coal_diamond_converter.tscn" id="16_7ok54"] [node name="ShopUI" type="Panel"] anchors_preset = 15 @@ -121,10 +122,10 @@ layout_mode = 2 item_icon = ExtResource("5_lu2tr") item_name = "Silver-ifier" item_description = "Exchanges ten copper coins for a shiny silver coin!" -item_cost_text = "100 copper" +item_cost_text = "80 copper" item_scene = ExtResource("10_dui5v") item_cost_type = &"Copper" -item_cost_goal = 100 +item_cost_goal = 80 [node name="PurchasableItemPadding" parent="Rows/PaddedScrollable/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("3_4feaj")] layout_mode = 2 @@ -162,7 +163,10 @@ layout_mode = 2 item_icon = ExtResource("15_ecie1") item_name = "Coal-pressor" item_description = "Consumes ten gold coins to create either a precious white diamond or an useless lump of coal!" -item_cost_text = "??" +item_cost_text = "20 gold" +item_scene = ExtResource("16_7ok54") +item_cost_type = &"Gold" +item_cost_goal = 20 has_unlocked = false [node name="PurchasableItemPadding6" parent="Rows/PaddedScrollable/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("3_4feaj")] @@ -173,10 +177,10 @@ layout_mode = 2 item_icon = ExtResource("14_1p6uj") item_name = "Arti-factory" item_description = "Assembles an artifact from twenty-five gold coins and a gem or a diamond!" -item_cost_text = "??" +item_cost_text = "30 gems" item_scene = ExtResource("14_tgckt") item_cost_type = &"Gem" -item_cost_goal = 20 +item_cost_goal = 30 has_unlocked = false [node name="PurchasableItemPadding7" parent="Rows/PaddedScrollable/Scrollable/ScrollableItems/ConvertCategory" instance=ExtResource("3_4feaj")] @@ -232,9 +236,9 @@ layout_mode = 2 item_icon = ExtResource("8_caq4i") item_name = "Auto-silver" item_description = "Receive two silver coins per second!" -item_cost_text = "40 silver" +item_cost_text = "60 silver" item_cost_type = &"Silver" -item_cost_goal = 40 +item_cost_goal = 60 has_unlocked = false one_shot = true @@ -246,9 +250,9 @@ layout_mode = 2 item_icon = ExtResource("8_caq4i") item_name = "Super-silver" item_description = "Receive eight silver coins per second!" -item_cost_text = "5 gold" +item_cost_text = "6 gold" item_cost_type = &"Gold" -item_cost_goal = 5 +item_cost_goal = 6 has_unlocked = false one_shot = true @@ -260,9 +264,9 @@ layout_mode = 2 item_icon = ExtResource("9_amnej") item_name = "Auto-gold" item_description = "Receive two gold coins per second!" -item_cost_text = "15 gems" +item_cost_text = "8 gems" item_cost_type = &"Gem" -item_cost_goal = 15 +item_cost_goal = 8 has_unlocked = false one_shot = true @@ -274,9 +278,9 @@ layout_mode = 2 item_icon = ExtResource("9_amnej") item_name = "Tera-gold" item_description = "Receive eight gold coins per second!" -item_cost_text = "5 gems" +item_cost_text = "24 gems" item_cost_type = &"Gem" -item_cost_goal = 5 +item_cost_goal = 24 has_unlocked = false one_shot = true @@ -306,7 +310,9 @@ layout_mode = 2 item_icon = ExtResource("8_caq4i") item_name = "Quick silver" item_description = "Create a silver coin when tapping!" -item_cost_text = "??" +item_cost_text = "5 gold" +item_cost_type = &"Gold" +item_cost_goal = 5 has_unlocked = false one_shot = true @@ -318,7 +324,9 @@ layout_mode = 2 item_icon = ExtResource("9_amnej") item_name = "Midas Touch" item_description = "Create a gold coin when tapping!" -item_cost_text = "??" +item_cost_text = "20 gems" +item_cost_type = &"Gem" +item_cost_goal = 20 has_unlocked = false one_shot = true diff --git a/main.tscn b/main.tscn index b04b443..ee10b53 100644 --- a/main.tscn +++ b/main.tscn @@ -6,7 +6,7 @@ [ext_resource type="PackedScene" uid="uid://cklkdygv61bny" path="res://interface/shop_ui.tscn" id="2_qj86l"] [ext_resource type="Script" path="res://interface/custom_ui.gd" id="3_xav0n"] [ext_resource type="PackedScene" uid="uid://bo5unrhqpoyim" path="res://interface/game_ui.tscn" id="4_siim3"] -[ext_resource type="PackedScene" path="res://safe_ui.tscn" id="5_2uxda"] +[ext_resource type="PackedScene" uid="uid://bpvx3nkkbluip" path="res://safe_ui.tscn" id="5_2uxda"] [ext_resource type="Script" path="res://game_camera.gd" id="5_xxjtg"] [sub_resource type="GDScript" id="GDScript_kyj65"]