using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.SocialPlatforms.Impl;

public class score : MonoBehaviour
{
    public MenuControler menuControler;
    public PLayerLife playerLife;
    public TMP_Text scoretext;
    public TMP_Text finalScoreText;
    public float scoreAmount;
    public float pointIncreasedPerSecond;

    public float highscoreAmount;
    public GameObject highscore;
    public TMP_Text HighScoreText;

    // Start is called before the first frame update
    void Start()
    {
        //highscoreAmount = PlayerPrefs.GetFloat("HighScore");
        scoreAmount = 0f;
        pointIncreasedPerSecond = 1f;
        highscore.SetActive(false);
    }

    // Update is called once per frame
    void Update()
    {
        HighScoreText.text = "HIGHSCORE: " + (int)highscoreAmount;
        finalScoreText.text = "SCORE: " + (int)scoreAmount;
        
        if (menuControler.playing && playerLife.Hp>0)
        {
            scoretext.text = (int)scoreAmount + "";
            scoreAmount += pointIncreasedPerSecond * Time.deltaTime;
        }

        highscore.SetActive(scoreAmount > highscoreAmount);

    }

    public void SetHighscore(int highscore)
    {
        highscoreAmount += (float)highscore;
    }
}
