using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class EnemyHealth : MonoBehaviour
{
    private int score = 1;
    private bool alive = true;
    public DataEnemy dataEnemy;

    private float health;

    private float damage;

    public void Start(){
        health = dataEnemy.health;
        damage = dataEnemy.damage;
    }

    public void checkAlive(bool alive){
        if(!alive){
            UI_Manager uI_Manager = GameObject.FindGameObjectWithTag("Manager").GetComponent<UI_Manager>();
            uI_Manager.killCount(score);
            GameObject.Destroy(this.gameObject);
        }
    }
    public void takeDamage(float bulletDamage){
        health = health - bulletDamage;
        if(health <= 0){
            alive = false;
            checkAlive(alive);
        }
    }
}