using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace MPStudio
{
    public class ReduceText : MonoBehaviour
    {
       // public Transform parent;
        
        public float animalCost = 0.8f;
        
        private UnityEngine.UI.Text _text;

        private Vector3 initPos;
        public Vector3 targetPos =new Vector3(0,-30,0);

        private void Awake()
        {
            
            initPos =Vector3.zero;
        }

        private void Start()
        {
            _text = GetComponent<Text>();
            
           // transform.SetParent(parent,false);
            AutoMove autoMove=GetComponent<AutoMove>();
            
            StartCoroutine(TweenManager.Inst.ToVec3(initPos, targetPos, this.animalCost, (f) =>
            {
                transform.localPosition = f;
            }, () =>
            {
                autoMove.enabled = true;
                
                StartCoroutine(TweenManager.Inst.ToFloat(1f, 0f,this.animalCost, (f) =>
                {

                }, () =>
                {
                    StartCoroutine(TweenManager.Inst.ToFloat(1f, 0f,this.animalCost, (f) =>
                    {
                        var sr = _text;
                        sr.color =new Color(sr.color.r,sr.color.g,sr.color.b,f);
                    }, () =>
                    {
                    }));
                }));
            }));
        }
        

        public void UpdateText(string t)
        {
            //print("null"+_text);
            GetComponent<Text>(). text = t;
        }
    }
}