feat: Change rank based on time left

This commit is contained in:
Dendy 2026-03-05 18:41:24 +01:00
parent 1efde00f1e
commit 4f601ec9f7
2 changed files with 17 additions and 2 deletions

View File

@ -9,6 +9,13 @@ const SLOW_MULT = 0.5
const STAMINA_COST = 15 const STAMINA_COST = 15
const STAMINA_RECOVER = 10 const STAMINA_RECOVER = 10
const SCORE_RANK = {
"C": { "time": 10, "money": 500, "color": Color.BROWN },
"B": { "time": 20, "money": 1000, "color": Color.PURPLE },
"A": { "time": 30, "money": 1500, "color": Color.GREEN },
"S": { "time": 999, "money": 2000, "color": Color.YELLOW },
}
var pedestrian_area_count = 0 var pedestrian_area_count = 0
var max_stamina: float = BASE_STAMINA var max_stamina: float = BASE_STAMINA
@ -61,9 +68,18 @@ func _on_area_area_entered(area: Area3D) -> void:
if area.name == "StationArea": if area.name == "StationArea":
$FinishControl.visible = true $FinishControl.visible = true
$HUD.visible = false $HUD.visible = false
var scoreLbl = $FinishControl/ScoreLabel
for letter in SCORE_RANK:
var rank = SCORE_RANK[letter]
if $TimeLimit.time_left > rank["time"]:
continue
scoreLbl.text = letter
scoreLbl.add_theme_color_override("font_color", rank["color"])
break
$TimeLimit.stop() $TimeLimit.stop()
func _on_area_area_exited(area: Area3D) -> void: func _on_area_area_exited(area: Area3D) -> void:
if area.name == "PedestrianArea": if area.name == "PedestrianArea":
pedestrian_area_count -= 1 pedestrian_area_count -= 1

View File

@ -97,7 +97,6 @@ offset_bottom = 4.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
pivot_offset_ratio = Vector2(0.5, 0.5) pivot_offset_ratio = Vector2(0.5, 0.5)
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_font_sizes/font_size = 20 theme_override_font_sizes/font_size = 20
text = "Diners guanyat: text = "Diners guanyat:
Diners total:" Diners total:"