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

public class HealthScript : MonoBehaviour {

    public float health;
    public float regen;
    public float orighealth;

    public void Start()
    {
        orighealth = health;
    }

    // Update is called once per frame
    public void TakeDamage(float amt)
    {
        //if (gameObject.name == "wire") print("hell");
        health -= amt;
        if (health <= 0) Destroy(gameObject);
    }

    public void TakeHit(Vector3 v)
    {
        GetComponent<Rigidbody2D>().AddForce(v * 10);
    }

    public void Act(string how)
    {
        if (how == "Laser")
        {
            try
            {
                GetComponent<Animator>().SetTrigger("Laser");
            }catch(System.Exception e)
            {

            }
        }
    }

    public void Update()
    {
        
        health += regen * Time.deltaTime;
        if (health > orighealth) health = orighealth;
    }
}
