38 lines
1003 B
C#
38 lines
1003 B
C#
|
using System;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
[ActorMessageHandler]
|
|||
|
public class C2M_InviteTeamHandler : AMActorLocationRpcHandler<Unit,C2M_InviteTeam, M2C_InviteTeam>
|
|||
|
{
|
|||
|
protected override async ETTask Run(Unit unit, C2M_InviteTeam request, M2C_InviteTeam response, Action reply)
|
|||
|
{
|
|||
|
if (!unit.IsTeamLeader)
|
|||
|
{
|
|||
|
response.Message = "您不是队长,无权邀请别人";
|
|||
|
reply();
|
|||
|
return;
|
|||
|
}
|
|||
|
Unit targetUnit = MapUnitComponent.Instance.Get(request.TargetId);
|
|||
|
if (targetUnit == null)
|
|||
|
{
|
|||
|
response.Message = "玩家单元不存在";
|
|||
|
reply();
|
|||
|
return ;
|
|||
|
}
|
|||
|
string retInvite = TeamComponent.Instance.CheckCanInvite(targetUnit);
|
|||
|
if (retInvite == null)
|
|||
|
{
|
|||
|
TeamComponent.Instance.InviteTeam(unit.TeamLeaderId, targetUnit);
|
|||
|
response.Message = "正在邀请该玩家...";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
response.Message = retInvite;
|
|||
|
}
|
|||
|
|
|||
|
reply();
|
|||
|
await ETTask.CompletedTask;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|