182 lines
5.7 KiB
C#
182 lines
5.7 KiB
C#
using cfg.GuideCfg;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Gameplay.Guide
|
|
{
|
|
/// <summary>
|
|
/// 引导组
|
|
/// </summary>
|
|
public class GuideGroup
|
|
{
|
|
/// <summary>
|
|
/// 引导步骤
|
|
/// </summary>
|
|
private readonly LinkedList<GuideStepBase> linkGuideStep;
|
|
/// <summary>
|
|
/// 当前引导步骤
|
|
/// </summary>
|
|
private LinkedListNode<GuideStepBase> curStep;
|
|
|
|
#region 属性
|
|
/// <summary>
|
|
/// 引导组id
|
|
/// </summary>
|
|
public int GroupId
|
|
{
|
|
get; private set;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否引导中
|
|
/// </summary>
|
|
public bool IsGuiding
|
|
{
|
|
get { return curStep != null && curStep.Value.IsGuiding; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否引导完成
|
|
/// </summary>
|
|
public bool IsComplete
|
|
{
|
|
get { return curStep != null && curStep == linkGuideStep.Last && E_GuideState.Complete == curStep.Value.GuideState; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当前引导步骤
|
|
/// </summary>
|
|
public GuideStepBase CurStep
|
|
{
|
|
get { return curStep.Value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取下一步引导id
|
|
/// </summary>
|
|
public int NextGroupId
|
|
{
|
|
get
|
|
{
|
|
if (null == linkGuideStep.Last)
|
|
return 0;
|
|
|
|
return linkGuideStep.Last.Value.Cfg.NextId;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 引导组构造
|
|
/// </summary>
|
|
/// <param name="groupId"></param>
|
|
/// <param name="linkCfg"></param>
|
|
/// <param name="isSkipBeginSkip">是否跳过起始步骤</param>
|
|
public GuideGroup(int groupId, LinkedList<DataGuideCfg> linkCfg, bool isSkipBeginSkip = false)
|
|
{
|
|
GroupId = groupId;
|
|
linkGuideStep = new();
|
|
|
|
foreach (DataGuideCfg cfg in linkCfg)
|
|
{
|
|
if (!isSkipBeginSkip)
|
|
{
|
|
linkGuideStep.AddLast(CreateGuideStep(cfg));
|
|
continue;
|
|
}
|
|
|
|
if (!cfg.IsBeginStep)
|
|
linkGuideStep.AddLast(CreateGuideStep(cfg));
|
|
}
|
|
|
|
curStep = linkGuideStep.First;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始引导
|
|
/// </summary>
|
|
public void BeginGuide()
|
|
{
|
|
if (null == curStep)
|
|
return;
|
|
|
|
curStep.Value.StartGuide();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始下一步引导
|
|
/// </summary>
|
|
public void BeginNextStep()
|
|
{
|
|
curStep = curStep.Next;
|
|
curStep.Value.StartGuide();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始指定步骤引导
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
public void BeginGuideById(int id)
|
|
{
|
|
curStep = linkGuideStep.First;
|
|
while (null != curStep)
|
|
{
|
|
if (curStep.Value.Cfg.Id == id)
|
|
break;
|
|
|
|
curStep = curStep.Next;
|
|
}
|
|
|
|
curStep?.Value.StartGuide();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 结束引导
|
|
/// </summary>
|
|
public void EndGuide()
|
|
{
|
|
if (IsGuiding)
|
|
{
|
|
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(true);
|
|
curStep.Value.EndGuide();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建引导步骤
|
|
/// </summary>
|
|
/// <param name="dataGuideCfg"></param>
|
|
/// <returns></returns>
|
|
private GuideStepBase CreateGuideStep(DataGuideCfg dataGuideCfg)
|
|
{
|
|
if (null == dataGuideCfg)
|
|
return null;
|
|
|
|
return dataGuideCfg.GuideStepType switch
|
|
{
|
|
E_GuideStepType.PlayVideo => new PlayVideoStep(dataGuideCfg),
|
|
E_GuideStepType.ClickButton => new ClickButtonStep(dataGuideCfg),
|
|
E_GuideStepType.DragButton => new SliderButtonStep(dataGuideCfg),
|
|
E_GuideStepType.ClickFloor => new ClickFloorStep(dataGuideCfg),
|
|
E_GuideStepType.EnterHome => new EnterMainStateStep(dataGuideCfg),
|
|
E_GuideStepType.ShowGuideTip => new ShowGuideTipStep(dataGuideCfg),
|
|
E_GuideStepType.EnterLevel => new EnterLevelStep(dataGuideCfg),
|
|
E_GuideStepType.Embattle => new LevelEmbattleStep(dataGuideCfg),
|
|
E_GuideStepType.EmbattleVehicle => new LevelEmbattleStep(dataGuideCfg),
|
|
E_GuideStepType.TeachFightMove => new TeachFightMoveStep(dataGuideCfg),
|
|
E_GuideStepType.TeachFightAttack => new TeachFightAttackStep(dataGuideCfg),
|
|
E_GuideStepType.TeachFightEmbattle => new TeachFightEmbattle(dataGuideCfg),
|
|
E_GuideStepType.TeachFightMoraleAndRepression => new TeachMoraleAndRepression(dataGuideCfg),
|
|
E_GuideStepType.TeachFightUseSkill => new TeachUseSkill(dataGuideCfg),
|
|
E_GuideStepType.WaitLevelComplete => new WaitLevelOver(dataGuideCfg),
|
|
E_GuideStepType.OpenChoosePerson => new OpenChoosePersonStep(dataGuideCfg),
|
|
E_GuideStepType.Wait => new WaitStep(dataGuideCfg),
|
|
E_GuideStepType.WaitOpenChangeName => new WaitOpenChangeName(dataGuideCfg),
|
|
E_GuideStepType.WaitEditTeam => new WaitEditTeamStep(dataGuideCfg),
|
|
E_GuideStepType.NoteStep => new NoteStep(dataGuideCfg),
|
|
E_GuideStepType.SaveDefaultTeam => new SaveDefaultTeamStep(dataGuideCfg),
|
|
_ => throw new Exception($"未处理类型:{dataGuideCfg.GuideStepType}"),
|
|
};
|
|
}
|
|
}
|
|
} |