PBG2H23ABR_PBG2H23AKL_PMC_P.../Plunderblock/Assets/Scripts/ScriptsKevin/Enemy.cs
2024-06-27 10:27:18 +02:00

33 lines
680 B
C#

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class Enemy : MonoBehaviour
{
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){
GameObject.Destroy(this.gameObject);
}
}
public void takeDamage(float bulletDamage){
health = health - bulletDamage;
if(health <= 0){
alive = false;
checkAlive(alive);
}
}
}