using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace MetaClient
{
    public class UICustomBtn : MonoBehaviour
    {
        public UICustom uICustom;
        [Header("选择界面分支")]
        public ECustomStyple eCustomStyple = ECustomStyple.None;
        [Header("按钮id")]
        public int id;
        [Header("功能分类")]
        public EButtonStyple eButtonStyple = EButtonStyple.Button;

        [Header("对应部位part")]
        public int part=0;

        [Header("对应调色")]
        public ETSStyple eTSStyple = ETSStyple.None;
        //[Header("点击分支")]
        //public ENieLianStyple eNieLianStyple = ENieLianStyple.None;
        [Header("是否重新生成列表")]
        public bool isCreate = false;

        public bool isZDYPart = false;

        public GameObject tiaoSeObj;
        private float value = 0;
        // Start is called before the first frame update
        void Awake()
        {
            //Debug.Log("111");
            Button btn = this.GetComponent<Button>();
            btn.onClick.AddListener(CustomBtnFun);
        }
        void CustomBtnFun() {
            //Debug.Log("111");
            //return;
            switch (this.eButtonStyple)
            {
                case EButtonStyple.Button:
                    if (!isCreate)
                    {

                    }
                    else
                    {
                       
                        CreatImgListFun();
                    }
                    break;
                case EButtonStyple.Scroll:
                    //if (!uICustom.scrollbar.gameObject.activeSelf)
                    //{
                    //    uICustom.scrollbar.gameObject.SetActive(true);
                    //}
                    // uICustom.scrollbar.value = GetValue();
                    uICustom.SetValue(id, eCustomStyple);
                    uICustom.PickOnButton(this.gameObject,id);
                    break;
                case EButtonStyple.TiaoSe:
                    TiaoSeFun();
                    break;
                case EButtonStyple.NorButton:
                    CreatImgListFun();
                    break;
                case EButtonStyple.Back:
                    uICustom.BackBtnFun();
                    break;
            }



        }
        void TiaoSeFun() {
            switch (this.eTSStyple)
            {
                case ETSStyple.None:
                    uICustom.BackBtnFun();
                    break;
                case ETSStyple.ViewOpen:
                   uICustom.TiaoSeViewOpenFun();
                    break;
                case ETSStyple.Close:
                   uICustom.TiaoSeBanOpenStyple(false);
                    break;
                case ETSStyple.Sure:
                    //uICustom.
                    break;
                case ETSStyple.Open:
                   // uICustom.TiaoSeBanOpenStyple(true);
                    break;
            }
        }









        //float GetVale()
        //{
        //    return 1;
        //}
        void CreatImgListFun() {
            if (uICustom.isTween)
            {
                return;
            }
            else
            {
                uICustom.HistoryAdd("ziDingyi" + "," + id + "");
                 //object[] _objects = new object[]{ eCustomStyple, id };
                // uICustom.ClickBotton(_objects);
                uICustom.ClickBotton(eCustomStyple, id,isZDYPart);
                int _numIsZDYPart = isZDYPart ? 1 : 0;
                //uICustom.HistoryAdd(eCustomStyple + "," + isZDYPart + "");
            }
        }
        // Update is called once per frame
        void Update()
        {

        }
    }
}
