NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/FirstTimeFlow/FirstTimeFlowManager.cs

142 lines
4.2 KiB
C#
Raw Normal View History

2025-04-02 16:27:14 +08:00
using Gameplay.HeroSelect;
using Gameplay.Naming;
2025-03-27 14:46:41 +08:00
using Gameplay.Net;
using PhxhSDK;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Gameplay.FirstTimeFlow
{
/// <summary>
/// 新号强制流程管理器
/// </summary>
2025-03-27 14:46:41 +08:00
public sealed class FirstTimeFlowManager : Singlenton<FirstTimeFlowManager>, IInitable
{
2025-03-27 14:46:41 +08:00
/// <summary>
/// 强制流程步骤链表
/// </summary>
private LinkedList<FirstTimeFlowStep> linkStep;
2025-04-03 15:19:42 +08:00
2025-04-02 16:27:14 +08:00
/// <summary>
/// 当前步骤
/// </summary>
public FirstTimeFlowStep CurStep { get; private set; }
2025-03-27 14:46:41 +08:00
/// <summary>
2025-03-27 15:26:49 +08:00
/// 是否强制流程中
/// </summary>
2025-04-02 16:27:14 +08:00
public bool IsFlowing { get { return null != CurStep; } }
/// <summary>
2025-04-02 16:51:01 +08:00
/// 是否有下一步
/// </summary>
public bool IsHasNextStep { get { return linkStep.Count > 0; } }
/// <summary>
2025-04-02 16:27:14 +08:00
/// 是否在剧情中需要设置角色
/// </summary>
/// <returns></returns>
2025-04-03 15:19:42 +08:00
public bool IsNeedSetHeroByStory
{
get
{
#if FIRST_TIME_FLOW
return CurStep is EnterStoryLevel1Step && !HeroSelectManager.Instance.IsSetHero;
#else
return false;
#endif
}
}
2025-04-02 16:27:14 +08:00
/// <summary>
/// 是否需要在剧情中设置名字
/// </summary>
2025-04-03 15:19:42 +08:00
public bool IsNeedSetNameByStory
{
get
{
#if FIRST_TIME_FLOW
return CurStep is EnterStoryLevel2Step && !NamingManager.Instance.IsSetName;
#else
return false;
#endif
}
}
2025-03-27 14:46:41 +08:00
public void Init()
{
linkStep = new LinkedList<FirstTimeFlowStep>();
}
public void Release()
{
2025-04-02 16:51:01 +08:00
linkStep.Clear();
2025-03-27 14:46:41 +08:00
}
/// <summary>
/// 开始强制流程
/// </summary>
2025-04-02 14:37:16 +08:00
/// <returns>是否强制流程</returns>
public bool StartFirstTimeFlow()
2025-03-27 14:46:41 +08:00
{
2025-04-03 15:19:42 +08:00
#if FIRST_TIME_FLOW
int severFlowId = (int)Actor.Instance.Logic.GetCount((uint)NLDPB.LogicID.NoviceProcessId); // 服务器所在强制流程步骤id
2025-03-27 14:46:41 +08:00
2025-04-03 15:02:30 +08:00
if (severFlowId <= (int)E_FirstTimeFlow.StarVideo)
linkStep.AddLast(PlayStartVideoStep.Create()); // 开始PV
2025-03-27 14:46:41 +08:00
2025-04-03 15:02:30 +08:00
if (severFlowId <= (int)E_FirstTimeFlow.StoryLevel_1)
linkStep.AddLast(EnterStoryLevel1Step.Create()); // 剧情1
2025-03-27 16:47:05 +08:00
2025-04-03 15:02:30 +08:00
if (severFlowId <= (int)E_FirstTimeFlow.FightLevel_1)
linkStep.AddLast(EnterFightLevel1Step.Create()); // 特殊战斗1
2025-03-27 16:47:05 +08:00
2025-04-03 15:02:30 +08:00
if (severFlowId <= (int)E_FirstTimeFlow.StoryLevel_2)
linkStep.AddLast(EnterStoryLevel2Step.Create()); // 剧情2
2025-03-27 16:47:05 +08:00
2025-04-03 15:02:30 +08:00
if (severFlowId <= (int)E_FirstTimeFlow.StoryLevel_3)
2025-04-02 19:39:27 +08:00
linkStep.AddLast(EnterStoryLevel3Step.Create()); // 剧情3
2025-04-03 15:02:30 +08:00
if (severFlowId <= (int)E_FirstTimeFlow.FightLevel_2_EditTeam)
linkStep.AddLast(FightLevel2EditTeamStep.Create()); // 特殊战斗2编队
2025-03-27 16:47:05 +08:00
2025-04-03 15:02:30 +08:00
if (severFlowId <= (int)E_FirstTimeFlow.StoryLevel_4)
2025-04-02 19:39:27 +08:00
linkStep.AddLast(EnterStoryLevel4Step.Create()); // 剧情4
2025-03-27 16:47:05 +08:00
2025-04-03 15:02:30 +08:00
if (severFlowId <= (int)E_FirstTimeFlow.EndVideo)
{
linkStep.AddLast(PlayEndVideoStep.Create()); // 结束PV
2025-04-03 15:02:30 +08:00
linkStep.AddLast(EndFirstTimeFlowStep.Create()); // 结束强制流程
}
2025-04-02 16:51:01 +08:00
if (IsHasNextStep)
2025-04-02 14:37:16 +08:00
{
StartNextStep();
2025-04-02 14:37:16 +08:00
return true;
}
2025-04-03 15:19:42 +08:00
#endif
2025-04-02 14:37:16 +08:00
return false;
}
/// <summary>
/// 开始下一个步骤
/// </summary>
public void StartNextStep()
{
2025-04-02 16:27:14 +08:00
CurStep = linkStep.First.Value;
linkStep.RemoveFirst();
2025-04-03 15:02:30 +08:00
NetHelper.SaveGuideProgress(NLDPB.LogicID.NoviceProcessId, (int)CurStep.FirstTimeFlow);
DebugUtil.Log($"保存强制流程{CurStep.FirstTimeFlow}");
2025-04-02 16:27:14 +08:00
CurStep.Run();
2025-04-03 15:02:30 +08:00
}
/// <summary>
/// 结束强制流程
/// </summary>
public void EndFirstTimeFlow()
{
CurStep = null;
linkStep.Clear();
2025-03-27 14:46:41 +08:00
}
}
}