33 lines
680 B
C#
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);
|
|
}
|
|
}
|
|
}
|