diff --git a/Game/scripts/HUDController.gd b/Game/scripts/HUDController.gd index 6310244f..35baf803 100644 --- a/Game/scripts/HUDController.gd +++ b/Game/scripts/HUDController.gd @@ -86,6 +86,9 @@ func _initialize_hud(): if game_manager and game_manager.has_signal("kickoff_countdown"): game_manager.kickoff_countdown.connect(_on_kickoff_countdown) + if game_manager and game_manager.has_signal("overtime_started"): + game_manager.overtime_started.connect(_on_overtime_started) + func _connect_ship_signals(): # Route ship telemetry to the flight instruments if ship.has_signal("speed_changed"): @@ -154,6 +157,11 @@ func _flash_score_label(label: Label) -> void: tween.tween_property(label, "scale", Vector2(1.4, 1.4), 0.1) tween.tween_property(label, "scale", Vector2(1.0, 1.0), 0.2) +func _on_overtime_started(): + if timer_label and is_instance_valid(timer_label): + timer_label.text = "OT" + timer_label.add_theme_color_override("font_color", Color(1.0, 0.85, 0.2)) + func _on_kickoff_countdown(count: int): if not kickoff_label or not is_instance_valid(kickoff_label): return diff --git a/Game/scripts/match_mode.gd b/Game/scripts/match_mode.gd index b8cd8d21..0143668b 100644 --- a/Game/scripts/match_mode.gd +++ b/Game/scripts/match_mode.gd @@ -7,10 +7,12 @@ extends GameMode signal timer_updated(minutes: int, seconds: int) signal score_changed(score: Dictionary) -# winning_team is -1 for a draw. +# winning_team is -1 for a draw. Never -1 when reached via overtime. signal match_ended(winning_team: int, score: Dictionary) # Counts 3, 2, 1, then 0 ("go", hide the label). signal kickoff_countdown(count: int) +# Full time ended level: sudden-death golden goal, no clock. +signal overtime_started # How long the result overlay stays up before returning to the menu. const RESULT_SCREEN_SECONDS := 5.0 @@ -27,6 +29,7 @@ const KICKOFF_COUNTDOWN_SECONDS := 3 var score := {0: 0, 1: 0} var match_timer: Timer +var _in_overtime := false func _start() -> void: @@ -71,6 +74,10 @@ func _on_goal_scored(conceding_team: int) -> void: score[scoring_team] += 1 score_changed.emit(score.duplicate()) print("Goal for team %d! Score: %d - %d" % [scoring_team, score[0], score[1]]) + if _in_overtime: + # Golden goal: the first score after a draw ends the match outright. + _end_match(scoring_team) + return await _run_kickoff_countdown() @@ -102,10 +109,23 @@ func _set_frozen(frozen: bool) -> void: func _on_match_timer_timeout() -> void: - print("Full time! Final score: %d - %d" % [score[0], score[1]]) - var winning_team := -1 - if score[0] != score[1]: - winning_team = 0 if score[0] > score[1] else 1 + print("Full time! Score: %d - %d" % [score[0], score[1]]) + if score[0] == score[1]: + await _start_overtime() + return + _end_match(0 if score[0] > score[1] else 1) + + +# Full time ended level: sudden-death golden goal, no clock running. +# _on_goal_scored checks _in_overtime and ends the match on the next goal. +func _start_overtime() -> void: + _in_overtime = true + overtime_started.emit() + await _run_kickoff_countdown() + + +func _end_match(winning_team: int) -> void: + print("Match over! Final score: %d - %d" % [score[0], score[1]]) match_ended.emit(winning_team, score.duplicate()) # Freeze gameplay while the HUD (process_mode ALWAYS) shows the result. get_tree().paused = true