using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; [RequireComponent(typeof(Health))] public abstract class Character : MonoBehaviour { [SerializeField] protected float speed; protected Health health; [SerializeField] protected int numberLives = 1; protected Animator animator; protected virtual void Awake() { health = GetComponent(); if (health != null) health.AddHealthExpiredListener(Die); // Debug.Log(health); } // Use this for initialization protected virtual void Start() { } //// Update is called once per frame //protected virtual void Update () { //} protected abstract void Die(); public void OnAttack(float damage) { if (health != null) { health.Value = Mathf.Max(health.Value - damage, 0); //Debug.Log("Attacked: " + health.Value); } } protected virtual void UpdateAnimator() { } }