44 lines
760 B
C#
44 lines
760 B
C#
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class Entity : MonoBehaviour
|
|
{
|
|
private int maxHealth;
|
|
private int currentHealth;
|
|
private int attackDamage;
|
|
|
|
[SerializeField] private EntityData data;
|
|
|
|
void Awake()
|
|
{
|
|
maxHealth = data.maxHealth;
|
|
currentHealth = data.maxHealth;
|
|
attackDamage = data.attackDamage;
|
|
}
|
|
|
|
public virtual void TakeDamage(int playerAttackDamage)
|
|
{
|
|
currentHealth -= playerAttackDamage;
|
|
if (currentHealth <= 0)
|
|
{
|
|
currentHealth = 0;
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
|
|
void Update()
|
|
{
|
|
RunAI();
|
|
}
|
|
|
|
protected void RunAI() { }
|
|
|
|
|
|
public int getAttackDamage()
|
|
{
|
|
return attackDamage;
|
|
}
|
|
|
|
}
|