feat: Add stage counter (logic & HUD control)

This commit is contained in:
Dendy 2026-03-05 13:31:28 +01:00
parent 8d0ca1a769
commit eba0831690
2 changed files with 21 additions and 1 deletions

View File

@ -14,6 +14,8 @@ var pedestrian_area_count = 0
var max_stamina: float = BASE_STAMINA var max_stamina: float = BASE_STAMINA
var stamina: float = max_stamina var stamina: float = max_stamina
var stage_counter: int = 0
func _ready() -> void: func _ready() -> void:
$Upgrades.update() $Upgrades.update()
@ -27,6 +29,7 @@ func _process(delta: float) -> void:
return return
$HUD/StaminaRect.scale.x = stamina / max_stamina $HUD/StaminaRect.scale.x = stamina / max_stamina
$HUD/StageLabel.text = "Stage %d" % [stage_counter + 1]
var time_left = int($TimeLimit.time_left) var time_left = int($TimeLimit.time_left)
@warning_ignore("integer_division") @warning_ignore("integer_division")
@ -56,6 +59,7 @@ func _on_area_area_entered(area: Area3D) -> void:
print(pedestrian_area_count) print(pedestrian_area_count)
if area.name == "StationArea": if area.name == "StationArea":
stage_counter += 1
station_reached.emit() station_reached.emit()
@ -71,6 +75,7 @@ func _on_time_limit_timeout():
func _on_retry_button_pressed(): func _on_retry_button_pressed():
stage_counter = 0
$FailControl.visible = false $FailControl.visible = false
$HUD.visible = true $HUD.visible = true
station_reached.emit() station_reached.emit()

View File

@ -43,7 +43,7 @@ shape = SubResource("CylinderShape3D_i3pqv")
debug_color = Color(0.41852123, 0.4635067, 0.996484, 0.41960785) debug_color = Color(0.41852123, 0.4635067, 0.996484, 0.41960785)
[node name="TimeLimit" type="Timer" parent="." unique_id=1568603467] [node name="TimeLimit" type="Timer" parent="." unique_id=1568603467]
wait_time = 10.0 wait_time = 60.0
one_shot = true one_shot = true
[node name="FailControl" type="Control" parent="." unique_id=640174831] [node name="FailControl" type="Control" parent="." unique_id=640174831]
@ -107,6 +107,21 @@ anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="StageLabel" type="Label" parent="HUD" unique_id=971924774]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -28.0
offset_top = 10.0
offset_right = 29.0
offset_bottom = 33.0
grow_horizontal = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 20
text = "Stage X"
horizontal_alignment = 1
[node name="TimeLimitLabel" type="Label" parent="HUD" unique_id=1179212384] [node name="TimeLimitLabel" type="Label" parent="HUD" unique_id=1179212384]
layout_mode = 0 layout_mode = 0
offset_left = 10.0 offset_left = 10.0