740 lines
28 KiB
C#
740 lines
28 KiB
C#
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 class GlobalMethod
|
||
{
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{team.GetMemberName()} {self.battleType}失败了!");
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
await BattleHelper.DefeatOption(self, team);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info(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);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{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;
|
||
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);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{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);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{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);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{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);
|
||
}
|
||
}
|
||
|
||
private static async ETTask 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);
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{team.GetMemberName()} {self.battleType}失败了!");
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
await BattleHelper.DefeatOption(self, team);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{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);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{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);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{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);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask PersonalPvpBattleDefeat(object arg)
|
||
{
|
||
try
|
||
{
|
||
CopyBattleArgs copyBattleArgs = arg.As<CopyBattleArgs>();
|
||
CopyBattle self = copyBattleArgs.copyBattle;
|
||
Team team = copyBattleArgs.team;
|
||
Log.Info($"{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);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{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);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask SpaceTravelBattleVictory(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;
|
||
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.01f))
|
||
{
|
||
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);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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.Info($"{team.GetMemberName()} {self.battleType}失败了!");
|
||
|
||
await TimerComponent.Instance.WaitAsync(5500);
|
||
await BattleHelper.DefeatOption(self, team);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask ActiveStarSoulCopy(object arg)
|
||
{
|
||
try
|
||
{
|
||
ActiveArgs args = arg.As<ActiveArgs>();
|
||
var unit = args.unit;
|
||
if (!unit.IsTeamLeader)
|
||
return;
|
||
if (unit.teamState != TeamState.None)
|
||
return;
|
||
string[] param = args.param;
|
||
byte type = byte.Parse(param[0]);
|
||
byte difficulty = byte.Parse(param[1]);
|
||
int sceneId = type switch
|
||
{
|
||
1 => Sys_SceneId.Scene_StarSoulCopyA,
|
||
2 => Sys_SceneId.Scene_StarSoulCopyB,
|
||
3 => Sys_SceneId.Scene_StarSoulCopyC,
|
||
4 => Sys_SceneId.Scene_StarSoulCopyD,
|
||
5 => Sys_SceneId.Scene_StarSoulCopyE,
|
||
_ => throw new ArgumentOutOfRangeException()
|
||
};
|
||
var config = unit.GetOrAddComponent<StarSoulCopyConfigComponent>();
|
||
config.type = type;
|
||
config.difficulty = difficulty;
|
||
Game.EventSystem.Publish(new ChangeMap() { unit = unit, mapId = sceneId * 100 + 1 });
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
}
|
||
[DataTableMethod]
|
||
public static async ETTask ActiveWorldBossCopy(object arg)
|
||
{
|
||
try
|
||
{
|
||
ActiveArgs args = arg.As<ActiveArgs>();
|
||
var unit = args.unit;
|
||
if (!unit.IsTeamLeader)
|
||
return;
|
||
if (unit.teamState != TeamState.None)
|
||
return;
|
||
Game.EventSystem.Publish(new ChangeMap() { unit = unit, mapId = Sys_SceneId.Scene_WorldBoss * 100 + 1 });
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask ActiveIdleBattle(object arg)
|
||
{
|
||
try
|
||
{
|
||
Log.Info("ActiveIdleBattle");
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Log.Error(e);
|
||
}
|
||
}
|
||
|
||
[DataTableMethod]
|
||
public static async ETTask 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);
|
||
}
|
||
}
|
||
[DataTableMethod]
|
||
public static async ETTask 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);
|
||
}
|
||
}
|
||
[DataTableMethod]
|
||
public static async ETTask 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);
|
||
}
|
||
}
|
||
}
|
||
} |