using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class Performance : MonoBehaviour
{
    // Wave Completion Performance
    public TextMeshProUGUI wave_damageText; // Text for displaying damage dealt during the wave
    public TextMeshProUGUI wave_shipsDestroyedText; // Text for displaying ships destroyed during the wave
    public TextMeshProUGUI wave_shotsFiredText; // Text for displaying shots fired during the wave
    public TextMeshProUGUI wave_wavesSurvived; // Text for displaying waves survived during the wave
    public TextMeshProUGUI wave_moneyText; // Text for displaying money earned during the wave

    // Game Over Performance
    public TextMeshProUGUI gameOver_damageText; // Text for displaying total damage dealt in the game
    public TextMeshProUGUI gameOver_shipsDestroyedText; // Text for displaying total ships destroyed in the game
    public TextMeshProUGUI gameOver_shotsFiredText; // Text for displaying total shots fired in the game
    public TextMeshProUGUI gameOver_wavesSurvived; // Text for displaying total waves survived in the game
    public TextMeshProUGUI gameOver_scoreText; // Text for displaying final score in the game

    // Performance data
    public static int damageDealt; // Total damage dealt
    public static int shipsDestroyed; // Total ships destroyed
    public static int shotsFired; // Total shots fired

    /// <summary>
    /// Updates the performance display.
    /// </summary>
    private void Update()
    {
        // Update wave completion performance
        UpdateWavePerformance();

        // Update game over performance
        UpdateGameOverPerformance();
    }

    /// <summary>
    /// Updates the wave completion performance display.
    /// </summary>
    private void UpdateWavePerformance()
    {
        // Display wave completion performance
        wave_damageText.text = "Damage Dealt: " + damageDealt.ToString();
        wave_shipsDestroyedText.text = "Ships Destroyed: " + shipsDestroyed.ToString();
        wave_shotsFiredText.text = "Shots Fired: " + shotsFired.ToString();
        wave_wavesSurvived.text = "Waves Survived: " + WaveManager.currentWave.ToString();
        wave_moneyText.text = "$" + ScoreManager.instance.score.ToString();
    }

    /// <summary>
    /// Updates the game over performance display.
    /// </summary>
    private void UpdateGameOverPerformance()
    {
        // Display game over performance
        gameOver_damageText.text = "Damage Dealt: " + damageDealt.ToString();
        gameOver_shipsDestroyedText.text = "Ships Destroyed: " + shipsDestroyed.ToString();
        gameOver_shotsFiredText.text = "Shots Fired: " + shotsFired.ToString();
        gameOver_wavesSurvived.text = "Waves Survived: " + WaveManager.currentWave.ToString();
        gameOver_scoreText.text = ScoreManager.instance.finalScore.ToString();
    }
}
