
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using Spine.Unity;
using System;

namespace RedHotRoast
{
    public class ChatUnlockUI : BaseUI
    {
        private ChatUnlockUICtrl ctrl;
        private ChatUnlockModel model;
        private FGUI.LG_Unlock.com_chatUnlock ui;

        public ChatUnlockUI(ChatUnlockUICtrl ctrl) : base(ctrl)
        {
            uiName = UIConst.ChatUnlockUI;
            this.ctrl = ctrl;
        }

        protected override void SetUIInfo(UIInfo uiInfo)
        {
            uiInfo.packageName = "LG_Unlock";
            uiInfo.assetName = "com_chatUnlock";
            uiInfo.layerType = UILayerType.Popup;
            uiInfo.isNeedOpenAnim = false;
            uiInfo.isNeedCloseAnim = false;
            uiInfo.isNeedUIMask = true;
        }

        #region 生命周期
        protected override void OnInit()
        {
            //model = ModuleManager.Instance.GetModel(ModelConst.ChatUnlockModel) as ChatUnlockModel;
        }

        protected override void OnClose()
        {
            closeCallback?.Invoke();
        }

        protected override void OnBind()
        {
            ui = baseUI as FGUI.LG_Unlock.com_chatUnlock;
        }

        protected override void OnOpenBefore(object args)
        {
            InitView();
        }

        protected override void OnOpen(object args)
        {
        }

        protected override void OnHide()
        {
        }

        protected override void OnDisplay(object args)
        {
        }
        #endregion

        #region 消息
        protected override void AddListener()
        {

        }
        protected override void RemoveListener()
        {

        }
        #endregion

        private Action closeCallback;
        //初始化页面逻辑
        private void InitView()
        {
            SkeletonAnimation ske_pot = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent, Fx_Type.fx_chatunlock, ref closeCallback);
            ske_pot.state.SetAnimation(0, "animation", true);

            SkeletonAnimation ske_pot1 = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent1, Fx_Type.fx_chatunlock1, ref closeCallback);
            ske_pot1.state.SetAnimation(0, "animation", true);

            SkeletonAnimation ske_pot2 = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent2, Fx_Type.fx_chatunlock2, ref closeCallback);
            ske_pot2.state.SetAnimation(0, "animation", true);
            ui.btn_close.SetClick(CtrlCloseUI);
        }
    }
}