using System;
using Unity.VisualScripting;
using UnityEngine;
using VContainer;

public class ScoreService
{
    public int score { get; private set; }
    public int HighScore = PlayerPrefs.GetInt("HighScore", 0);
    [Inject] GameScreenController gameScreenController;
    [Inject] StartScreenController startScreenController;

    public void AddScore()
    {
        if (!startScreenController.hasGameStarted) return;
        score += 5;
        gameScreenController.UpdateScore(score);
        if(score>HighScore)
        {
            SetHighScore();
        }
        Debug.Log(score);
    }

    private void SetHighScore()
    {
        HighScore = score;
        PlayerPrefs.SetInt("HighScore",HighScore);
        PlayerPrefs.Save();
    }

    public int GetHighscore()
    {
        return PlayerPrefs.GetInt("HighScore",0);
    }

}
