// using Cal.DataTable; // using System; // using System.Collections.Generic; // // namespace ET // { // public class MainStoryBattleAwakeSystem : AwakeSystem // { // public override void Awake(MainStoryBattle self, Team team) // { // self.Awake(team); // } // } // public class MainStoryBattleUpdateSystem : UpdateSystem // { // public override void Update(MainStoryBattle self) // { // self.Update(); // } // } // public class MainStoryBattleDestroySystem : DestroySystem // { // public override void Destroy(MainStoryBattle self) // { // self.team.ChangeState(TeamState.None); // self.targetTeam.ChangeState(TeamState.None); // self.team = null; // if (self.targetTeam != null) // foreach (Unit item in self.targetTeam.GetUnits()) // { // try // { // item.GetMap().Leave(item); // // item.Dispose(); // } // catch (Exception e) // { // Log.Error(e); // } // } // self.targetTeam?.Dispose(); // self.targetTeam = null; // self.mainStory = null; // self.mineKillInfo.Dispose(); // self.targetKillInfo.Dispose(); // } // } // public static class MainStoryBattleSystem // { // private const int StartTime = 5 * 1000; // //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 }; // public static void Awake(this MainStoryBattle self, Team team) // { // self.team = team; // self.mineKillInfo = new MonsterKillInfo(self, team); // self.isRunning = false; // self.quitBattleAction = OnQuitBattle; // } // // public static void Init(this MainStoryBattle self, MainStory mainStory) // { // self.mainStory = mainStory; // self.ReadyBeforeBattle(); // self.startTime = TimeHelper.ClientNow(); // } // public static void Update(this MainStoryBattle self) // { // if (!self.isRunning) return; // long now = TimeHelper.ClientNow(); // if (now - self.startTime < StartTime) // return; // if (now - self.startTime > ConstDefine.MainStoryBattleTime) // { // Team anotherTeam = self.GetAnotherTeam(self.team); // BattleHelper.OnTargetVictory(self, anotherTeam); // return; // } // CheckCanStartSkill(self, now); // } // // private static void CheckCanStartSkill(MainStoryBattle self, long now) // { // foreach (Unit unit in self.team.GetUnits()) // { // if (!unit.IsAlive) continue; // if (unit.GetComponent().CheckCD(now)) // { // BattleHelper.PlayerSkill(unit, now); // } // } // foreach (Unit unit in self.targetTeam.GetUnits()) // { // if (!unit.IsAlive) continue; // if (unit.GetComponent().CheckCD(now)) // { // BattleHelper.MonsterSkill(unit); // } // } // // } // // public static void ReadyBeforeBattle(this MainStoryBattle self) // { // try // { // Team team = self.team; // MainStory mainStory = self.mainStory; // if (mainStory == null) // { // BattleMgrCompnent.Instance.RemoveBattle(self); // return; // } // team.ChangeState(TeamState.Fight); // LinkedList teamList = team.GetUnits(); // MonsterBase monsterBase = MonsterFactoryHelper.MainstoryGenerate(self, mainStory); // // self.targetKillInfo = new MonsterKillInfo(self, self.targetTeam); // Unit leader = team.GetLeader(); // //!+设置每个人的状态 // foreach (Unit u in teamList) // { // u.GetComponent().BattleType = BattleType.MainStory; // PlayerData playerData = u.GetComponent(); // if (leader.isAI && ( !playerData.HasMainstoryAITime()&&!playerData.HasMainstoryVIPAITime())) // { // continue; // } // NumericComponent component = u.GetComponent(); // int num = component.GetAsInt(NumericType.Energy); // if (num > 0) // { // int num2 = num; // switch (monsterBase.MonsterType) // { // case 0: // throw new Exception("怪物类型错误"); // case 1: // num -= 3; // break; // case 2: // num -= 3; // break; // case 3: // num--; // break; // } // component.Set(NumericType.Energy, num); // StatisticsHelper.AddEnergyCost(u.Id, "EnergyCostType_MainStory", num2 - num); // } // } // self.SendMonsterInfo(); // //!+设置目标/技能信息 // LinkedList monsterTeamList = self.targetTeam.GetUnits(); // Game.EventSystem.Publish(new EventType.BattleStart { teamList = teamList, targetTeamList = monsterTeamList }).Coroutine(); // foreach (Unit item in monsterTeamList) // { // CharacterHelper.SyncNumeric(item); // CharacterHelper.RecoverUnit(item); // } // BattleHelper.SetTargets(self, teamList, monsterTeamList); // //!+保存主怪Id // MainStoryMap.Instance.GetBattleInteractiveInfo(team.LeaderId).LeaderMonsterId = mainStory.Monster_1Arr[0].Monster_1_Id; // //!+创建怪物击破信息 // self.mineKillInfo.Init(self.targetTeam.MemberCount, OnVictory); // self.targetKillInfo.Init(self.team.MemberCount, BattleHelper.OnTargetVictory); // Log.Info($"\n{team.GetMemberName()}开始主线战斗,[{mainStory.SceneId}][{mainStory.Layer}]*************"); // // // self.isRunning = true; // } // catch (Exception e) // { // BattleMgrCompnent.Instance.RemoveBattle(self); // Log.Error(e); // } // } // // private static void SendMonsterInfo(this MainStoryBattle self) // { // M2C_MainStoryMonsterInfo m2C_MainStoryMonsterInfo = new M2C_MainStoryMonsterInfo(); // foreach (Unit unitMonster in self.targetTeam.GetUnits()) // { // //!给玩家返回怪物信息 // MonsterUnitInfo retUnitInfo = new MonsterUnitInfo() // { // Id = unitMonster.Id, // MonsterId = unitMonster.GetComponent().monsterId // }; // // m2C_MainStoryMonsterInfo.MonsterUnitInfoList.Add(retUnitInfo); // } // foreach (Unit u in self.team.GetUnits()) // { // MessageHelper.SendActor(u, m2C_MainStoryMonsterInfo); // } // } // public static void ReSendMonsterInfo(this MainStoryBattle self, Unit unit) // { // M2C_ReMainStoryMonsterInfo m2C_MainStoryMonsterInfo = new(); // foreach (Unit unitMonster in self.targetTeam.GetUnits()) // { // //!给玩家返回怪物信息 // NumericComponent num = unitMonster.GetComponent(); // ReMonsterUnitInfo retUnitInfo = new() // { // Id = unitMonster.Id, // MonsterId = unitMonster.GetComponent().monsterId, // Hp = num.GetAsInt(NumericType.Hp), // MaxHp = num.GetAsInt(NumericType.MaxHp), // }; // // m2C_MainStoryMonsterInfo.MonsterUnitInfoList.Add(retUnitInfo); // } // MessageHelper.SendActor(unit, m2C_MainStoryMonsterInfo); // } // public static void Victory(this MainStoryBattle self, Unit unit) // { // Team team = TeamComponent.Instance.Get(unit.TeamLeaderId); // OnVictory(self, team); // } // // private static void OnVictory(BattleBase self, Team team) // { // try // { // if (self == null) // { // Log.Error($"battle == null"); // return; // } // if (!self.isRunning) return; // Execute(self.As(), team).Coroutine(); // static async ETVoid Execute(MainStoryBattle self, Team team) // { // self.isRunning = false; // // LinkedList teamList = team.GetUnits(); // Unit unit = MapUnitComponent.Instance.Get(team.LeaderId); // // Log.Info($"{team.GetMemberName()}主线胜利了!"); // // UnitScene unitScene = unit.GetComponent(); // //!触发通关任务事件 // BattleHelper.UpdateChangeMapTaskStateEvent(unitScene, teamList).Coroutine(); // // // if (unitScene.MapId % 100 == 10) // { // int mapId = unitScene.MapId; // 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(); // 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 = unitScene.MapId }); // } // } // await BattleHelper.VictoryOption(self, team, self.mainStory.Id); // // Team anotherTeam = self.GetAnotherTeam(team); // BattleHelper.EnermyClearOption(self, anotherTeam); // // BattleMgrCompnent.Instance.RemoveBattle(self); // } // } // catch (Exception e) // { // Log.Error(e); // BattleMgrCompnent.Instance.RemoveBattle(self); // } // } // // private static void OnQuitBattle(BattleBase self, Team team,long Id) // { // try // { // if (team.AddVote(Id)) // { // Team anotherTeam = self.GetAnotherTeam(team); // BattleHelper.OnTargetVictory(self, anotherTeam); // } // } // catch (Exception e) // { // Log.Error(e); // BattleMgrCompnent.Instance.RemoveBattle(self); // } // } // } // }