moved stuff to a different entity script
This commit is contained in:
parent
f4344c4700
commit
a0bfc600ef
14 changed files with 497 additions and 189 deletions
|
|
@ -4,45 +4,14 @@ using UnityEngine;
|
|||
|
||||
public class Entity : MonoBehaviour
|
||||
{
|
||||
[Header("Health")]
|
||||
public float health;
|
||||
public float maxHealth;
|
||||
[Header("Stats")]
|
||||
public float speed;
|
||||
public float jumpPower;
|
||||
[Header("Abilities")]
|
||||
public List<Ability> abilities = new();
|
||||
public Transform attackOriginPoint;
|
||||
[SerializeField] protected Transform attackOriginCenter;
|
||||
[Header("Stats")]
|
||||
public EntityStats stats;
|
||||
[Header("Cache")]
|
||||
[SerializeField] protected Rigidbody2D rb;
|
||||
public List<Entity> entitiesInRange = new();
|
||||
public Entity closestEntity;
|
||||
[Header("Ground Detection")]
|
||||
[SerializeField] private Transform groundCheck;
|
||||
[SerializeField] private LayerMask groundLayer;
|
||||
|
||||
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()
|
||||
public virtual void OnDeath()
|
||||
{
|
||||
|
||||
}
|
||||
protected bool OnGround()
|
||||
{
|
||||
return Physics2D.OverlapCircle(groundCheck.position, 0.05f, groundLayer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue