using System.Collections; using System.Collections.Generic; using DG.Tweening; using Invector; using Invector.vCharacterController; using Sirenix.OdinInspector; using UnityEngine; namespace Beyond { [RequireComponent(typeof(vIHealthController))] [RequireComponent(typeof(QuestObject))] public class HealAnimatorBase : MonoBehaviour { [SerializeField] protected Renderer m_renderer; protected Material m_material; public float m_healTime = 2f; public Ease m_easeType = Ease.InCubic; protected QuestObject m_questObject; protected vIHealthController m_healthController; protected v_SpriteHealth m_spriteBar; //protected bTriggerGenericAction m_trigger; protected virtual void Init() { if (m_renderer == null) m_renderer = GetComponent(); if (m_renderer == null) { Debug.LogError("No renderer found!", this); return; } m_material = m_renderer.material; m_healthController = GetComponent(); m_spriteBar = gameObject.GetComponentInChildren(); m_questObject = GetComponent(); //m_trigger = GetComponent(); //m_trigger.OnPressActionInput.AddListener(Heal); } /// /// Reveals healthbar /// public virtual void Reveal() { if (m_spriteBar) m_spriteBar.gameObject.SetActive(true); if (m_questObject) { m_questObject.enabled = true; } } protected virtual void Start() { if (m_spriteBar) m_spriteBar.gameObject.SetActive(false); if (m_questObject) { m_questObject.SetAlpha(0f); m_questObject.enabled = false; } } protected virtual void Awake() { Init(); } [Button] public virtual void Heal() { if (m_material == null) { Init(); } DOTween.Kill(m_material); if (m_questObject) { m_questObject.SetAlpha(0f); m_questObject.enabled = false; } m_healthController.ResetHealth(); } [Button] public virtual void Unheal() { if (m_material == null) { Init(); } DOTween.Kill(m_material); } } }