1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-10-16 06:17:27 +00:00

Limit deletion to single converter

This commit is contained in:
Steffo 2023-10-02 21:42:07 +02:00
parent 2efdb5ebee
commit 3b27e8a269
Signed by: steffo
GPG key ID: 2A24051445686895
10 changed files with 22 additions and 15 deletions

View file

@ -5,6 +5,7 @@
"**/*.tres": true,
"**/*.tscn": true,
"**/*.import": true,
"**/*.png": true,
},
"files.associations": {
"*.gdignore": "ignore",

View file

@ -40,7 +40,7 @@ func ending_deletion():
sprite_front.modulate = Color.WHITE
is_pending_deletion = false
func _input(event: InputEvent):
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()

View file

@ -136,5 +136,6 @@ stream = ExtResource("11_r8505")
[node name="ConverterPlacementBody" parent="." instance=ExtResource("12_5qhgs")]
[connection signal="input_event" from="." to="." method="_on_input_event"]
[connection signal="goal" from="Collector" to="." method="_on_collector_goal"]
[connection signal="timeout" from="ConversionTimer" to="." method="_on_timer_timeout"]

View file

@ -144,6 +144,7 @@ stream = ExtResource("11_5c46k")
[node name="ConverterPlacementBody" parent="." instance=ExtResource("12_xld3l")]
[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="timeout" from="ConversionTimer" to="." method="_on_timer_timeout" flags=18]

View file

@ -148,6 +148,7 @@ stream = ExtResource("12_vklpo")
[node name="ConverterPlacementBody" parent="." instance=ExtResource("13_6o73w")]
[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="timeout" from="ConversionTimer" to="." method="_on_timer_timeout" flags=18]

View file

@ -227,6 +227,7 @@ 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="timeout" from="ConversionTimer" to="." method="_on_timer_timeout" flags=18]

View file

@ -122,6 +122,7 @@ stream = ExtResource("11_ow0vy")
[node name="ConverterPlacementBody" parent="." instance=ExtResource("12_37x2h")]
[connection signal="input_event" from="." to="." method="_on_input_event"]
[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"]

View file

@ -35,6 +35,7 @@ func _on_purchase_begin(what: PurchasableItem):
print("[Game] Beginning purchase of ", what.name, " costing ", what.item_cost_goal, "x ", what.item_cost_type)
store_collector.collecting_types = [what.item_cost_type]
store_collector.collecting_amount = what.item_cost_goal
store_collector.collected_count = 0
store_collector.goal.connect(_handle_purchase_success.bind(what))
update_counter_icon()
update_counter_text()

View file

@ -67,7 +67,7 @@ position = Vector2(136, 0)
target = NodePath("..")
buffer_cap = 1
spawn_rect = Rect2(-20, 0, 40, 0)
overlapping_body_count_limit = 4
overlapping_body_count_limit = 16
metadata/_edit_lock_ = true
[node name="NeckShape" type="CollisionShape2D" parent="TimeSpawner"]
@ -99,7 +99,7 @@ scene = ExtResource("13_4j8om")
target = NodePath("..")
buffer_cap = 10
spawn_rect = Rect2(-20, 0, 40, 0)
overlapping_body_count_limit = 4
overlapping_body_count_limit = 16
metadata/_edit_lock_ = true
[node name="NeckShape" type="CollisionShape2D" parent="ButtonSpawner"]

View file

@ -39,20 +39,14 @@ func _on_any_purchase_begin(what: Node):
if what.item_scene:
ghost_requested.emit(what.item_scene, what.item_icon)
purchase_begin.emit(what)
for item in purchasable_items:
if item == what:
continue
item.can_buy = false
set_all_can_buy(false, what)
func _on_any_purchase_cancel(what: Node):
if not what is PurchasableItem:
push_error("Purchase cancelled outside a PurchasableItem")
return
purchase_cancel.emit(what)
for item in purchasable_items:
if item == what:
continue
item.can_buy = true
set_all_can_buy(true, what)
func _on_any_purchase_success(what: Node):
if not what is PurchasableItem:
@ -61,10 +55,7 @@ func _on_any_purchase_success(what: Node):
if what.item_scene:
ghost_materialize.emit()
purchase_success.emit(what)
for item in purchasable_items:
if item == what:
continue
item.can_buy = true
set_all_can_buy(true, what)
func _on_game_score_changed(total: int):
score_button.set_score(total)
@ -159,9 +150,18 @@ func _on_delete_button_pressed():
is_deleting = false
delete_button.text = "Del"
delete_button.modulate = Color.WHITE
set_all_can_buy(true, null)
delete_cancel.emit()
else:
is_deleting = true
delete_button.text = "Undo"
delete_button.modulate = Color.RED
set_all_can_buy(false, null)
delete_begin.emit()
func set_all_can_buy(state: bool, except: PurchasableItem):
for item in purchasable_items:
if item == except:
continue
item.can_buy = state