using System;
using UnityEngine;
using UnityEngine.UI;

namespace MPStudio
{
    
  
    public class DelayFadeOut2:MonoBehaviour
    {
        public bool autoDestroy = true;
        
        public bool isSp = true;
        
        [SerializeField] private float delayTime = 1f;

        [SerializeField] private float animalCost = 1f;
        protected virtual void OnEnable()
        {
            Animal();
        }

        protected virtual void ActionRun()
        {
         if(autoDestroy)   Destroy(this.gameObject);
        }

        protected void OnDisable()
        {
        }
        
        protected virtual void Animal()
        {
            StartCoroutine(TweenManager.Inst.ToFloat(1f, 1.5f,this.delayTime, (f) =>
            {
                //什么都不做
            }, () =>
            {
                TweenManager.Inst.GrowAlpha(transform,this.isSp,this.animalCost,1,0, () =>
                {
                    ActionRun();
                });
            }));
        }
    }
}