//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------

using UnityEngine;
using UnityEngine.UI;
using UnityGameFramework.Runtime;

namespace MetaClient
{
    public class FinchFaceForm : UGuiForm
    {
        [Header("选择功能分类界面")]
        public GameObject toolView;
        [Header("捏脸界面")]
        public GameObject nieLianView;
        [Header("身体修改界面")]
        public GameObject bodyChangeView;
        [Header("服装修改界面")]
        public GameObject clothChangeView;
        [SerializeField]
        private EFinchFaceCengJi eFinchFaceCengJi = EFinchFaceCengJi.None;//默认为未开始选择层级
        [SerializeField]
        private EFinchFaceStyple eFinchFaceStyple = EFinchFaceStyple.None;//默认为未选择界面分支 

         




#if UNITY_2017_3_OR_NEWER
        protected override void OnOpen(object userData)
#else
        protected internal override void OnOpen(object userData)
#endif
        {
            base.OnOpen(userData);
        }

        /// <summary>
        /// 按钮触发事件
        /// </summary>
        public void ChooseJieMianFun(EFinchFaceStyple _styple,EFinchFaceCengJi _cengJi,bool _changeCengJi, string _objName)
        {
            //eFinchFaceCengJi = _cengJi;
            //eFinchFaceStyple = _styple;
            ChangeStyple(_styple, _cengJi, _changeCengJi, _objName);
        }
        /// <summary>
        /// 按钮触发事件控制事件
        /// </summary>
        private void ChangeStyple(EFinchFaceStyple _styple, EFinchFaceCengJi _cengJi, bool _changeCengJi, string _objName)
        {
            //首先判定是否需要改变选择的界面类型
            if (_styple != eFinchFaceStyple)
            {
                eFinchFaceStyple = _styple;

                toolView.SetActive(false);
                if (nieLianView != null)
                {
                    nieLianView.SetActive(false);
                }
                if (bodyChangeView != null)
                {
                    bodyChangeView.SetActive(false);
                }
                if (clothChangeView != null)
                {
                    clothChangeView.SetActive(false);
                }
            
            }
            switch (eFinchFaceStyple)
            {
                //回到首次选择的界面
                case EFinchFaceStyple.None:
                    toolView.SetActive(true);
                    break;
                //捏脸分支
                case EFinchFaceStyple.FaceChange:
                    nieLianView.SetActive(true);
                    ChangeCengJi(_cengJi, _changeCengJi, _objName);
                    break;
                //身体分支
                case EFinchFaceStyple.BodyChange:
                    bodyChangeView.SetActive(true);
                    ChangeCengJi(_cengJi,_changeCengJi, _objName);
                    break;
                //衣服分支
                case EFinchFaceStyple.ClothChange:
                    clothChangeView.SetActive(true);
                    ChangeCengJi(_cengJi,_changeCengJi,_objName);
                    break;
            }
           
        }
        /// <summary>
        /// 按钮控制界面层级修改
        /// </summary>
        private void ChangeCengJi(EFinchFaceCengJi _cengJi,bool _changeCengJi,string _objName) 
        {
            //if (_cengJi != eFinchFaceCengJi)
            //{

            //}
            if (_changeCengJi)
            {
                eFinchFaceCengJi = _cengJi;
            }
        }
        private void ChangeNowViewFun(string _objName)
        {

        }







        /// <summary>
        /// 按钮控制捏脸界面修改
        /// </summary>
        private void ChangeNieLianViewCengJi()
        {
            
        }
        




#if UNITY_2017_3_OR_NEWER
        protected override void OnClose(bool isShutdown, object userData)
#else
        protected internal override void OnClose(bool isShutdown, object userData)
#endif
        {
            base.OnClose(isShutdown, userData);
        }

        public void ClickFaceChangeBtn()
        {
            GameEntry.Event.Fire(this, CustomRoleFaceEventArgs.Create(EditableFacePart.eye, new Vector3(1,0,0)));
        }
    }
    /// <summary>
    /// 捏脸分类
    /// </summary>
    public enum EFinchFaceStyple {
        //初始
        None,
        //捏脸
        FaceChange,
        //身体重铸
        BodyChange,
        //衣服替换
        ClothChange,
    }
    /// <summary>
    /// 当前点击的图层应用顺序等级 即一级只能单向指向固定二级 二级只能回退到一级选择界面 
    /// </summary>
    public enum EFinchFaceCengJi {
        None,
        One,
        Two,
        Three
    }
}
