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

public class Enemy : MonoBehaviour
{
    float EnemyHP = 100;
    public float EnemyMaxHP = 100;

    void Start()
    {
        EnemyHP = EnemyMaxHP;
    }

    // Update is called once per frame
    void Update()
    {
        detactDeath();
    }
    private void detactDeath()
    {
        if (EnemyHP <= 0){
            Destroy(this.gameObject);
        }
    }
    public void ReactToHit(float Damage,GameObject damageSource)
    {
        EnemyHP -= Damage;
        Debug.Log("HP:"+ EnemyHP);
        if(EnemyHP <= 0)
        {
            damageSource.GetComponent<AgentWithGun>().GotKill();
            Destroy(this.gameObject);
        }
    }
    public float getnowHP()
    {
        return EnemyHP;
    }
}
