34 lines
526 B
C#
34 lines
526 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class Entity : MonoBehaviour
|
|
{
|
|
[Header("Health")]
|
|
public float health;
|
|
public float maxHealth;
|
|
[Header("Stats")]
|
|
public float speed;
|
|
public float jumpPower;
|
|
[Header("Cache")]
|
|
[SerializeField] protected Rigidbody2D rb;
|
|
|
|
public void TakeDamage(float damage)
|
|
{
|
|
health -= damage;
|
|
if (health <= 0)
|
|
{
|
|
OnDeath();
|
|
}
|
|
}
|
|
|
|
public void Heal(float healing)
|
|
{
|
|
health += healing;
|
|
health = Math.Clamp(health, 0, maxHealth);
|
|
}
|
|
|
|
protected virtual void OnDeath()
|
|
{
|
|
|
|
}
|
|
}
|