using DG.Tweening;
using System;
using FairyGUI;
using Spine.Unity;
using UnityEngine;

namespace RedHotRoast
{

    public class GuideViewUI : BaseUI
    {
        private GuideViewUICtrl ctrl;
        private GuideViewModel model;
        private FGUI.ZM_Novice_21.com_guide ui;

        protected GProgressBar pb_loading;
        private Tweener tweener;


        protected int currValue;

        public GuideViewUI(GuideViewUICtrl ctrl) : base(ctrl)
        {
            uiName = UIConst.GuideViewUI;
            this.ctrl = ctrl;
        }

        protected override void SetUIInfo(UIInfo uiInfo)
        {
            uiInfo.packageName = "ZM_Novice_21";
            uiInfo.assetName = "com_guide";
            uiInfo.layerType = UILayerType.Loading;
            uiInfo.isNeedOpenAnim = false;
            uiInfo.isNeedCloseAnim = false;
            uiInfo.isNeedUIMask = false;
        }

        #region 生命周期

        protected override void OnInit()
        {
        }

        protected override void OnClose()
        {
        }

        protected override void OnBind()
        {
            ui = baseUI as FGUI.ZM_Novice_21.com_guide;
        }
        private Action closeCallback;

        protected override void OnOpenBefore(object args)
        {
             TimerHelper.mEasy.AddTimer(0.7f, () =>
            {
                ui.btn_new_start.visible = true;
                // var ska = FXManager.Instance.SetFx<SkeletonAnimation>(ui.btn_new_start.GetChild("btn_parent") as GGraph, Fx_Type.fx_btn_start, ref closeCallback);
                // ska.state.SetAnimation(0, "play", true);
                var finger = FXManager.Instance.SetFx<SkeletonAnimation>(ui.finger_parent, Fx_Type.fx_hand_pre, ref closeCallback);
                finger.state.SetAnimation(0, "idle", true);
            });
           

            ui.btn_new_start.SetClick(()=>{
                DataMgr.NoviceGuide.Value = true;
                GameHelper.gameType = 0;
                GameDispatcher.Instance.Dispatch(GameMsg.OpenGame);
                CtrlCloseUI();
            });
        }

        protected override void OnOpen(object args)
        {
        }

        #endregion


    }
}