mtd/Scenes/Menus/GameEndScreen/game_end_screen.gd

46 lines
1.5 KiB
GDScript3
Raw Permalink Normal View History

class_name GameEndScreen extends PanelContainer
2024-02-22 06:22:22 +11:00
@export var box: PackedScene
@export var outcome_label: Label
@export var winrate_label: Label
@export var total_games_label: Label
@export var total_wins_label: Label
@export var total_losses_label: Label
@export var undefeated_enemies: VBoxContainer
func _ready() -> void:
2024-02-22 06:22:22 +11:00
var wins: int = Data.save_stats.twenty_game_history.count(true)
var games: int = Data.save_stats.twenty_game_history.size()
var winrate: int = int((float(wins) / float(games)) * 100.0)
winrate_label.text = "Your 20-game winrate is now: " + str(winrate) + "%!"
total_games_label.text = "Total games: " + str(Data.save_stats.wins + Data.save_stats.losses)
total_wins_label.text = "Total wins: " + str(Data.save_stats.wins)
total_losses_label.text = "Total losses: " + str(Data.save_stats.losses)
2024-02-22 06:22:22 +11:00
for wave_key: int in Game.stats.enemies_undefeated:
var spawned_box: EnemyBox = box.instantiate() as EnemyBox
undefeated_enemies.add_child(spawned_box)
2024-02-22 06:22:22 +11:00
spawned_box.set_wave(wave_key)
for enemy_key: Enemy in Game.stats.enemies_undefeated[wave_key]:
spawned_box.add_enemy_tag(enemy_key, Game.stats.enemies_undefeated[wave_key][enemy_key])
func set_outcome_message(message: String) -> void:
outcome_label.text = message
func _on_quit_button_pressed() -> void:
2023-11-20 21:20:29 +11:00
Game.scene_switch_main_menu()
queue_free()
func _on_play_button_pressed() -> void:
Game.setup()
Game.start()
queue_free()
func _on_button_mouse_entered() -> void:
$AudioStreamPlayer.play()