using Fort23.Core;
using Fort23.UTool;
using GameLogic.Combat;
using GameLogic.Combat.CombatTool;
using UnityEngine;
using UnityEngine.UI;
namespace Fort23.Mono.Phases
{
    public class Phase6 : IGuideLogic
    {
        public PlayerGuideManager pgm;
        private bool once = false;
        public Phase6(PlayerGuideManager guideManager)
        {
            this.pgm = guideManager;
            once = true;
        }
        public override void Active()
        {
            base.Active();
            actionList.Add(OnStep601);
            actionList.Add(OnStep602);
            actionList.Add(OnStep603);
            actionList.Add(OnStepEnd);
        }
        public override void Begin()
        {
            guideID = 6;
            guideIdx = -1;
            pgm.isForceDone = false;
            pgm.isTriggerDone = false;
        }
        public override void End()
        {
        }
        public override async CTask Guide()
        {
            if (actionList.Count > guideIdx)
            {
                pgm.ResetPlayerGuide();
                guideIdx++;
                SaveStep(guideIdx);
                await actionList[guideIdx](null);
            }
            else
            {
                LogTool.Error("没有引导了,强制结束。出错步骤,:" + pgm.curPhase + guideIdx);
                pgm.isForceDone = true;
            }
        }
        public override void LogicRelase()
        {
            actionList.Clear();
        }
        public override void LogicUpdate()
        {
        }
        /// 
        /// 点击洞府
        /// 
        /// 
        public async CTask OnStep601(UnityEngine.Object obj)
        {
            GameObject gameObject = UIManager.Instance.GetComponent().Btn_DongFu.gameObject;
            Vector3 localPos = pgm.WorldPosToLocalPos(gameObject.transform.position);
            Vector2 size = gameObject.GetComponent().sizeDelta;
            pgm.SetfxTransVisiable(true);
            pgm.SetMaskTarget(gameObject);
            pgm.SetShowFramePosAndSize(localPos, size, 0, gameObject);
            await pgm.ConfigLogic(601, delegate() { });
            pgm.SetFingerPos(localPos);
            pgm.SetFingerVisiable(true);
        }
        /// 
        /// 点击修炼
        /// 
        /// 
        public async CTask OnStep602(UnityEngine.Object obj)
        {
            GameObject gameObject = UIManager.Instance.GetComponent().Btn_XiuLian.gameObject;
            Vector3 localPos = pgm.WorldPosToLocalPos(gameObject.transform.position);
            Vector2 size = gameObject.GetComponent().sizeDelta;
            pgm.SetfxTransVisiable(true);
            pgm.SetMaskTarget(gameObject);
            pgm.SetShowFramePosAndSize(localPos, size, 0, gameObject);
            await pgm.ConfigLogic(602, delegate() { });
            pgm.SetFingerPos(localPos);
            pgm.SetFingerVisiable(true);
        }
        /// 
        /// 升级
        /// 
        /// 
        public async CTask OnStep603(UnityEngine.Object obj)
        {
            GameObject gameObject = UIManager.Instance.GetComponent().Btn_TuPo.gameObject;
            Vector3 localPos = pgm.WorldPosToLocalPos(gameObject.transform.position);
            Vector2 size = gameObject.GetComponent().sizeDelta;
            pgm.SetfxTransVisiable(true);
            pgm.SetMaskTarget(gameObject);
            pgm.SetShowFramePosAndSize(localPos, size, 0, gameObject);
            await pgm.ConfigLogic(603, delegate() { });
            pgm.SetFingerPos(localPos);
            pgm.SetFingerVisiable(true);
        }
        public async CTask OnStepEnd(UnityEngine.Object obj)
        {
            pgm.StepInit();
            pgm.SetBlackBaseVisiable(false);
            ForceGuideOver();
        }
        /// 
        /// 引导完成
        /// 
        private void ForceGuideOver()
        {
            pgm.CloseForceGuide();
            pgm.RestGuide();
        }
    }
}