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

public class PlayerManager : Singleton<PlayerManager>
{
    private const string MAX_KILLS = "MaxKills";
    public UnitController unit;
    public Transform look;
    public Transform follow;

    public delegate void OnPlayerDeath();
    public OnPlayerDeath playerDeath;
    public delegate void OnPlayerLive();
    public OnPlayerLive playerLive;

    private bool gameStarted = false;

    private int maxKills = 0;
    private int kills = 0;

    void Update() {
        maxKills = PlayerPrefs.GetInt(MAX_KILLS,0);
        if(unit != null) {
            if(playerLive != null)
                playerLive();
        }
    }

    public void IncrementKills() {
        kills++;
        if(kills > maxKills) {
            maxKills = kills;
            PlayerPrefs.SetInt(MAX_KILLS,maxKills);
        }
    }

    public int GetKills() {
        return this.kills;
    }

    public int GetMaxKills() {
        return this.maxKills;
    }

    public void Reset() {
        kills = 0;
        if(playerDeath != null) {
            playerDeath();
        }
    }
}
