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

public class CloudWaterAnim : MonoBehaviour
{
    public GameObject cloudObj;
    public GameObject littleWater;
    public GameObject targetObj;
    private void OnEnable()
    {
        //transform.DOScale(new Vector3(1f, 1f, 1f), 0.5f);
        //var s = DOTween.Sequence();
        //s.Append(transform.DOMove(v, 1f).SetEase(Ease.Linear));
        //s.Append(littleWater.transform.DOMove(new Vector3(v.x, v.y, v.z), 0.5f).SetEase(Ease.Linear).OnComplete(resetAnim));
        //transform.DOScale(new Vector3(1f, 1f, 1f), 0.5f);
        Vector3 v = targetObj.transform.position;
        littleWater.SetActive(false);
        //Debug.Log("v.x " + v.x + "v.y " + v.y + "v.z " + v.z);
        var s = DOTween.Sequence();
        s.Append(transform.DOMove(new Vector3(v.x, v.y + 2f, v.z), 0.5f).SetEase(Ease.Linear).OnComplete(resetAnim2));
        s.Append(littleWater.transform.DOMove(new Vector3(v.x, v.y - 0.2f, v.z), 1f).SetEase(Ease.Linear).OnComplete(resetAnim));
    }

    private void Start()
    {
        ////transform.DOScale(new Vector3(1f, 1f, 1f), 0.5f);
        //Vector3 v = targetObj.transform.position;
        ////Debug.Log("v.x " + v.x + "v.y " + v.y + "v.z " + v.z);
        //var s = DOTween.Sequence();
        //s.Append(transform.DOMove(v, 1f).SetEase(Ease.Linear));
        //s.Append(littleWater.transform.DOMove(new Vector3(v.x, v.y-1f, v.z), 0.5f).SetEase(Ease.Linear).OnComplete(resetAnim));
    }
    private void resetAnim2()
    {
        //transform.DOScale(new Vector3(0f, 0f, 1f), 0.1f);
        littleWater.SetActive(true);
        GameObject.Find("Music_Background").GetComponent<MusicPlayerControl>().playColudWaterAudio();
    }
    private void resetAnim()
    {
        //transform.DOScale(new Vector3(0f, 0f, 1f), 0.1f);
        transform.localPosition = new Vector3(0f, 0f, 1f);
        littleWater.transform.localPosition = new Vector3(0f, 0f, 1f);
        transform.gameObject.SetActive(false);
    }
}
