using System; using System.Collections; using UnityEngine; public class Entity : MonoBehaviour { [Header("Health")] public float health; public float maxHealth; [Header("Movement")] public int maxMovement; public TileObject currentTile; public float moveAnimSpeed; [Header("Flags")] public bool canMove = true; public bool invincible; public void TakeDamage(float damage) { health -= damage; if (health <= 0) { OnKillEffects(); } } public void Heal(float healing) { health += healing; health = Mathf.Clamp(health, 0, maxHealth); } protected virtual void OnKillEffects() { } public virtual IEnumerator MoveToLocation(TileObject[] pathToMove) { float currentState = 0; int currentTileList = 0; while (currentTileList < pathToMove.Length) { currentState += Time.deltaTime * moveAnimSpeed; transform.position = Vector2.Lerp(currentTile.transform.position, pathToMove[currentTileList].transform.position, currentState); if (currentState > 1) { currentTile = pathToMove[currentTileList]; currentState = 0; currentTileList++; } yield return null; } } }