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

public class FloatWaterAnim : MonoBehaviour
{
    public GameObject waterBottleObj;//浇水动画水瓶
    public GameObject waterDrop;//水滴
    //public GameObject floatBottle;//浮动的加速剂图标
    public GameObject time;//减少时间动画
    private Fruit_Time fruitTime;
    private void Awake()
    {
        fruitTime = time.GetComponent<Fruit_Time>();
    }
    void Start()
    {

    }
    /// <summary>
    /// 水滴 x:-40  y:-30 
    /// </summary>
    //激活时执行动画
    private void OnEnable()
    {
        //waterDrop.SetActive(false);//水滴隐藏
        //floatBottle.SetActive(false);//浮动水瓶隐藏
        GameObject.Find("Music_Background").GetComponent<MusicPlayerControl>().playColudWaterAudio();
        var s = DOTween.Sequence();
        s.Append(waterBottleObj.transform.DOLocalRotate(new Vector3(0, 0, 90), 0.5f, RotateMode.Fast).OnComplete(dissmissAnimation));
        s.Append(waterDrop.transform.DOLocalMoveY(-70f, 0.5f).OnComplete(dissmissAnimation2));
    }

    private void dissmissAnimation()
    {
    }

    private void dissmissAnimation2()
    {
        waterBottleObj.transform.rotation = Quaternion.identity;
        waterDrop.transform.localPosition = new Vector3(-40, -30, 0);
        if (fruitTime != null)
        {
            fruitTime.showFlyTime();
        }
        transform.gameObject.SetActive(false);
    }

   
}
