using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FloatGetRewardAnim : MonoBehaviour
{
    public Text getFruitMoneyTv;
    public int position = -1;
    public LandDataControl mLandData;
    private void Start()
    {
        if (position != -1)
        {
            //收获数量
            //getFruitMoneyTv.text = LandListDataControl.GetIns().getLandListDataPos(position).profit.ToString();
            getFruitMoneyTv.text = mLandData.getMyLandEntity.profit.ToString();
        }
    }

    private void OnEnable()
    {
        GameObject.Find("Music_Background").GetComponent<MusicPlayerControl>().playgetRewardAudio();
        if (position != -1)
        {
            mLandData.updateMyLand();
            CoinNumControl.GetIns().rewardRedPackReduce();
        }
        transform.DOLocalMoveY(90f, 1f).OnComplete(dissmissAnimSuccess);
    }

    private void dissmissAnimSuccess()
    {
        transform.localPosition = new Vector3(0, 0, 0);
        //if (position != -1)
        //{
        //    mLandData.updateMyLand();
        //    CoinNumControl.GetIns().rewardRedPackReduce();
        //}
        transform.gameObject.SetActive(false);
        //GameObject.Find("Form_land")?.GetComponent<LandListEvent>().updateLandList(3, position);
    }
}
