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

33 lines
680 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class Enemy : MonoBehaviour
{
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){
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);
}
}
}