2021-05-01 11:27:41 +08:00
|
|
|
|
using System;
|
2021-05-01 23:12:23 +08:00
|
|
|
|
using System.Collections.Generic;
|
2021-05-01 11:27:41 +08:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Cal.DataTable;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
[ActorMessageHandler]
|
|
|
|
|
public class C2M_ClickMapUnitHandler: AMActorLocationRpcHandler<Unit, C2M_ClickMapUnit, M2C_ClickMapUnit>
|
|
|
|
|
{
|
|
|
|
|
protected override async ETTask Run(Unit unit, C2M_ClickMapUnit request, M2C_ClickMapUnit response, Action reply)
|
|
|
|
|
{
|
|
|
|
|
if (!unit.IsTeamLeader)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "你不是队长!";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}if (unit.teamState == TeamState.Fight)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "战斗中...";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MapMonsterComponent monsterComponent = unit.GetComponent<MapMonsterComponent>();
|
|
|
|
|
var type = (MapMonsterType) request.type;
|
|
|
|
|
if (!monsterComponent.TryGet(type, out var monster) || monster.Id != request.Id)
|
|
|
|
|
{
|
|
|
|
|
response.Message = "系统错误,怪消失了";
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string strRet = null;
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case MapMonsterType.MainStory:
|
|
|
|
|
break;
|
|
|
|
|
case MapMonsterType.Trial:
|
|
|
|
|
break;
|
|
|
|
|
case MapMonsterType.ManulEquip:
|
|
|
|
|
strRet = await StartManulEquipBattle(unit, monster);
|
|
|
|
|
break;
|
|
|
|
|
case MapMonsterType.MapCoin:
|
|
|
|
|
break;
|
|
|
|
|
case MapMonsterType.SpaceTravel:
|
|
|
|
|
strRet = await StartSpaceTravelBattle(unit, monster);
|
|
|
|
|
break;
|
2021-05-05 13:36:19 +08:00
|
|
|
|
case MapMonsterType.StarSoulCopy:
|
|
|
|
|
strRet = await StartStarSoulCopyBattle(unit, monster);
|
|
|
|
|
break;
|
2021-05-01 11:27:41 +08:00
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strRet != null)
|
|
|
|
|
{
|
|
|
|
|
response.Message = strRet;
|
|
|
|
|
reply();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
monsterComponent.Remove(type);
|
|
|
|
|
reply();
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async ETTask<string> StartManulEquipBattle(Unit unit, Unit monster)
|
|
|
|
|
{
|
|
|
|
|
Team team = TeamComponent.Instance.Get(unit.TeamLeaderId);
|
|
|
|
|
if (team != null)
|
|
|
|
|
{
|
|
|
|
|
if (!AppConfig.inst.isTest)
|
|
|
|
|
if (team.MemberCount < 3)
|
|
|
|
|
{
|
|
|
|
|
return "至少3人才能挑战!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (team.TeamState == TeamState.Fight)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】多次进行手工副本战斗");
|
|
|
|
|
return"系统错误";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
|
|
|
UnitSceneType unitSceneType = MapHelper.GetMapType(unitScene.MapId / 100);
|
|
|
|
|
if (unitSceneType != UnitSceneType.ManulEquip)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】场景{unitScene.MapId / 100}错误");
|
|
|
|
|
return"系统错误";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long configId = monster.GetComponent<ConfigIdComponent>().configId;
|
|
|
|
|
ManulEquipMonsterConfig config = ManulEquipMonsterConfigCategory.Instance.Get(configId);
|
|
|
|
|
if ((unitScene.Position -monster.Position).sqrMagnitude > MoveHelper.AtkDis)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】位置{unitScene.Position}错误");
|
|
|
|
|
return "系统错误";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ManulEquipMap.instance.DestoryUnit(unit);
|
|
|
|
|
CopyBattle battle = BattleMgrCompnent.Instance.CreateBattle(team);
|
|
|
|
|
MonsterFactoryHelper.ManulEquipGenerate(battle, config);
|
|
|
|
|
battle.Init(battle.team, battle.targetTeam, CopyConfigId.ManulEquipBattle, config.Id);
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async ETTask<string> StartSpaceTravelBattle(Unit unit, Unit monster)
|
|
|
|
|
{
|
|
|
|
|
Team team = TeamComponent.Instance.Get(unit.TeamLeaderId);
|
|
|
|
|
|
|
|
|
|
if (team.TeamState == TeamState.Fight)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】多次进行时空旅行战斗");
|
|
|
|
|
return "系统错误";
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-16 17:22:42 +08:00
|
|
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
|
|
|
if (unitScene.layer != 6)
|
2021-05-01 23:12:23 +08:00
|
|
|
|
{
|
2021-05-16 17:22:42 +08:00
|
|
|
|
|
|
|
|
|
LinkedList<Unit> teamList = team.GetUnits();
|
|
|
|
|
foreach (Unit u in teamList)
|
2021-05-01 23:12:23 +08:00
|
|
|
|
{
|
2021-05-16 17:22:42 +08:00
|
|
|
|
PlayerData data = u.GetComponent<PlayerData>();
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"data == null where id = {u?.Id}");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2021-05-01 23:12:23 +08:00
|
|
|
|
|
2021-05-16 17:22:42 +08:00
|
|
|
|
if (data.travelVoucher <= 0)
|
|
|
|
|
{
|
|
|
|
|
return "您的或者队友的次数不够";
|
|
|
|
|
}
|
2021-05-01 23:12:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-01 11:27:41 +08:00
|
|
|
|
UnitSceneType unitSceneType = MapHelper.GetMapType(unitScene.sceneId);
|
|
|
|
|
if (unitSceneType != UnitSceneType.SpaceTravel)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】场景{unitScene.MapId / 100}错误");
|
|
|
|
|
return "系统错误";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long configId = monster.GetComponent<ConfigIdComponent>().configId;
|
|
|
|
|
SpaceTravelConfig spaceTravelConfig = SpaceTravelConfigCategory.Instance.Get(configId);
|
|
|
|
|
if ((unitScene.Position - monster.Position).sqrMagnitude > MoveHelper.AtkDis)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】位置{unitScene.Position}错误");
|
|
|
|
|
return "系统错误";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CopyBattle battle = BattleMgrCompnent.Instance.CreateBattle(team);
|
|
|
|
|
MonsterFactoryHelper.SpaceTravelGenerate(battle, spaceTravelConfig);
|
|
|
|
|
battle.Init(team, battle.targetTeam, CopyConfigId.SpaceTravelBattle, spaceTravelConfig.Id);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-05-05 13:36:19 +08:00
|
|
|
|
|
|
|
|
|
private async ETTask<string> StartStarSoulCopyBattle(Unit unit, Unit monster)
|
|
|
|
|
{
|
|
|
|
|
Team team = TeamComponent.Instance.Get(unit.TeamLeaderId);
|
|
|
|
|
|
|
|
|
|
if (team.TeamState == TeamState.Fight)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】多次进行星魂副本战斗");
|
|
|
|
|
return "系统错误";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
|
|
|
UnitSceneType unitSceneType = MapHelper.GetMapType(unitScene.sceneId);
|
|
|
|
|
if (unitSceneType != UnitSceneType.StarSoulCopy)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】场景{unitScene.MapId / 100}错误");
|
|
|
|
|
return "系统错误";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long configId = monster.GetComponent<ConfigIdComponent>().configId;
|
|
|
|
|
StarSoulCopyConfig soulCopyConfig = StarSoulCopyConfigCategory.Instance.Get(configId);
|
|
|
|
|
if ((unitScene.Position - monster.Position).sqrMagnitude > MoveHelper.AtkDis)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"*【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】位置{unitScene.Position}错误");
|
|
|
|
|
return "系统错误";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CopyBattle battle = BattleMgrCompnent.Instance.CreateBattle(team);
|
|
|
|
|
MonsterFactoryHelper.StarSoulGenerate(battle, soulCopyConfig);
|
|
|
|
|
battle.Init(team, battle.targetTeam, CopyConfigId.StarSoulBattle, soulCopyConfig.Id);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-05-01 11:27:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|