2024-05-22 16:31:29 +08:00
|
|
|
|
using cfg.GuideCfg;
|
2024-05-22 15:41:05 +08:00
|
|
|
|
using Framework;
|
2024-10-11 15:46:57 +08:00
|
|
|
|
using Framework.Condition;
|
2024-07-05 17:25:57 +08:00
|
|
|
|
using Gameplay.Area;
|
|
|
|
|
|
using Gameplay.Level;
|
2024-06-05 14:04:26 +08:00
|
|
|
|
using Gameplay.Net;
|
2024-07-05 17:25:57 +08:00
|
|
|
|
using Gameplay.Skill;
|
2024-06-05 14:04:26 +08:00
|
|
|
|
using NLDPB;
|
2024-05-22 15:41:05 +08:00
|
|
|
|
using PhxhSDK;
|
2024-06-28 17:34:50 +08:00
|
|
|
|
using System;
|
2024-05-22 15:41:05 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
namespace Gameplay.Guide
|
2024-05-22 15:41:05 +08:00
|
|
|
|
{
|
2024-05-22 16:31:29 +08:00
|
|
|
|
/// <summary>
|
2024-05-29 16:36:30 +08:00
|
|
|
|
/// 新手引导管理器
|
2024-05-22 16:31:29 +08:00
|
|
|
|
/// </summary>
|
2024-07-05 17:25:57 +08:00
|
|
|
|
public class GuideManager : Singlenton<GuideManager>, IInitable, IUpdatable
|
2024-05-24 19:11:19 +08:00
|
|
|
|
{
|
2024-09-30 17:38:53 +08:00
|
|
|
|
#region 兜底强制跳过引导机制
|
|
|
|
|
|
/// <summary>
|
2024-10-12 13:34:27 +08:00
|
|
|
|
/// 2秒内点击n次,弹出强制跳过引导
|
2024-09-30 17:38:53 +08:00
|
|
|
|
/// </summary>
|
2024-10-12 12:54:52 +08:00
|
|
|
|
private readonly Queue<DateTime> queueTime = new();
|
2024-09-30 17:38:53 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 强制跳过引导检测时间(秒)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private const double SKIP_GUIDE_CHECK_TIME = 2d;
|
|
|
|
|
|
#endregion
|
2024-10-11 15:46:57 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 新手引导配置字典,key:引导组,Value:引导步骤配置链表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Dictionary<int, LinkedList<DataGuideCfg>> dicGuideCfg;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当前的引导组
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private GuideGroup curGroup;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 触发条件id
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private int reactionID = ConditionReactor.INVALID_ALLOC_ID;
|
2024-10-18 18:13:23 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 特殊pv引导id
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private int pvGuideID = 402;
|
2024-05-29 16:36:30 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否引导中
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsGuiding
|
2024-05-24 19:11:19 +08:00
|
|
|
|
{
|
2024-05-29 16:36:30 +08:00
|
|
|
|
get { return curGroup != null && curGroup.IsGuiding; }
|
2024-05-24 19:11:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-03 14:07:54 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 控制地板点击
|
|
|
|
|
|
/// </summary>
|
2024-07-04 16:06:01 +08:00
|
|
|
|
public bool IsControlFloor = false;
|
2024-07-01 13:08:37 +08:00
|
|
|
|
/// <summary>
|
2024-07-03 19:15:36 +08:00
|
|
|
|
/// 是否改名
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsChangeName = true;
|
|
|
|
|
|
/// <summary>
|
2024-07-01 13:08:37 +08:00
|
|
|
|
/// 指定地板索引
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int FloorIndex = -1;
|
2024-07-04 13:48:56 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否编队引导
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsEditTeamGuide = false;
|
2024-10-17 18:27:11 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 使用技能成功
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsUseSkillSuccess = true;
|
2024-10-18 18:13:23 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否播放过PV视频
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsPlayPVVideo;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否响应任意点击
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsEnableAnyClick = true;
|
2024-07-01 13:08:37 +08:00
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
public void Init()
|
2024-05-24 19:11:19 +08:00
|
|
|
|
{
|
2024-09-30 17:38:53 +08:00
|
|
|
|
InputManager.Instance.OnAnyClick += OnAnyClick;
|
2024-05-29 16:36:30 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.AllConfigLoad, InitData);
|
|
|
|
|
|
}
|
2024-05-29 13:04:51 +08:00
|
|
|
|
|
2024-07-05 17:25:57 +08:00
|
|
|
|
public void Update(float deltaTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!Instance.IsGuiding)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (!LevelManager.Instance.IsInLevel)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (null == LevelManager.Instance.CurrentLevel)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (!LevelManager.Instance.CurrentLevel.isInBattle)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (!LevelManager.Instance.CurrentLevel.IsPause())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
AreaManager.instance.LogicUpdate(deltaTime);
|
|
|
|
|
|
SkillManager.instance.playerSkillManager.LogicUpdate(deltaTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
public void Release()
|
|
|
|
|
|
{
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.AllConfigLoad, InitData);
|
2024-09-30 17:38:53 +08:00
|
|
|
|
if (null != InputManager.Instance)
|
|
|
|
|
|
InputManager.Instance.OnAnyClick -= OnAnyClick;
|
2024-05-24 19:11:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 开始引导
|
|
|
|
|
|
/// </summary>
|
2024-10-11 18:21:20 +08:00
|
|
|
|
public void BeginGuide(int completeStepId = 0)
|
2024-05-24 19:11:19 +08:00
|
|
|
|
{
|
2024-06-05 13:13:11 +08:00
|
|
|
|
#if GUIDE
|
2024-10-17 12:33:34 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsGuiding)
|
|
|
|
|
|
return;
|
2024-05-28 18:47:23 +08:00
|
|
|
|
|
2024-10-17 12:33:34 +08:00
|
|
|
|
if (ConditionReactor.INVALID_ALLOC_ID != reactionID)
|
|
|
|
|
|
ConditionReactor.Instance.RemoveReaction(reactionID);
|
2024-10-11 19:22:18 +08:00
|
|
|
|
|
2024-10-17 12:33:34 +08:00
|
|
|
|
if (completeStepId == 0)
|
|
|
|
|
|
completeStepId = (int)Actor.Instance.Logic.GetCount((uint)LogicID.NewGuideProgress);
|
2024-10-11 18:21:20 +08:00
|
|
|
|
|
2024-10-17 12:33:34 +08:00
|
|
|
|
int groupId = GetGuideGroupId(completeStepId);
|
|
|
|
|
|
if (!dicGuideCfg.TryGetValue(groupId, out LinkedList<DataGuideCfg> linkCfg))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
curGroup = new GuideGroup(groupId, linkCfg);
|
2024-10-10 13:59:48 +08:00
|
|
|
|
|
2024-10-17 12:33:34 +08:00
|
|
|
|
if (curGroup.CurStep.Cfg.BeginCondition.Length <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
OnBeginGuide(true, null, ConditionReactor.INVALID_ALLOC_ID);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-08-01 14:42:22 +08:00
|
|
|
|
|
2024-10-17 12:33:34 +08:00
|
|
|
|
reactionID = ConditionReactor.Instance.AddReaction(curGroup.CurStep.Cfg.BeginCondition, OnBeginGuide);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
2024-10-11 17:17:54 +08:00
|
|
|
|
{
|
2024-10-17 12:33:34 +08:00
|
|
|
|
DebugUtil.LogError($"引导启动异常:{e}");
|
2024-10-11 17:17:54 +08:00
|
|
|
|
}
|
2024-06-05 13:13:11 +08:00
|
|
|
|
#endif
|
2024-05-24 19:11:19 +08:00
|
|
|
|
}
|
2024-05-24 15:07:50 +08:00
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 完成指定引导步骤
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="step"></param>
|
|
|
|
|
|
public void CompleteStep(GuideStepBase step)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (null == curGroup)
|
|
|
|
|
|
return;
|
2024-05-29 13:04:51 +08:00
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
if (step != curGroup.CurStep)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("要完成的引导步骤不是当前步骤");
|
|
|
|
|
|
EndGuide(true);
|
2024-05-29 13:04:51 +08:00
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-05-29 13:04:51 +08:00
|
|
|
|
|
2024-08-01 14:42:22 +08:00
|
|
|
|
NetHelper.SaveGuideProgress((uint)curGroup.CurStep.Cfg.Id); // 完成引导步骤,保存服务器
|
2024-09-29 14:38:21 +08:00
|
|
|
|
DebugUtil.Log($"<color=#00FA9A>完成引导步骤,服务器保存引导id:{curGroup.CurStep.Cfg.Id}</color>");
|
2024-10-12 17:13:17 +08:00
|
|
|
|
queueTime.Clear();
|
2024-08-01 14:42:22 +08:00
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
if (curGroup.IsComplete)
|
|
|
|
|
|
{
|
2024-08-01 14:42:22 +08:00
|
|
|
|
DebugUtil.Log($"<color=#00FA9A>完成引导组,组id:{curGroup.GroupId}</color>");
|
2024-05-29 16:36:30 +08:00
|
|
|
|
|
|
|
|
|
|
int nextGroupId = curGroup.NextGroupId;
|
|
|
|
|
|
if (dicGuideCfg.TryGetValue(nextGroupId, out LinkedList<DataGuideCfg> linkCfg))
|
|
|
|
|
|
{
|
2024-07-05 19:33:21 +08:00
|
|
|
|
curGroup = new(nextGroupId, linkCfg, true);
|
2024-05-29 16:36:30 +08:00
|
|
|
|
curGroup.BeginGuide();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
EndGuide(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2024-07-08 19:20:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (curGroup.CurStep.Cfg.IsComplete)
|
2024-08-01 14:42:22 +08:00
|
|
|
|
DebugUtil.Log($"<color=#00FA9A>提前完成引导组,组id:{curGroup.GroupId}</color>");
|
|
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
curGroup.BeginNextStep();
|
2024-07-08 19:20:33 +08:00
|
|
|
|
}
|
2024-05-29 16:36:30 +08:00
|
|
|
|
}
|
2024-05-22 16:31:29 +08:00
|
|
|
|
|
2024-07-03 13:08:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 回到指定步骤
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="step"></param>
|
|
|
|
|
|
public void ReturnStep(int stepId)
|
|
|
|
|
|
{
|
|
|
|
|
|
curGroup.EndGuide();
|
|
|
|
|
|
curGroup.BeginGuideById(stepId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 结束引导
|
|
|
|
|
|
/// </summary>
|
2024-06-06 14:41:02 +08:00
|
|
|
|
public void EndGuide(bool isReEnterMain)
|
2024-05-22 16:31:29 +08:00
|
|
|
|
{
|
2024-05-29 16:36:30 +08:00
|
|
|
|
if (IsGuiding)
|
|
|
|
|
|
curGroup.EndGuide();
|
2024-05-22 16:31:29 +08:00
|
|
|
|
|
2024-10-08 16:13:27 +08:00
|
|
|
|
RecoverState();
|
2024-05-29 16:36:30 +08:00
|
|
|
|
curGroup = null;
|
|
|
|
|
|
UIManager.Instance.CloseWindow(UINameConst.UI_Guide);
|
|
|
|
|
|
UIManager.Instance.CloseWindow(UINameConst.UI_GuideTip);
|
2024-05-22 15:41:05 +08:00
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
if (isReEnterMain)
|
2024-10-17 15:28:13 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (LevelManager.Instance.IsInLevel)
|
|
|
|
|
|
LevelManager.Instance.TryExitLevel(false, null, true);
|
|
|
|
|
|
else
|
|
|
|
|
|
GameStateManager.Instance.ChangeState(new GameStateMainScene());
|
|
|
|
|
|
}
|
2024-05-22 16:31:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-08 17:31:59 +08:00
|
|
|
|
/// <summary>
|
2024-10-11 15:46:57 +08:00
|
|
|
|
/// 跳过当前引导组
|
2024-10-08 17:31:59 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="isReEnterMain"></param>
|
2024-10-11 15:46:57 +08:00
|
|
|
|
public void SkipCurGuideGroup()
|
2024-10-08 17:31:59 +08:00
|
|
|
|
{
|
2024-10-11 15:46:57 +08:00
|
|
|
|
if (null == curGroup)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (!dicGuideCfg.TryGetValue(curGroup.GroupId, out LinkedList<DataGuideCfg> linkedCfg))
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("要完成的引导组不存在");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NetHelper.SaveGuideProgress((uint)linkedCfg.Last.Value.Id); // 跳过引导步骤,保存服务器
|
|
|
|
|
|
DebugUtil.Log($"<color=#00FA9A>跳过引导组,服务器保存引导id:{linkedCfg.Last.Value.Id}</color>");
|
2024-10-11 17:17:54 +08:00
|
|
|
|
EndGuide(false);
|
2024-10-11 18:21:20 +08:00
|
|
|
|
BeginGuide(linkedCfg.Last.Value.Id);
|
2024-10-08 17:31:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-12 12:46:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 跳过所有引导
|
|
|
|
|
|
/// </summary>
|
2024-10-18 18:13:23 +08:00
|
|
|
|
public async void SkipAllGuide()
|
2024-10-12 12:46:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("跳过所有引导");
|
|
|
|
|
|
GuideConfig guideConfig = TableManager.Instance.Tables.GuideConfig;
|
|
|
|
|
|
DataGuideCfg cfg = guideConfig.DataList[^1];
|
|
|
|
|
|
NetHelper.SaveGuideProgress((uint)cfg.Id);
|
2024-10-18 18:13:23 +08:00
|
|
|
|
if (!IsPlayPVVideo &&
|
|
|
|
|
|
null != curGroup &&
|
|
|
|
|
|
curGroup.CurStep.Cfg.Id <= pvGuideID) // 特殊处理 播放过pv视频则不播放,没播放过则播放
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.Instance.CloseWindow(UINameConst.UI_Guide, UIWindowCloseType.HideAndPush);
|
|
|
|
|
|
UIManager.Instance.CloseWindow(UINameConst.UI_GuideTip, UIWindowCloseType.HideAndPush);
|
|
|
|
|
|
await UI_PVAnimaPlayController.Open("Assets/Video/LevelIntro/LevelIntro_PV.mp4", () => { EndGuide(true); });
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
EndGuide(true);
|
2024-10-12 12:46:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 显示跳过所有引导提示
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void ShowSkipAllGuide()
|
|
|
|
|
|
{
|
2024-10-12 13:34:27 +08:00
|
|
|
|
UITipsManager.ShowConfirmTwo(CommonUtils.GetLocalizeText("Guide_SkipAllTitle"), // 脱离卡死
|
|
|
|
|
|
CommonUtils.GetLocalizeText("Guide_SkipAllContent"), // 是否强制跳过新手引导?(选择【跳过】便不再触发新手引导)
|
|
|
|
|
|
CommonUtils.GetLocalizeText("Skip"), // 跳过
|
|
|
|
|
|
CommonUtils.GetLocalizeText("Not"), // 否
|
|
|
|
|
|
() => { SkipAllGuide(); });
|
2024-10-12 12:46:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-14 12:20:28 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 判断引导步骤是否完成
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public bool CheckComplete(int guideId)
|
|
|
|
|
|
{
|
|
|
|
|
|
int curCompleteStepId = (int)Actor.Instance.Logic.GetCount((uint)LogicID.NewGuideProgress);
|
|
|
|
|
|
|
|
|
|
|
|
return curCompleteStepId >= guideId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void InitData()
|
2024-05-22 16:31:29 +08:00
|
|
|
|
{
|
2024-05-29 16:36:30 +08:00
|
|
|
|
dicGuideCfg = new();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DataGuideCfg cfg in TableManager.Instance.Tables.GuideConfig.DataList)
|
2024-05-22 16:31:29 +08:00
|
|
|
|
{
|
2024-05-29 16:36:30 +08:00
|
|
|
|
if (dicGuideCfg.ContainsKey(cfg.GroupId) && !IsFirstStep(cfg))
|
2024-05-22 16:31:29 +08:00
|
|
|
|
continue;
|
2024-05-29 16:36:30 +08:00
|
|
|
|
|
|
|
|
|
|
DataGuideCfg addCfg = cfg; // 记录要添加进链表的引导步骤配置
|
|
|
|
|
|
int groudId = cfg.GroupId;
|
|
|
|
|
|
LinkedList<DataGuideCfg> linkCfg = new();
|
|
|
|
|
|
dicGuideCfg[groudId] = linkCfg;
|
|
|
|
|
|
|
|
|
|
|
|
while (null != addCfg && addCfg.GroupId == groudId)
|
|
|
|
|
|
{
|
|
|
|
|
|
linkCfg.AddLast(addCfg);
|
2024-07-01 19:12:47 +08:00
|
|
|
|
|
2024-07-02 13:45:19 +08:00
|
|
|
|
if (0 == addCfg.NextId)
|
|
|
|
|
|
addCfg = null;
|
|
|
|
|
|
else if (addCfg.Id >= addCfg.NextId)
|
|
|
|
|
|
throw new Exception($"{addCfg.Id}引导的下一步id配置错误,下一步id小于等于当前id可能导致死循环");
|
|
|
|
|
|
else
|
|
|
|
|
|
addCfg = TableManager.Instance.Tables.GuideConfig.Get(addCfg.NextId);
|
2024-05-22 16:31:29 +08:00
|
|
|
|
}
|
2024-05-29 16:36:30 +08:00
|
|
|
|
}
|
2024-05-22 16:31:29 +08:00
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
#region 检验每个引导组的步骤顺序是否正常
|
|
|
|
|
|
foreach (LinkedList<DataGuideCfg> linkCfg in dicGuideCfg.Values)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataGuideCfg preCfg = null;
|
|
|
|
|
|
foreach (DataGuideCfg cfg in linkCfg)
|
2024-05-22 16:31:29 +08:00
|
|
|
|
{
|
2024-05-29 16:36:30 +08:00
|
|
|
|
if (null == preCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
preCfg = cfg;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (preCfg.NextId != cfg.Id)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"新手引导配置出错,组id:{cfg.GroupId}, 当前步骤id:{preCfg.Id}, 实际下一步步骤id:{preCfg.NextId}, 当前下一步步骤id:{cfg.Id}");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
preCfg = cfg;
|
2024-05-22 16:31:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-05-29 16:36:30 +08:00
|
|
|
|
#endregion
|
2024-05-22 16:31:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-29 16:36:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否是引导组的第一步
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private bool IsFirstStep(DataGuideCfg dataGuideCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
return dataGuideCfg.Id == dataGuideCfg.GroupId;
|
|
|
|
|
|
}
|
2024-08-01 14:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取应该引导的引导组id
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private int GetGuideGroupId(int completeStepId)
|
|
|
|
|
|
{
|
2024-08-02 15:55:10 +08:00
|
|
|
|
GuideConfig guideConfig = TableManager.Instance.Tables.GuideConfig;
|
|
|
|
|
|
if (guideConfig.DataList.Count <= 0)
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (completeStepId >= guideConfig.DataList[^1].Id) // 大于等于最后一步的id
|
2024-08-01 15:39:44 +08:00
|
|
|
|
return 0; // 跳过引导
|
|
|
|
|
|
|
2024-08-01 14:42:22 +08:00
|
|
|
|
DataGuideCfg completeCfg = guideConfig.Get(completeStepId); // 已经完成的引导步骤配置
|
|
|
|
|
|
if (null == completeCfg) // 没有获取到,说明不是存在的配置id
|
|
|
|
|
|
return guideConfig.DataList.Count > 0 ? guideConfig.DataList[0].GroupId : 0;
|
|
|
|
|
|
|
|
|
|
|
|
bool isGroupComplete = false; // 当前步骤所在引导组是否完成
|
|
|
|
|
|
DataGuideCfg nextCfg = guideConfig.Get(completeCfg.NextId);
|
2024-08-01 14:49:39 +08:00
|
|
|
|
if (null == nextCfg)
|
|
|
|
|
|
return 0; // 没有下一步了
|
|
|
|
|
|
else if (nextCfg.GroupId != completeCfg.GroupId) // 该步骤是该组最后一步,表示整组完成
|
2024-08-01 14:42:22 +08:00
|
|
|
|
isGroupComplete = true;
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (DataGuideCfg cfg in TableManager.Instance.Tables.GuideConfig.DataList)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cfg.GroupId != completeCfg.GroupId)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
if (cfg.IsComplete && cfg.Id <= completeCfg.Id)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log($"<color=#00FA9A>引导步骤{completeStepId}所在组{cfg.GroupId}的{cfg.Id}步骤完成,该组完成</color>");
|
|
|
|
|
|
isGroupComplete = true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isGroupComplete) // 该组完成,取下一组
|
|
|
|
|
|
{
|
|
|
|
|
|
DataGuideCfg dataGuideCfg = guideConfig.Get(completeCfg.NextId);
|
|
|
|
|
|
while (null != dataGuideCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dataGuideCfg.GroupId == completeCfg.GroupId)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataGuideCfg = guideConfig.Get(dataGuideCfg.NextId);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dataGuideCfg.GroupId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2024-08-01 14:49:39 +08:00
|
|
|
|
return completeCfg.GroupId; // 该组没有完成,重来
|
2024-08-01 14:42:22 +08:00
|
|
|
|
}
|
2024-09-30 17:38:53 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-10-08 16:13:27 +08:00
|
|
|
|
/// 设置引导状态
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void SetGuideState()
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.Instance.IsEnableBack = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 还原状态
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void RecoverState()
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.Instance.IsEnableBack = true;
|
2024-10-11 19:22:18 +08:00
|
|
|
|
ConditionReactor.Instance.RemoveReaction(reactionID);
|
|
|
|
|
|
reactionID = ConditionReactor.INVALID_ALLOC_ID;
|
2024-10-08 16:13:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-11 15:46:57 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 开始引导
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnBeginGuide(bool conditionResult, object callBackParam, int reactionID)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!conditionResult)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
ConditionReactor.Instance.RemoveReaction(reactionID);
|
|
|
|
|
|
this.reactionID = ConditionReactor.INVALID_ALLOC_ID;
|
|
|
|
|
|
|
|
|
|
|
|
if (IsGuiding)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SetGuideState();
|
|
|
|
|
|
int completeStepId = (int)Actor.Instance.Logic.GetCount((uint)LogicID.NewGuideProgress);
|
|
|
|
|
|
DebugUtil.Log($"<color=#00FA9A>已完成的引导步骤id:{completeStepId},开始引导组id:{curGroup.GroupId}</color>");
|
|
|
|
|
|
curGroup.BeginGuide();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"跳过引导,错误信息:{e}");
|
|
|
|
|
|
RecoverState();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-08 16:13:27 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 引导过程中的任意点击事件
|
2024-09-30 17:38:53 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnAnyClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!IsGuiding)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-10-18 18:13:23 +08:00
|
|
|
|
if (!IsEnableAnyClick)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-09-30 17:38:53 +08:00
|
|
|
|
DateTime curTime = CommonUtils.GetCurTime(CommonUtils.E_TimeType.Local);
|
|
|
|
|
|
queueTime.Enqueue(curTime);
|
2024-10-12 17:13:17 +08:00
|
|
|
|
while (queueTime.TryPeek(out DateTime firstTime))
|
|
|
|
|
|
{
|
|
|
|
|
|
TimeSpan timeSpan = curTime - firstTime;
|
|
|
|
|
|
if (timeSpan.TotalSeconds < SKIP_GUIDE_CHECK_TIME)
|
|
|
|
|
|
break;
|
2024-09-30 17:38:53 +08:00
|
|
|
|
|
|
|
|
|
|
queueTime.Dequeue();
|
2024-10-12 17:13:17 +08:00
|
|
|
|
}
|
2024-09-30 17:38:53 +08:00
|
|
|
|
|
2024-10-12 12:53:49 +08:00
|
|
|
|
if (TableManager.Instance.Tables.GlobalConfig.SkipGuideClickCount <= queueTime.Count)
|
2024-09-30 17:38:53 +08:00
|
|
|
|
{
|
2024-10-12 12:53:49 +08:00
|
|
|
|
DebugUtil.Log($"{SKIP_GUIDE_CHECK_TIME}秒内连续点击{TableManager.Instance.Tables.GlobalConfig.SkipGuideClickCount}次,弹出强制跳过新手引导提示");
|
2024-09-30 17:38:53 +08:00
|
|
|
|
queueTime.Clear();
|
2024-10-12 12:46:58 +08:00
|
|
|
|
ShowSkipAllGuide();
|
2024-09-30 17:38:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2024-10-08 16:13:27 +08:00
|
|
|
|
DebugUtil.Log($"[引导]记录两秒内的点击次数{queueTime.Count}");
|
2024-09-30 17:38:53 +08:00
|
|
|
|
}
|
2024-05-22 15:41:05 +08:00
|
|
|
|
}
|
2024-05-24 19:11:19 +08:00
|
|
|
|
}
|