using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FlyFruitAnim : MonoBehaviour
{
    public GameObject targetObj;
    private Vector3 targetV;

    private void OnEnable()
    {
        if (targetObj != null)
        {
            targetV = targetObj.transform.position;
            Debug.Log("v.x " + targetV.x + "v.y " + targetV.y + "v.z " + targetV.z);
        }
        if (targetV == null)
        {
            targetV = new Vector3(0, 0, 0);
        }
        transform.DOMove(targetV, 1f).OnComplete(dissmissFlyFruit).SetEase(Ease.Linear);
    }

    private void dissmissFlyFruit()
    {
        var s = DOTween.Sequence();
        s.Append(targetObj.transform.DOScale(1.2f, 0.1f).SetEase(Ease.Linear));
        s.Append(targetObj.transform.DOScale(1f, 0.1f).SetEase(Ease.Linear).OnComplete(onPlayEnd));
    }
    private void onPlayEnd()
    {
        transform.localPosition = new Vector3(0, 0, 0);
        transform.gameObject.SetActive(false);
    }

}
