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

public class LandPlantControl : MonoBehaviour
{
    public int position = -1;

    private LandListEvent landEvent;
    private FarmControl landFarm;
    public LandDataControl mLandData;
    private void Awake()
    {
        landEvent = GameObject.Find("Form_land")?.GetComponent<LandListEvent>();
        landFarm = GameObject.Find("Form_land")?.GetComponent<FarmControl>();
    }

    //private int seedNum = 0;
    //private void Awake()
    //{
    //    updateSeedNum();
    //}

    //public int getSeedNum
    //{
    //    get { return seedNum; }
    //}

    //public void updateSeedNum()
    //{
    //    if (position != -1)
    //    {
    //        seedNum = LandListDataControl.GetIns().getSeedNum(position);
    //    }
    //}


    //种植水果
    public void onClickPlantFruit()
    {
        if (position != -1) {
            landFarm.setOnclickLandId = position;
            GameObject.Find("Music_Background").GetComponent<MusicPlayerControl>().playBtnAudio();
            GameObject.Find("GameManager").GetComponent<UnityToAndroid>().onEventUtil("click_plant_farm_id_" + (position + 1), "种植农作物id_" + (position + 1));
            if (mLandData.setPlantFruitData(position))
            {
                int time = mLandData.setCreatWormTime();

                mLandData.updateMyLand();

                GameObject.Find("guideParent").GetComponent<UserGuide>().setStep1();

                if (position == 2)
                {
                    GameObject.Find("guideParent").GetComponent<UserGuide>().setStep6(false);
                }

                landEvent.updateLandList(4, position,time);
            }
            else
            {
                Debug.Log("种植水果失败 种子不足");
                GameObject.Find("dialog").GetComponent<DialogControl>().showSeedNotEnough((position + 1), mLandData.getMyLandEntity.seedPrice, CoinNumControl.GetIns().getSubSeedVideoNum);
            }

        }
    }
}
