PBG2H23ABR_PBG2H23AKL_PMC_P.../Plunderblock/Assets/Scripts/ScriptsKevin/EnemyHealth.cs

36 lines
862 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
2024-07-03 12:46:41 +02:00
public class EnemyHealth : MonoBehaviour
{
private int score = 1;
private bool alive = true;
public DataEnemy dataEnemy;
2024-06-27 10:27:18 +02:00
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){
2024-06-27 10:27:18 +02:00
health = health - bulletDamage;
if(health <= 0){
alive = false;
2024-06-27 10:27:18 +02:00
checkAlive(alive);
}
}
}