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

public class PlayerState : MonoBehaviour    
{
    public static List<string> inventory = new List<string>();
    static private int itemNum;
    private static float heartBeat, heartBeatLimit, moveFactor;
    public float secOffset;
    private int count;
    public int hp;
    private static float nowHp;

    // Start is called before the first frame update
    void Start()
    {
        itemNum = 0;
        heartBeat = 80f;
        heartBeatLimit = 140f;
        moveFactor = 0f;
        secOffset = 1f;
        count = 0;
        nowHp = hp;
    }

    // Update is called once per frame
    void Update()
    {
        float heartBeatFactor = 0;
        Debug.Log(heartBeat);
        Debug.Log(nowHp);
        if (Time.time > secOffset * count)
        {
            if (heartBeat > 80)
            {
                heartBeatFactor -= 3f;
            }
            if (heartBeat <= heartBeatLimit)
            {
                heartBeatFactor += moveFactor;                
            }
            heartBeat += heartBeatFactor;
            count++;         
            if(heartBeat > 140)
            {
                heartBeat = 140;
            }
        }
    }

    public static void AddItem(string name)
    {
        inventory.Add(name);
        itemNum++;
    }

    public static void RemoveItem(string name)
    {
        inventory.Remove(name);
        itemNum--;
    }

    public static void walkHeartBeat(float walkFactor)
    {
        moveFactor = walkFactor;
    }

    public static void hurt()
    {
        nowHp--;
        HurtEffect.Flash();
    }
}
