NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Guide/GuideGroup.cs

165 lines
5.6 KiB
C#
Raw Normal View History

2024-05-22 19:08:14 +08:00
using cfg.GuideCfg;
using System;
using System.Collections.Generic;
2024-05-29 16:36:30 +08:00
namespace Gameplay.Guide
2024-05-22 19:08:14 +08:00
{
/// <summary>
2024-05-29 16:36:30 +08:00
/// 引导组
2024-05-22 19:08:14 +08:00
/// </summary>
2024-05-29 16:36:30 +08:00
public class GuideGroup
2024-05-28 18:47:23 +08:00
{
2024-05-29 16:36:30 +08:00
/// <summary>
/// 引导步骤
/// </summary>
private readonly LinkedList<GuideStepBase> linkGuideStep;
/// <summary>
/// 当前引导步骤
/// </summary>
private LinkedListNode<GuideStepBase> curStep;
#region 属性
/// <summary>
/// 引导组id
/// </summary>
public int GroupId
{
get; private set;
}
2024-05-28 18:47:23 +08:00
2024-05-29 16:36:30 +08:00
/// <summary>
/// 是否引导中
/// </summary>
public bool IsGuiding
{
get { return curStep != null && curStep.Value.IsGuiding; }
}
2024-05-24 19:11:19 +08:00
2024-05-29 16:36:30 +08:00
/// <summary>
/// 引导组是否完成
2024-05-29 16:36:30 +08:00
/// </summary>
public bool IsComplete
{
get { return curStep != null && curStep == linkGuideStep.Last && E_GuideState.Complete == curStep.Value.GuideState; }
}
2024-05-24 19:11:19 +08:00
2024-05-29 16:36:30 +08:00
/// <summary>
/// 当前引导步骤
/// </summary>
public GuideStepBase CurStep
{
get { return curStep.Value; }
}
2024-05-24 19:11:19 +08:00
2024-05-29 16:36:30 +08:00
/// <summary>
/// 获取下一步引导id
/// </summary>
public int NextGroupId
2024-05-24 19:11:19 +08:00
{
2024-05-29 16:36:30 +08:00
get
{
if (null == linkGuideStep.Last)
return 0;
2024-05-24 19:11:19 +08:00
2024-05-29 16:36:30 +08:00
return linkGuideStep.Last.Value.Cfg.NextId;
}
2024-05-24 19:11:19 +08:00
}
2024-05-29 16:36:30 +08:00
#endregion
2024-05-22 19:08:14 +08:00
2024-07-05 19:33:21 +08:00
/// <summary>
/// 引导组构造
/// </summary>
/// <param name="groupId"></param>
2024-12-04 14:27:43 +08:00
/// <param name="listCfg"></param>
2024-07-05 19:33:21 +08:00
/// <param name="isSkipBeginSkip">是否跳过起始步骤</param>
2024-12-04 14:27:43 +08:00
public GuideGroup(int groupId, List<DataGuideCfg> listCfg, bool isSkipBeginSkip = false)
2024-05-22 19:08:14 +08:00
{
2024-05-29 16:36:30 +08:00
GroupId = groupId;
linkGuideStep = new();
2024-05-22 19:08:14 +08:00
2024-12-04 14:27:43 +08:00
foreach (DataGuideCfg cfg in listCfg)
2024-05-29 16:36:30 +08:00
{
2024-07-05 19:33:21 +08:00
if (!isSkipBeginSkip)
{
linkGuideStep.AddLast(CreateGuideStep(cfg));
continue;
}
if (!cfg.IsBeginStep)
linkGuideStep.AddLast(CreateGuideStep(cfg));
2024-05-29 16:36:30 +08:00
}
2024-05-22 19:08:14 +08:00
2024-05-29 16:36:30 +08:00
curStep = linkGuideStep.First;
}
2024-05-22 19:08:14 +08:00
2024-05-29 16:36:30 +08:00
/// <summary>
/// 开始引导
/// </summary>
2024-10-28 14:22:54 +08:00
public async void BeginGuide()
2024-05-29 16:36:30 +08:00
{
if (null == curStep)
return;
2024-05-24 19:11:19 +08:00
DebugUtil.Log($"<color=#00FA9A>正常开始id为{curStep.Value.Cfg.Id}的引导</color>"); // #00FA9A绿色
2024-10-28 14:22:54 +08:00
await curStep.Value.StartGuide();
2024-05-29 16:36:30 +08:00
}
2024-05-22 19:08:14 +08:00
2024-05-29 16:36:30 +08:00
/// <summary>
/// 开始下一步引导
/// </summary>
2024-10-28 14:22:54 +08:00
public async void BeginNextStep()
2024-05-29 16:36:30 +08:00
{
curStep = curStep.Next;
DebugUtil.Log($"<color=#00FA9A>开始下一步引导开始id为{curStep.Value.Cfg.Id}的引导</color>"); // #00FA9A绿色
2024-10-28 14:22:54 +08:00
await curStep.Value.StartGuide();
2024-05-29 16:36:30 +08:00
}
2024-05-22 19:08:14 +08:00
2024-05-29 16:36:30 +08:00
/// <summary>
/// 结束引导
/// </summary>
public void EndGuide()
{
if (IsGuiding)
curStep.Value.EndGuide();
}
2024-05-24 19:11:19 +08:00
2024-05-29 16:36:30 +08:00
/// <summary>
/// 创建引导步骤
/// </summary>
/// <param name="dataGuideCfg"></param>
/// <returns></returns>
private GuideStepBase CreateGuideStep(DataGuideCfg dataGuideCfg)
2024-05-22 19:08:14 +08:00
{
2024-05-29 16:36:30 +08:00
if (null == dataGuideCfg)
return null;
return dataGuideCfg.GuideStepType switch
{
E_GuideStepType.PlayVideo => new PlayVideoStep(dataGuideCfg),
E_GuideStepType.ClickButton => new ClickButtonStep(dataGuideCfg),
2024-07-02 16:44:14 +08:00
E_GuideStepType.DragButton => new SliderButtonStep(dataGuideCfg),
2024-07-01 13:08:37 +08:00
E_GuideStepType.ClickFloor => new ClickFloorStep(dataGuideCfg),
2024-06-04 19:13:48 +08:00
E_GuideStepType.EnterHome => new EnterMainStateStep(dataGuideCfg),
2024-05-29 16:36:30 +08:00
E_GuideStepType.ShowGuideTip => new ShowGuideTipStep(dataGuideCfg),
E_GuideStepType.EnterLevel => new EnterLevelStep(dataGuideCfg),
E_GuideStepType.Embattle => new LevelEmbattleStep(dataGuideCfg),
2024-06-03 16:48:18 +08:00
E_GuideStepType.EmbattleVehicle => new LevelEmbattleStep(dataGuideCfg),
2024-06-04 15:13:16 +08:00
E_GuideStepType.WaitLevelComplete => new WaitLevelOver(dataGuideCfg),
2024-06-20 16:36:40 +08:00
E_GuideStepType.OpenChoosePerson => new OpenChoosePersonStep(dataGuideCfg),
2024-07-01 16:19:07 +08:00
E_GuideStepType.Wait => new WaitStep(dataGuideCfg),
2024-07-03 19:21:42 +08:00
E_GuideStepType.WaitOpenChangeName => new WaitOpenChangeName(dataGuideCfg),
2024-07-04 13:21:28 +08:00
E_GuideStepType.WaitEditTeam => new WaitEditTeamStep(dataGuideCfg),
2024-07-04 14:40:00 +08:00
E_GuideStepType.NoteStep => new NoteStep(dataGuideCfg),
2024-07-05 20:49:03 +08:00
E_GuideStepType.SaveDefaultTeam => new SaveDefaultTeamStep(dataGuideCfg),
2024-10-15 18:48:43 +08:00
E_GuideStepType.EnterEditTeam => new EnterEnterEditTeam(dataGuideCfg),
2024-10-18 13:31:45 +08:00
E_GuideStepType.EnterTeamInfo => new EnterEnterTeamInfo(dataGuideCfg),
2024-10-15 20:05:34 +08:00
E_GuideStepType.ClearTeam => new ClearTeamStep(dataGuideCfg),
2024-10-16 13:02:48 +08:00
E_GuideStepType.DragButtonBattle => new SliderButtonBattleStep(dataGuideCfg),
2024-10-28 14:22:54 +08:00
E_GuideStepType.DragButtonUseSkill => new SliderButtonUseSkillStep(dataGuideCfg),
E_GuideStepType.DragButtonUsePlayerSkill => new SliderButtonUsePlayerSkillStep(dataGuideCfg),
2024-10-16 17:40:49 +08:00
E_GuideStepType.SelectTeam => new SelectTeamStep(dataGuideCfg),
2024-05-29 16:36:30 +08:00
_ => throw new Exception($"未处理类型:{dataGuideCfg.GuideStepType}"),
}; ;
2024-05-29 16:36:30 +08:00
}
2024-05-22 19:08:14 +08:00
}
2024-05-29 16:36:30 +08:00
}