56 lines
2.0 KiB
C#
Executable File
56 lines
2.0 KiB
C#
Executable File
using Cal.DataTable;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ET
|
|
{
|
|
[ActorMessageHandler]
|
|
public class C2M_EndBattleIdleFightHandler : AMActorLocationRpcHandler<Unit, C2M_EndBattleIdleFight, M2C_EndBattleIdleFight>
|
|
{
|
|
protected override async ETTask Run(Unit unit, C2M_EndBattleIdleFight request, M2C_EndBattleIdleFight response, Action reply)
|
|
{
|
|
try
|
|
{
|
|
if (!unit.IsTeamLeader)
|
|
{
|
|
response.Message = "您不是队长!";
|
|
reply();
|
|
return;
|
|
}
|
|
if (!unit.GetComponent<PlayerData>().IsBattleIdle)
|
|
{
|
|
response.Message = "战斗挂机还没有开始!";
|
|
reply();
|
|
return;
|
|
}
|
|
Team team = TeamComponent.Instance.Get(unit.TeamLeaderId);
|
|
if (team.TeamState == TeamState.Fight)
|
|
{
|
|
response.Message = "战斗中!";
|
|
reply();
|
|
return;
|
|
}
|
|
LinkedList<Unit> teamList = team.GetUnits();
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
int sceneId = unitScene.MapId / 100;
|
|
if (sceneId != Sys_SceneId.Scene_BattleIdle)
|
|
{
|
|
Log.Error($"【{ UserComponent.Instance.Get(unit.Id)?.NickName} ({ unit.Id})】在取消挂机时场景错误!");
|
|
}
|
|
BattleIdleMap.Instance.Remove(unit.TeamLeaderId);
|
|
await Game.EventSystem.Publish(new EventType.BackMainCity { unit = unit});
|
|
foreach (Unit u in teamList)
|
|
{
|
|
u.GetComponent<PlayerData>().IsBattleIdle = false;
|
|
}
|
|
|
|
reply();
|
|
await ETTask.CompletedTask;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e);
|
|
}
|
|
}
|
|
}
|
|
} |