You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
52 lines
1.6 KiB
3 years ago
|
using System;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
[FriendClass(typeof(Battle))]
|
||
|
public class C2M_EnterBattleHandler: AMActorLocationRpcHandler<Unit, C2M_EnterBattle, M2C_EnterBattle>
|
||
|
{
|
||
|
protected async override ETTask Run(Unit unit, C2M_EnterBattle request, M2C_EnterBattle response, Action reply)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
Battle battle = null;
|
||
|
if (request.BattleType == ConstBattleType.BATTLE_PVP)
|
||
|
{
|
||
|
battle=await BattleOperate.EnterBattle(unit, request.EnemyId);
|
||
|
}
|
||
|
else if(request.BattleType == ConstBattleType.BATTLE_PVE)
|
||
|
{
|
||
|
battle = BattleOperate.EnterPveBattle(unit,request.EnemyId);
|
||
|
}
|
||
|
if (battle == null)
|
||
|
{
|
||
|
response.Error = ErrorCode.ERR_CanNotFoundEnemy;
|
||
|
reply();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
foreach (var v in battle.FighterDic)
|
||
|
{
|
||
|
response.FighterList.Add(v.Value.ToMessage());
|
||
|
}
|
||
|
|
||
|
foreach (var v in battle.EnemyDic)
|
||
|
{
|
||
|
response.EnemyList.Add(v.Value.ToMessage());
|
||
|
}
|
||
|
|
||
|
response.BattleId = battle.Id;
|
||
|
response.Error = ErrorCode.ERR_Success;
|
||
|
reply();
|
||
|
battle.BattleAtk();
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
response.Message = e.ToString();
|
||
|
reply();
|
||
|
}
|
||
|
|
||
|
await ETTask.CompletedTask;
|
||
|
}
|
||
|
}
|
||
|
}
|