Encounter / Assets / Scripts / GUIHandlers / GameOverUI.cs
GameOverUI.cs
Raw
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

/// <summary>
/// Handles the Game Over GUI functionalities
/// </summary>
public class GameOverUI : MonoBehaviour
{
    public static GameOverUI Instance { get; private set; }

    [Header("Canvas Attributes")]
    [SerializeField] private TextMeshProUGUI encounterText;

    /// <summary>
    /// Just sets the static instance of the active game over UI
    /// </summary>
    private void Awake()
        => Instance = this;
    /// <summary>
    /// Takes the player back to the title screen to create a new player
    /// </summary>
    public void BackToTitleScreen()
        => SceneManager.LoadScene(0);
    /// <summary>
    /// Closes out of the game for the player
    /// </summary>
    public void ApplicationQuit()
        => Application.Quit();
    /// <summary>
    /// Injects statistic information that the player might be interested in upon a game over
    /// </summary>
    /// <param name="gameManager"></param>
    public void InjectGameMangerInfo(GameManager gameManager)
    {
        // Minus one value since they died at the last encounter
        encounterText.text = $"You survived\n{gameManager.GetEncounterValue() - 1}\nEncounters!";

        // TODO ---> Indicate cause of death for the player and the party

        // TODO ---> Create a stats class and have the game manager and the stats communicate
        // information before injecting the stats class from the game manager to the game over screen
    }
}