65 lines
2.2 KiB
C#
65 lines
2.2 KiB
C#
using Cal.DataTable;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ET
|
|
{
|
|
|
|
[ActorMessageHandler]
|
|
public class C2M_StartMainStoryAIHandler : AMActorLocationRpcHandler<Unit, C2M_StartMainStoryAI, M2C_StartMainStoryAI>
|
|
{
|
|
protected override async ETTask Run(Unit unit, C2M_StartMainStoryAI request, M2C_StartMainStoryAI response, Action reply)
|
|
{
|
|
try
|
|
{
|
|
if (!unit.IsTeamLeader)
|
|
{
|
|
response.Message = "您不是队长";
|
|
reply();
|
|
return;
|
|
}
|
|
if (unit.teamState != TeamState.None)
|
|
{
|
|
response.Message = "空闲状态才可以开始";
|
|
reply();
|
|
return;
|
|
}
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
if (unitScene.MapId / 100 != Sys_SceneId.Scene_MainCity)
|
|
{
|
|
response.Message = "城镇才可以开始";
|
|
reply();
|
|
return;
|
|
}
|
|
|
|
int targetSceneId = request.Index + 10010;
|
|
if (MainStoryMap.Instance.GetMainStoryData(targetSceneId * 100 + 1) == null)
|
|
{
|
|
response.Message = "输入有误!";
|
|
reply();
|
|
return;
|
|
}
|
|
Team team = TeamComponent.Instance.Get(unit.TeamLeaderId);
|
|
LinkedList<Unit> teamList = team.GetUnits();
|
|
foreach (Unit u in teamList)
|
|
{
|
|
if (!u.GetComponent<PlayerData>().CanEnterMianStory(targetSceneId - 1))
|
|
{
|
|
response.Message = "队伍中至少有一人没通过这一章节!";
|
|
reply();
|
|
return;
|
|
}
|
|
}
|
|
MainStoryAI ai = MainStoryAIComponent.instance.CreateAI(team,targetSceneId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e);
|
|
}
|
|
reply();
|
|
await ETTask.CompletedTask;
|
|
}
|
|
}
|
|
|
|
}
|