72 lines
2.8 KiB
C#
Executable File
72 lines
2.8 KiB
C#
Executable File
using Cal.DataTable;
|
|
using System;
|
|
|
|
namespace ET
|
|
{
|
|
[ActorMessageHandler]
|
|
public class C2M_StartTrialCopyFightHandler: AMActorLocationRpcHandler<Unit, C2M_StartTrialCopyFight, M2C_StartTrialCopyFight>
|
|
{
|
|
protected override async ETTask Run(Unit unit, C2M_StartTrialCopyFight request, M2C_StartTrialCopyFight response, Action reply)
|
|
{
|
|
try
|
|
{
|
|
//!排除队伍
|
|
Team team = TeamComponent.Instance.Get(unit.TeamLeaderId);
|
|
if (team is { MemberCount: > 1 })
|
|
{
|
|
response.Message = "试炼之地只能单人挑战!";
|
|
reply();
|
|
return;
|
|
}
|
|
|
|
if (team.TeamState == TeamState.Fight)
|
|
{
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】多次进行试炼战斗");
|
|
response.Message = "系统错误";
|
|
reply();
|
|
return;
|
|
}
|
|
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
UnitSceneType mapType = MapHelper.GetMapType(unitScene.MapId / 100);
|
|
if (mapType != UnitSceneType.Trial)
|
|
{
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】场景{unitScene.MapId / 100}错误");
|
|
response.Message = "系统错误";
|
|
reply();
|
|
return;
|
|
}
|
|
|
|
TrialCopy trialCopy = TrialCopyMap.Instance.GetTrialCopyInfo(unitScene.MapId);
|
|
if (trialCopy == null)
|
|
{
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】场景{unitScene.MapId}错误");
|
|
response.Message = "系统错误";
|
|
reply();
|
|
return;
|
|
}
|
|
|
|
if ((unitScene.Position - new UnityEngine.Vector2(trialCopy.Pos_X, trialCopy.Pos_Y)).sqrMagnitude > MoveHelper.AtkDis)
|
|
{
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】位置{unitScene.Position}错误");
|
|
response.Message = "系统错误";
|
|
reply();
|
|
return;
|
|
}
|
|
|
|
CopyBattle battle = BattleMgrCompnent.Instance.CreateBattle(team);
|
|
MonsterFactoryHelper.TrialCopyGenerate(battle, trialCopy);
|
|
battle.Init(battle.team, battle.targetTeam, CopyConfigId.TrialCopyBattle, trialCopy.Id);
|
|
reply();
|
|
|
|
response.TrialCopyId = (int) trialCopy.Id;
|
|
reply();
|
|
await ETTask.CompletedTask;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e);
|
|
}
|
|
}
|
|
}
|
|
} |