123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- using System;
- using System.Collections.Generic;
- using Excel2Json;
- using Fort23.UTool;
- using UnityEngine.Device;
- namespace Fort23.Mono
- {
- public abstract class IGuideLogic
- {
- // /// <summary>
- // /// 是否是软性引导(还需要等待一些特殊的条件才触发的引导)
- // /// </summary>
- // public virtual bool issoftGuide => false;
- /// <summary>
- /// 引导ID
- /// </summary>
- public int guideID;
- public int guideIdx = 0;
- protected List<Action<UnityEngine.Object>> actionList = new List<Action<UnityEngine.Object>>();
- protected int step;
- public UnlockConfig uLockConfig;
- public object ActionObject;
- public PlayerGuideManager pgm;
- // public IGuideLogic(PlayerGuideManager guideManager)
- // {
- // this.pgm = guideManager;
- // }
- /// <summary>
- /// 新手,引导吧...
- /// </summary>
- public virtual async void Guide()
- {
- }
- public void Redo(int idx)
- {
- actionList[idx](null);
- }
- public void ClearList()
- {
- actionList.Clear();
- }
- /// <summary>
- /// 是否全面屏
- /// </summary>
- /// <returns></returns>
- public bool IsFullScreen()
- {
- float bl = Screen.width * 1.0f / Screen.height;
- if (bl <= 0.5f)
- {
- return true;
- }
- return false;
- }
- /// <summary>
- /// 之前引导是否被中断?
- /// </summary>
- /// <param name="length">引导长度</param>
- /// <param name="key">当前步骤</param>
- /// <returns></returns>
- protected bool IsPhaseBreak(int length, int key)
- {
- step = GetPhaseStep(key);
- //new do
- if (step == -1)
- {
- return false;
- }
- else if (step != length - 1)
- {
- LogTool.Log("上次引导中断了: " + key + "-" + step);
- return true;
- }
- else
- {
- return false;
- }
- }
- protected bool IsPhaseDone(int length, int key)
- {
- step = GetPhaseStep(key);
- if (step != -1)
- {
- FinishTriggerGuide(key);
- return true;
- }
- return false;
- }
- protected void FinishTriggerGuide(int key)
- {
- PlayerGuideManager.Instance.ResetPlayerGuide();
- PlayerGuideManager.Instance.FinishATriggerGuide();
- LogTool.Log("已完成引导:" + key);
- }
- public int GetPhaseStep(int key)
- {
- if (AccountFileInfo.Instance.playerData.phaseKey.Contains(key))
- {
- int idx = AccountFileInfo.Instance.playerData.phaseKey.IndexOf(key);
- return AccountFileInfo.Instance.playerData.phaseValue[idx];
- }
- else
- {
- return -1;
- }
- }
- protected void SaveStep(int s)
- {
- //影子引导不记录.
- if (PlayerGuideManager.Instance.curPhase == 66)
- {
- return;
- }
- PlayerGuideManager.Instance.curStep = s;
- var phase = PlayerGuideManager.Instance.curPhase;
- AccountFileInfo.Instance.playerData.curPhase = phase;
- AccountFileInfo.Instance.playerData.curStep = s;
- if (!AccountFileInfo.Instance.playerData.phaseKey.Contains(phase))
- {
- AccountFileInfo.Instance.playerData.phaseKey.Add(phase);
- AccountFileInfo.Instance.playerData.phaseValue.Add(s);
- }
- else
- {
- var idx = AccountFileInfo.Instance.playerData.phaseKey.IndexOf(phase);
- if (AccountFileInfo.Instance.playerData.phaseValue[idx] < s)
- {
- AccountFileInfo.Instance.playerData.phaseValue[idx] = s;
- }
- }
- LogTool.Log("guide message:" + "Phase=" + phase + " Step=" + s);
- AccountFileInfo.Instance.SavePlayerData();
- }
- public void SavePhase(int phase, int step = -1)
- {
- AccountFileInfo.Instance.playerData.curPhase = phase;
- AccountFileInfo.Instance.playerData.curStep = step;
- if (!AccountFileInfo.Instance.playerData.phaseKey.Contains(phase))
- {
- AccountFileInfo.Instance.playerData.phaseKey.Add(phase);
- AccountFileInfo.Instance.playerData.phaseValue.Add(step);
- }
- else
- {
- // var idx = AccountFileInfo.Instance.playerSettingInfo.phaseKey.IndexOf(phase);
- // AccountFileInfo.Instance.playerSettingInfo.phaseValue[idx] = step;
- LogTool.Warning("已保存过该步骤:" + phase);
- }
- AccountFileInfo.Instance.SavePlayerData();
- }
- public void SaveForceDone()
- {
- AccountFileInfo.Instance.playerData.isForceDone = true;
- AccountFileInfo.Instance.SavePlayerData();
- }
- public void SaveTriggerDone()
- {
- AccountFileInfo.Instance.playerData.isTriggerDone = true;
- AccountFileInfo.Instance.SavePlayerData();
- }
- /// <summary>
- /// 激活
- /// </summary>
- public virtual void Active()
- {
- isSkipGuide = false;
- }
- /// <summary>
- /// 是否跳过本引导(一般是引导过期了)
- /// </summary>
- public bool isSkipGuide = false;
- /// <summary>
- /// 开始
- /// </summary>
- public virtual void Begin()
- {
- // if (uLockConfig.ulockCondition == 1)
- // {
- // if (PlayerManager.Instance.curGuideGroupId != uLockConfig.ulockValue)
- // {
- // isSkipGuide = true;
- // }
- // }
- // else if (uLockConfig.ulockCondition == 2)
- // {
- // if (PlayerManager.Instance.Level > uLockConfig.ulockValue)
- // {
- // isSkipGuide = true;
- // }
- // }
- //
- // if (!isSkipGuide)
- // {
- // if (IsPhaseDone(actionList.Count, guideID))
- // {
- // isSkipGuide = true;
- // }
- // }
- }
- /// <summary>
- /// 更新循环
- /// </summary>
- public virtual void LogicUpdate()
- {
- }
- /// <summary>
- /// 结束
- /// </summary>
- public virtual void End()
- {
-
- }
- /// <summary>
- /// 释放逻辑,关闭
- /// </summary>
- public virtual void LogicRelase()
- {
- PlayerGuideManager.Instance.guideLogic = null;
- }
-
- public virtual void SkipGuide()
- {
- PlayerGuideManager.Instance.CloseForceGuide();
- }
- }
- }
|