Fix devil idol ui

This commit is contained in:
2026-05-17 16:51:07 +02:00
parent 41466af1ca
commit 4fd23d9416
14 changed files with 89 additions and 31 deletions

View File

@@ -98,7 +98,7 @@ func _update_worker_display() -> void:
var worker_currency: Currency = _get_worker_currency()
var can_assign: bool = false
if worker_currency != null and _alchemy_worker_count < 10:
if worker_currency != null and _alchemy_worker_count < _alchemy_tower.data.max_workers:
var worker_balance: BigNumber = _game_state.get_currency_amount(worker_currency)
can_assign = worker_balance.mantissa >= 1.0

View File

@@ -30,9 +30,9 @@ shape = SubResource("RectangleShape2D_barracks")
[node name="GeneratorContainer" parent="." unique_id=1905754561 node_paths=PackedStringArray("_generator") instance=ExtResource("5_panel")]
visible = false
offset_left = 138.0
offset_left = 70.0
offset_top = -100.0
offset_right = 402.0
offset_right = 334.0
offset_bottom = 110.0
_generator = NodePath("../CurrencyGenerator")

View File

@@ -7,6 +7,7 @@ const PRESTIGE_GOAL_ID: StringName = &"gold_350k_wood_20k"
func _ready() -> void:
_prestige_panel.visible = false
if game_state:
game_state.goal_completed.connect(_on_goal_completed)

View File

@@ -45,6 +45,8 @@ func _ready() -> void:
# Connect to goal completion for unlocking
game_state.goal_completed.connect(_on_goal_completed)
# Refresh button state when unit balance changes
game_state.currency_changed.connect(_on_currency_changed)
# If goal was already completed in a previous session, unlock immediately
if game_state.is_goal_completed(UNLOCK_GOAL_ID):
@@ -67,6 +69,10 @@ func _on_goal_completed(goal_id: StringName) -> void:
_unlock_idol()
func _on_currency_changed(currency_id: StringName, _new_amount: BigNumber) -> void:
if currency_id == &"unit":
_update_ui()
func _unlock_idol() -> void:
_is_targetable = true
@@ -103,9 +109,10 @@ func _update_ui() -> void:
return
var progress_pct: float = 0.0
if _max_hp.mantissa > 0.0:
progress_pct = (1.0 - (_current_hp.mantissa / _max_hp.mantissa)) * pow(10.0, float(_current_hp.exponent - _max_hp.exponent))
progress_pct = clampf(progress_pct * 100.0, 0.0, 100.0)
var max_float: float = _max_hp.to_float()
if max_float > 0.0:
var current_float: float = _current_hp.to_float()
progress_pct = clampf((1.0 - current_float / max_float) * 100.0, 0.0, 100.0)
_hp_value.text = "%s / %s (%.1f%%)" % [_current_hp.to_string_suffix(2), _max_hp.to_string_suffix(2), progress_pct]

View File

@@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://cj0sxoceqqyrm" path="res://docs/gyms/tiny_sword/buildings/monastery/monastery.gd" id="1_e17qd"]
[ext_resource type="Texture2D" uid="uid://dlmjd2berkb6v" path="res://docs/gyms/tiny_sword/buildings/monastery/Monastery.png" id="1_yyw6r"]
[ext_resource type="PackedScene" uid="uid://dd8roif0mqirl" path="res://core/research/research_panel.tscn" id="3_c6gi6"]
[ext_resource type="PackedScene" uid="uid://6d101h70mcx" path="res://core/research/research_panel.tscn" id="3_c6gi6"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_yyw6r"]
size = Vector2(160, 254)
@@ -21,10 +21,10 @@ shape = SubResource("RectangleShape2D_yyw6r")
[node name="ResearchPanel" parent="." unique_id=1105274967 instance=ExtResource("3_c6gi6")]
visible = false
offset_left = 78.0
offset_top = -98.0
offset_right = 478.0
offset_bottom = 128.0
offset_left = 59.0
offset_top = -87.0
offset_right = 459.0
offset_bottom = 139.0
[connection signal="mouse_entered" from="Area2D" to="." method="_on_area_2d_mouse_entered"]
[connection signal="mouse_exited" from="Area2D" to="." method="_on_area_2d_mouse_exited"]