877 lines
33 KiB
C#
Executable File
877 lines
33 KiB
C#
Executable File
using System;
|
||
using System.Collections.Generic;
|
||
using Cal.DataTable;
|
||
using ET.EventType;
|
||
|
||
namespace ET
|
||
{
|
||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
|
||
public class DataTableMethodAttribute: BaseAttribute
|
||
{
|
||
}
|
||
|
||
public static partial class GlobalMethod
|
||
{
|
||
[DataTableMethod]
|
||
public static async ETTask<string> CommonDefeat(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
if (self == null)
|
||
{
|
||
Log.Error($"battle == null");
|
||
return "系统错误";
|
||
}
|
||
|
||
var leader = team.GetLeader();
|
||
if (leader.UnitType == UnitType.Player)
|
||
Log.Debug($"{team.GetMemberName()} {self.battleType}失败了!");
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
await BattleHelper.DefeatOption(self, team);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> TrialCopyBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
Log.Debug(team.GetMemberName() + "试炼之地胜利了!");
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
await TimerComponent.Instance.WaitAsync(5000L);
|
||
MessageHelper.SendActor(unit, new M2C_BattleVictory { BattleType = (int) self.battleType });
|
||
await TimerComponent.Instance.WaitAsync(500L);
|
||
PlayerData data = unit.GetComponent<PlayerData>();
|
||
await data.UpdateTrialCopy((mapId / 100));
|
||
await BattleHelper.VictoryOption(self, team, self.configId);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> MainStoryBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
|
||
Log.Debug($"{team.GetMemberName()}主线胜利了!");
|
||
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
|
||
if (mapId % 100 == 10)
|
||
{
|
||
await TimerComponent.Instance.WaitAsync(6000);
|
||
foreach (Unit item in teamList)
|
||
{
|
||
MessageHelper.SendActor(item, new M2C_BattleVictory() { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
await Game.EventSystem.Publish(new EventType.BackMainCity { unit = unit, isForce = true });
|
||
//!更新通过记录
|
||
foreach (Unit u in teamList)
|
||
{
|
||
PlayerData data = u.GetComponent<PlayerData>();
|
||
int dId = mapId / 100 - data.MainStoryRecordId;
|
||
if (mapId / 100 == Sys_SceneId.Scene_MainStory17 &&
|
||
data.MainStoryRecordId >= Sys_SceneId.Scene_MainStory16 &&
|
||
data.MainStoryRecordId < Sys_SceneId.Scene_MainStory17)
|
||
{
|
||
data.MainStoryRecordId = Sys_SceneId.Scene_MainStory17;
|
||
}
|
||
else
|
||
{
|
||
switch (dId)
|
||
{
|
||
case 1:
|
||
data.MainStoryRecordId++;
|
||
break;
|
||
case > 1:
|
||
Log.Error($"【严重错误】玩家 Id={u.Id}通过记录增加数大于1 ");
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
foreach (Unit item in teamList)
|
||
{
|
||
MessageHelper.SendActor(item, new M2C_BattleVictory() { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
await TimerComponent.Instance.WaitAsync(500);
|
||
foreach (Unit item in teamList)
|
||
{
|
||
MessageHelper.SendActor(item, new M2C_StartupTransPoint() { MapId = mapId });
|
||
}
|
||
}
|
||
|
||
await BattleHelper.VictoryOption(self, team, self.configId);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> MainStoryIdleBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
|
||
Log.Debug($"{team.GetMemberName()}挂机战斗胜利了!");
|
||
|
||
await TimerComponent.Instance.WaitAsync(6000);
|
||
foreach (Unit item in teamList)
|
||
{
|
||
MessageHelper.SendActor(item, new M2C_BattleVictory() { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
//!结束挂机战斗
|
||
BattleIdleMap.Instance.Get(team.LeaderId)?.SetFightEnd();
|
||
await BattleHelper.VictoryOption(self, team, self.configId);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> BossBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
Log.Debug($"{team.GetMemberName()}Boss战斗胜利了!{unitScene.MapId}");
|
||
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
foreach (Unit item in teamList)
|
||
{
|
||
MessageHelper.SendActor(item, new M2C_BattleVictory() { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
//!更新Boss状态
|
||
BossComponent.Instance.BossDead(team.GetMemberName(), mapId % 100);
|
||
await BattleHelper.VictoryOption(self, team, self.configId);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> FamilyBossBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
var unit = team.GetLeader();
|
||
await SettleBossDamageData(self, unit);
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
|
||
Log.Debug($"{team.GetMemberName()}家族{self.configId}阶Boss战斗胜利了!");
|
||
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
foreach (Unit item in teamList)
|
||
{
|
||
MessageHelper.SendActor(item, new M2C_BattleVictory() { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
team.ChangeState(TeamState.None);
|
||
|
||
//!战斗结束事件(回血,奖励)
|
||
UnOrderMultiMapComponent<long, (int, int)> rewordMapComponent = UnOrderMultiMapComponent<long, (int, int)>.Create();
|
||
foreach (Unit u in teamList)
|
||
{
|
||
Game.EventSystem.Publish(new EventType.BattleEnd { unit = u, team = team }).Coroutine();
|
||
Game.EventSystem.Publish(new EventType.BattleEnd_AddHp { unit = u }).Coroutine();
|
||
u.Live();
|
||
}
|
||
|
||
//!移除不在线玩家
|
||
await TeamComponent.Instance.RemoveAllOffLineId(team);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
private static async ETTask<string> SettleBossDamageData(CopyBattle self, Unit leader)
|
||
{
|
||
User user = await UserComponent.Instance.Query(leader.Id);
|
||
FamilyBoss family = await FamilyBossComponent.instance.Query(user.Family);
|
||
FamilyBossConfig familyBossConfig = FamilyBossConfigCategory.Instance.Get(self.configId);
|
||
family.InsertDamageInfo((int) familyBossConfig.Id, self.bossDamageMap);
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> FamilyBossBattleDefeat(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
var leader = team.GetLeader();
|
||
await SettleBossDamageData(self, leader);
|
||
if (leader.UnitType == UnitType.Player)
|
||
Log.Debug($"{team.GetMemberName()} {self.battleType}失败了!");
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
await BattleHelper.DefeatOption(self, team);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> ManulEquipBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
|
||
Log.Debug($"{team.GetMemberName()}手工副本胜利了!");
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
//!触发通关任务事件
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
foreach (Unit item in teamList)
|
||
{
|
||
MessageHelper.SendActor(item, new M2C_BattleVictory() { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
if (MapHelper.GetMapType(mapId / 100) == UnitSceneType.ManulEquip)
|
||
{
|
||
int layer = mapId % 100;
|
||
if (layer == 4)
|
||
{
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
else
|
||
{
|
||
Game.EventSystem.Publish(new ChangeMap() { unit = unit, mapId = mapId + 1 });
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Log.Error($"{unit.Id.GetPlayerFormatName()} 位置错误 : {mapId}");
|
||
}
|
||
|
||
await BattleHelper.VictoryOption(self, team, self.configId);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> PKBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
|
||
Log.Debug($"{team.GetMemberName()} PK胜利了!");
|
||
//!触发通关任务事件
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
foreach (Unit item in teamList)
|
||
{
|
||
MessageHelper.SendActor(item, new M2C_BattleVictory() { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
team.ChangeState(TeamState.None);
|
||
|
||
foreach (Unit u in teamList)
|
||
{
|
||
Game.EventSystem.Publish(new EventType.BattleEnd { unit = u, team = team }).Coroutine();
|
||
Game.EventSystem.Publish(new EventType.BattleEnd_AddHp { unit = u }).Coroutine();
|
||
u.Live();
|
||
}
|
||
|
||
//!移除不在线玩家
|
||
await TeamComponent.Instance.RemoveAllOffLineId(team);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> PersonalPvpBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
|
||
Log.Debug($"{team.GetMemberName()} 竞技场胜利了!");
|
||
//!触发通关任务事件
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
foreach (Unit item in teamList)
|
||
{
|
||
MessageHelper.SendActor(item, new M2C_BattleVictory() { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
foreach (Unit u in teamList)
|
||
{
|
||
Game.EventSystem.Publish(new EventType.BattleEnd { unit = u, team = team }).Coroutine();
|
||
u.Live();
|
||
CharacterHelper.RecoverUnit(u);
|
||
}
|
||
|
||
//!移除不在线玩家
|
||
await TeamComponent.Instance.RemoveAllOffLineId(team);
|
||
|
||
await PvpMap.inatance.SettleBattle(team, self.GetAnotherTeam(team));
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> PersonalPvpBattleDefeat(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
Log.Debug($"{team.GetMemberName()} 竞技场失败了!");
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
foreach (Unit u in teamList)
|
||
{
|
||
MessageHelper.SendActor(u, new M2C_BattleDefeat { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
foreach (Unit u in teamList)
|
||
{
|
||
u.Live();
|
||
//!战斗结束事件(回血)
|
||
Game.EventSystem.Publish(new EventType.BattleEnd { unit = u, team = team }).Coroutine();
|
||
CharacterHelper.RecoverUnit(u);
|
||
}
|
||
|
||
//!移除不在线玩家
|
||
await TeamComponent.Instance.RemoveAllOffLineId(team);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> BossBattleDefeat(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
if (self == null)
|
||
{
|
||
Log.Error($"battle == null");
|
||
return "系统错误";
|
||
}
|
||
|
||
var leader = team.GetLeader();
|
||
UnitScene unitScene = leader.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
if (leader.UnitType == UnitType.Player)
|
||
Log.Debug($"{team.GetMemberName()} {self.battleType}失败了!");
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
await BattleHelper.DefeatOption(self, team);
|
||
//!重新刷新Boss
|
||
int mapLayer = mapId % 100;
|
||
BossComponent.Instance.ChangeState(mapLayer, BossComponent.BossState.Idle, true);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> SpaceTravelBattleVictory(object arg)
|
||
{
|
||
void ReSetSpaceTravelNum(Team team)
|
||
{
|
||
foreach (Unit teamMember in team.GetUnits())
|
||
{
|
||
var playerData = teamMember.GetComponent<PlayerData>();
|
||
if (playerData)
|
||
{
|
||
int num = ConstDefine.SpaceTravelBossNumArray.RandomArray_Len2();
|
||
playerData.noSpaceTravelBossDay = num;
|
||
UnitHelper.SaveComponenet(playerData);
|
||
}
|
||
}
|
||
}
|
||
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
Log.Info(team.GetMemberName() + $"{self.battleType}胜利了!");
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
if (mapId % 100 != 6)
|
||
{
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
foreach (Unit u in teamList)
|
||
{
|
||
PlayerData _data = u.GetComponent<PlayerData>();
|
||
if (_data == null)
|
||
{
|
||
Log.Error($"data == null where id = {u?.Id}");
|
||
continue;
|
||
}
|
||
|
||
_data.travelVoucher--;
|
||
}
|
||
}
|
||
|
||
await TimerComponent.Instance.WaitAsync(5000L);
|
||
foreach (Unit unit1 in team.GetUnits())
|
||
{
|
||
MessageHelper.SendActor(unit1, new M2C_BattleVictory { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
await TimerComponent.Instance.WaitAsync(500L);
|
||
if (MapHelper.GetMapType(mapId / 100) == UnitSceneType.SpaceTravel)
|
||
{
|
||
int layer = mapId % 100;
|
||
if (layer == 5)
|
||
{
|
||
if (MathHelper.IsHit(0.02f))
|
||
{
|
||
ReSetSpaceTravelNum(team);
|
||
Game.EventSystem.Publish(new ChangeMap() { unit = unit, mapId = mapId + 1 });
|
||
}
|
||
else
|
||
{
|
||
foreach (Unit teamMember in team.GetUnits())
|
||
{
|
||
var playerData = teamMember.GetComponent<PlayerData>();
|
||
if (playerData)
|
||
{
|
||
playerData.noSpaceTravelBossDay--;
|
||
UnitHelper.SaveComponenet(playerData);
|
||
}
|
||
}
|
||
|
||
var playerLeaderData = unit.GetComponent<PlayerData>();
|
||
if (playerLeaderData.noSpaceTravelBossDay <= 0)
|
||
{
|
||
ReSetSpaceTravelNum(team);
|
||
Game.EventSystem.Publish(new ChangeMap() { unit = unit, mapId = mapId + 1 });
|
||
}
|
||
else
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
}
|
||
else if (layer == 6)
|
||
{
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
else
|
||
{
|
||
Game.EventSystem.Publish(new ChangeMap() { unit = unit, mapId = mapId + 1 });
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Log.Error($"{unit.Id.GetPlayerFormatName()} 位置错误 : {mapId}");
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
|
||
await BattleHelper.VictoryOption(self, team, self.configId);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> SpaceTravelBattleDefeat(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
if (self == null)
|
||
{
|
||
Log.Error($"battle == null");
|
||
return "系统错误";
|
||
}
|
||
|
||
var unit = team.GetLeader();
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
|
||
if (mapId % 100 != 6)
|
||
{
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
foreach (Unit u in teamList)
|
||
{
|
||
PlayerData _data = u.GetComponent<PlayerData>();
|
||
if (_data == null)
|
||
{
|
||
Log.Error($"data == null where id = {u?.Id}");
|
||
continue;
|
||
}
|
||
|
||
_data.travelVoucher--;
|
||
}
|
||
}
|
||
|
||
if (unit.UnitType == UnitType.Player)
|
||
Log.Debug($"{team.GetMemberName()} {self.battleType}失败了!");
|
||
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
await BattleHelper.DefeatOption(self, team);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> StarSoulBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
Log.Info(team.GetMemberName() + $"{self.battleType}胜利了!");
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
await TimerComponent.Instance.WaitAsync(5000L);
|
||
foreach (Unit unit1 in team.GetUnits())
|
||
{
|
||
MessageHelper.SendActor(unit1, new M2C_BattleVictory { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
await TimerComponent.Instance.WaitAsync(500L);
|
||
if (MapHelper.GetMapType(mapId / 100) == UnitSceneType.StarSoulCopy)
|
||
{
|
||
int layer = mapId % 100;
|
||
if (layer == 3)
|
||
{
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
else
|
||
{
|
||
Game.EventSystem.Publish(new ChangeMap() { unit = unit, mapId = mapId + 1 });
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Log.Error($"{unit.Id.GetPlayerFormatName()} 位置错误 : {mapId}");
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
|
||
await BattleHelper.VictoryOption(self, team, self.configId);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> WorldBossBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
Log.Info(team.GetMemberName() + $"{self.battleType}胜利了!");
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
await TimerComponent.Instance.WaitAsync(5000L);
|
||
foreach (Unit unit1 in team.GetUnits())
|
||
{
|
||
MessageHelper.SendActor(unit1, new M2C_BattleVictory { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
await TimerComponent.Instance.WaitAsync(500L);
|
||
if (MapHelper.GetMapType(mapId / 100) == UnitSceneType.WorldBoss)
|
||
{
|
||
}
|
||
else
|
||
{
|
||
Log.Error($"{unit.Id.GetPlayerFormatName()} 位置错误 : {mapId}");
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
|
||
await BattleHelper.VictoryOption(self, team, self.configId);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> WorldBossBattleDefeat(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
long instanceId = team.InstanceId;
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
Log.Info(team.GetMemberName() + $"{self.battleType}失败了!");
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
|
||
await TimerComponent.Instance.WaitAsync(5000L);
|
||
foreach (Unit unit1 in team.GetUnits())
|
||
{
|
||
MessageHelper.SendActor(unit1, new M2C_BattleDefeat { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
await TimerComponent.Instance.WaitAsync(500L);
|
||
if (MapHelper.GetMapType(mapId / 100) == UnitSceneType.WorldBoss)
|
||
{
|
||
if (team.InstanceId != instanceId)
|
||
{
|
||
Log.Error($"team instanceId is not same : old ={instanceId} new = {team.InstanceId}");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Log.Error($"{unit.Id.GetPlayerFormatName()} 位置错误 : {mapId}");
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
|
||
await BattleHelper.DefeatOption(self, team, true);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> JourneyOfDeathBattleVictory(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
Log.Info(team.GetMemberName() + $"{self.battleType}胜利了!");
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
foreach (Unit u in teamList)
|
||
{
|
||
PlayerData _data = u.GetComponent<PlayerData>();
|
||
if (_data == null)
|
||
{
|
||
Log.Error($"data == null where id = {u?.Id}");
|
||
continue;
|
||
}
|
||
|
||
_data.journeyOfDeathCount--;
|
||
}
|
||
|
||
await TimerComponent.Instance.WaitAsync(5000L);
|
||
|
||
foreach (Unit unit1 in team.GetUnits())
|
||
{
|
||
MessageHelper.SendActor(unit1, new M2C_BattleVictory { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
await TimerComponent.Instance.WaitAsync(500L);
|
||
if (MapHelper.GetMapType(mapId / 100) == UnitSceneType.JourneyOfDeath)
|
||
{
|
||
int layer = mapId % 100;
|
||
if (layer == 2)
|
||
{
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
else
|
||
{
|
||
Game.EventSystem.Publish(new ChangeMap() { unit = unit, mapId = mapId + 1 });
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Log.Error($"{unit.Id.GetPlayerFormatName()} 位置错误 : {mapId}");
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
|
||
await BattleHelper.VictoryOption(self, team, self.configId);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask<string> JourneyOfDeathBattleDefeat(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
long instanceId = team.InstanceId;
|
||
Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
||
Log.Info(team.GetMemberName() + $"{self.battleType}失败了!");
|
||
UnitScene unitScene = unit.GetComponent<UnitScene>();
|
||
int mapId = unitScene.MapId;
|
||
|
||
LinkedList<Unit> teamList = team.GetUnits();
|
||
foreach (Unit u in teamList)
|
||
{
|
||
PlayerData _data = u.GetComponent<PlayerData>();
|
||
if (_data == null)
|
||
{
|
||
Log.Error($"data == null where id = {u?.Id}");
|
||
continue;
|
||
}
|
||
|
||
_data.journeyOfDeathCount--;
|
||
}
|
||
|
||
await TimerComponent.Instance.WaitAsync(5000L);
|
||
foreach (Unit unit1 in team.GetUnits())
|
||
{
|
||
MessageHelper.SendActor(unit1, new M2C_BattleDefeat { BattleType = (int) self.battleType });
|
||
}
|
||
|
||
await TimerComponent.Instance.WaitAsync(500L);
|
||
if (MapHelper.GetMapType(mapId / 100) == UnitSceneType.JourneyOfDeath)
|
||
{
|
||
if (team.InstanceId != instanceId)
|
||
{
|
||
Log.Error($"team instanceId is not same : old ={instanceId} new = {team.InstanceId}");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Log.Error($"{unit.Id.GetPlayerFormatName()} 位置错误 : {mapId}");
|
||
Game.EventSystem.Publish(new BackMainCity() { unit = unit, isForce = true });
|
||
}
|
||
|
||
await BattleHelper.DefeatOption(self, team);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
|
||
return null;
|
||
}
|
||
}
|
||
} |