79 lines
3.3 KiB
C#
79 lines
3.3 KiB
C#
|
using Cal.DataTable;
|
|||
|
using System;
|
|||
|
using System.Net;
|
|||
|
using System.Xml;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
[ActorMessageHandler]
|
|||
|
public class C2M_StartMainStoryFightHandler : AMActorLocationRpcHandler<Unit, C2M_StartMainStoryFight, M2C_StartMainStoryFight>
|
|||
|
{
|
|||
|
//0.50f, 0.46f, 0.41f, 0.35f
|
|||
|
public readonly static float[] HpDifficultyArr = { 0, 0.50f, 0.96f, 1.37f, 1.72f };
|
|||
|
// 0.18f, 0.16f, 0.12f, 0.08f
|
|||
|
public readonly static float[] AtkDefDifficultyArr = { 0, 0.18f, 0.34f, 0.46f, 0.53f };
|
|||
|
private const int moveTimeToStartMonster = 2 * 1000;
|
|||
|
protected override async ETTask Run(Unit unit, C2M_StartMainStoryFight request, M2C_StartMainStoryFight response, Action reply)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (!unit.IsTeamLeader)
|
|||
|
{
|
|||
|
response.Message = "您不是队长!";
|
|||
|
reply();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
var unitScene = unit.GetComponent<UnitScene>();
|
|||
|
if (TimeHelper.ClientNow() - unitScene.enterTime < moveTimeToStartMonster)
|
|||
|
{
|
|||
|
Log.Error($"*【{ UserComponent.Instance.Get(unit.Id)?.NickName} ({ unit.Id})】挑战主线时间错误,进入了{TimeHelper.ClientNow() - unitScene.enterTime}");
|
|||
|
response.Message = "系统错误";
|
|||
|
reply();
|
|||
|
return;
|
|||
|
}
|
|||
|
MainStory mainStory = MainStoryMap.Instance.GetMainStoryData(unitScene.MapId);
|
|||
|
if (mainStory == null)
|
|||
|
{
|
|||
|
Log.Error($"*【{ UserComponent.Instance.Get(unit.Id)?.NickName} ({ unit.Id})】场景{unitScene.MapId}错误");
|
|||
|
response.Message = "系统错误";
|
|||
|
reply();
|
|||
|
return;
|
|||
|
}
|
|||
|
bool isPosWoring = true;
|
|||
|
for (int i = 0; i < mainStory.MonsterPosArr.Length; i++)
|
|||
|
{
|
|||
|
var posInfo = mainStory.MonsterPosArr[i];
|
|||
|
if ((unitScene.Position - new UnityEngine.Vector2(posInfo.MonsterPos_X, posInfo.MonsterPos_Y)).sqrMagnitude <= MoveHelper.AtkDis)
|
|||
|
{
|
|||
|
isPosWoring = false;
|
|||
|
}
|
|||
|
}
|
|||
|
if (isPosWoring)
|
|||
|
{
|
|||
|
Log.Error($"*【{ UserComponent.Instance.Get(unit.Id)?.NickName} ({ unit.Id})】位置{unitScene.Position}错误");
|
|||
|
response.Message = "系统错误";
|
|||
|
reply();
|
|||
|
return;
|
|||
|
}
|
|||
|
Team team = TeamComponent.Instance.Get(unit.TeamLeaderId);
|
|||
|
if (team.TeamState == TeamState.Fight)
|
|||
|
{
|
|||
|
Log.Error($"*【{ UserComponent.Instance.Get(unit.Id)?.NickName} ({ unit.Id})】多次进行主线战斗");
|
|||
|
response.Message = "系统错误";
|
|||
|
reply();
|
|||
|
return;
|
|||
|
}
|
|||
|
var battle= BattleMgrCompnent.Instance.CreateBattle<MainStoryBattle>(team);
|
|||
|
battle.Init(mainStory);
|
|||
|
reply();
|
|||
|
|
|||
|
await ETTask.CompletedTask;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
Log.Error(e);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|