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

public class ScoreManager : MonoBehaviour
{
    /// <summary>
    /// The singleton instance of the ScoreManager.
    /// </summary>
    public static ScoreManager instance;

    /// <summary>
    /// The current score.
    /// </summary>
    public int score;

    /// <summary>
    /// The final score obtained in the game.
    /// </summary>
    public int finalScore;

    /// <summary>
    /// Sets the singleton instance to this ScoreManager.
    /// </summary>
    private void Awake()
    {
        instance = this;
    }

    /// <summary>
    /// Retrieves the score when the game starts.
    /// </summary>
    private void Start()
    {
        GetScore();
    }

    /// <summary>
    /// Adds points to the score based on the points obtained from enemies and the current wave.
    /// </summary>
    /// <param name="points">The points obtained from defeating enemies.</param>
    public void AddScore(int points)
    {
        score += points + WaveManager.currentWave;
        finalScore += points;
    }

    /// <summary>
    /// Removes points from the score, typically used when purchasing items.
    /// </summary>
    /// <param name="points">The points to be deducted from the score.</param>
    public void RemoveScore(int points)
    {
        score -= points;
    }

    /// <summary>
    /// Resets the score to zero.
    /// </summary>
    public void ResetScore()
    {
        score = 0;
    }

    /// <summary>
    /// Returns the current score.
    /// </summary>
    /// <returns>The current score.</returns>
    public int GetScore()
    {
        return score;
    }
}
