2024-03-31 19:32:00 +11:00
|
|
|
class_name GameEndScreen extends PanelContainer
|
2024-02-22 06:22:22 +11:00
|
|
|
|
|
|
|
@export var box: PackedScene
|
2023-11-08 14:28:55 +11:00
|
|
|
|
2024-03-31 19:32:00 +11:00
|
|
|
@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
|
|
|
|
|
2023-11-08 14:28:55 +11:00
|
|
|
|
2023-12-17 02:02:16 +11:00
|
|
|
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)
|
2024-03-31 19:32:00 +11:00
|
|
|
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
|
2024-03-31 19:32:00 +11:00
|
|
|
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])
|
2023-12-17 02:02:16 +11:00
|
|
|
|
|
|
|
|
2024-03-31 19:32:00 +11:00
|
|
|
func set_outcome_message(message: String) -> void:
|
|
|
|
outcome_label.text = message
|
|
|
|
|
|
|
|
|
2023-11-08 14:28:55 +11:00
|
|
|
func _on_quit_button_pressed() -> void:
|
2023-11-20 21:20:29 +11:00
|
|
|
Game.scene_switch_main_menu()
|
|
|
|
queue_free()
|
2023-11-08 14:28:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
func _on_play_button_pressed() -> void:
|
2024-03-31 19:32:00 +11:00
|
|
|
Game.setup()
|
|
|
|
Game.start()
|
2023-11-08 14:28:55 +11:00
|
|
|
queue_free()
|
2023-12-17 02:02:16 +11:00
|
|
|
|
|
|
|
|
|
|
|
func _on_button_mouse_entered() -> void:
|
|
|
|
$AudioStreamPlayer.play()
|