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

public class UserGuide : MonoBehaviour
{

    private string guide5Key = "GUIDE_FIVE";
    private string guide6Key = "GUIDE_SIX";
    private string guide7Key = "GUIDE_SEVEN";

    public GameObject guideBg;
    public GameObject guideHand;
    public GameObject guideUpHand;
    public GameObject step1;
    public GameObject step2;
    public GameObject step3;
    public GameObject step4;
    //5 6 7
    public GameObject step5;
    public GameObject step6;
    public GameObject step7;

    private bool isShow = false;
    private void Start()
    {
        setStep0();
    }

    public void setStep0()
    {
        //显示
        if (!LandListDataControl.GetIns().getIsShowGuide)
        {
            isShow = true;
            setStep5(false);
            return;
        }
        if (isShow)
        {
            return;
        }
        guideBg.SetActive(true);
        guideHand.SetActive(true);
        step1.SetActive(true);
        guideUpHand.SetActive(false);
        step2.SetActive(false);
        step3.SetActive(false);
        step4.SetActive(false);
    }

    public void setStep1()
    {   //种植
        if (!LandListDataControl.GetIns().getIsShowGuide)
        {
            return;
        }
        if (isShow)
        {
            return;
        }
        step1.SetActive(false);
        step2.SetActive(true);
        step3.SetActive(false);
        step4.SetActive(false);
    }
    public void setStep2()
    {
        //浇水
        if (!LandListDataControl.GetIns().getIsShowGuide)
        {
            return;
        }
        if (isShow)
        {
            return;
        }
        step1.SetActive(false);
        step2.SetActive(false);
        step3.SetActive(true);
        step4.SetActive(false);
    }

    public void setStep3()
    {   //收获
        if (!LandListDataControl.GetIns().getIsShowGuide)
        {
            return;
        }
        if (isShow)
        {
            return;
        }
        isShow = true;
        guideBg.SetActive(false);
        step1.SetActive(false);
        step2.SetActive(false);
        step3.SetActive(false);
        guideHand.SetActive(false);
        guideUpHand.SetActive(true);
        step4.SetActive(true);
        GameObject.Find("GameManager").GetComponent<UnityToAndroid>().guideOverPlayPlyBox();
    }

    public void setStep4()
    {   //兑换现金
        //if (!LandListDataControl.GetIns().getIsShowGuide)
        //{
        //    return;
        //}
        step1.SetActive(false);
        step2.SetActive(false);
        step3.SetActive(false);
        guideUpHand.SetActive(false);
        step4.SetActive(false);
        LandListDataControl.GetIns().getIsShowGuide=false;//引导结束
        setStep5(false);
    }
    //第五步引导
    public void setStep5(bool isSetKey)
    {
        if (isSetKey)
        {
            PlayerPrefs.SetInt(guide5Key, 1);
            step5.SetActive(false);
        }
        else
        {
            if (PlayerPrefs.GetInt(guide5Key, -1) == -1)
            {//第五步引导还没有引导过
                step5.SetActive(true);
            }
        }
    }

    //第六步引导
    public void setStep6(bool isSetKey)
    {
        if (isSetKey)
        {
            PlayerPrefs.SetInt(guide6Key, 1);
            step6.SetActive(false);
            //第七步引导已解锁 第六步引导结束 引导第七步
            if(PlayerPrefs.GetInt(guide7Key, -1) == 0)
            {
                setStep7(false);
            }
        }
        else
        {
            if (step4.activeSelf == false)
            {
                if (PlayerPrefs.GetInt(guide6Key, -1) == -1)
                {//第六步引导 还没有引导过
                    step6.SetActive(true);
                }
            }
           
        }
        
    }

    //第七步引导
    public void setStep7(bool isSetKey)
    {
        if (isSetKey)
        {
            PlayerPrefs.SetInt(guide7Key, 1);
            step7.SetActive(false);
        }
        else
        {//第七步引导 还没有引导过
            if (PlayerPrefs.GetInt(guide7Key, -1) == -1)
            {
                if(PlayerPrefs.GetInt(guide6Key, -1) != -1)
                {
                    step7.SetActive(true);
                }
                else
                {
                    PlayerPrefs.SetInt(guide7Key, 0);
                }
            }
            else
            {
                if (PlayerPrefs.GetInt(guide6Key, -1) != -1)
                {
                    if (PlayerPrefs.GetInt(guide7Key, -1) == 0)
                    {
                        step7.SetActive(true);
                    }
                }
            }
        }
        
    }

}
