297 lines
12 KiB
C#
297 lines
12 KiB
C#
// using Cal.DataTable;
|
|
// using System;
|
|
// using System.Collections.Generic;
|
|
//
|
|
// namespace ET
|
|
// {
|
|
// public class IdleBattleAwakeSystem : AwakeSystem<IdleBattle, Team>
|
|
// {
|
|
// public override void Awake(IdleBattle self, Team team)
|
|
// {
|
|
// self.Awake(team);
|
|
// }
|
|
// }
|
|
// public class IdleBattleUpdateSystem : UpdateSystem<IdleBattle>
|
|
// {
|
|
// public override void Update(IdleBattle self)
|
|
// {
|
|
// self.Update();
|
|
// }
|
|
// }
|
|
// public class IdleBattleDestroySystem : DestroySystem<IdleBattle>
|
|
// {
|
|
// public override void Destroy(IdleBattle self)
|
|
// {
|
|
// self.team.ChangeState(TeamState.None);
|
|
// self.targetTeam.ChangeState(TeamState.None);
|
|
// self.team = null;
|
|
// foreach (Unit item in self.targetTeam.GetUnits())
|
|
// {
|
|
// item.GetMap().Leave(item);
|
|
//
|
|
// item.Dispose();
|
|
// }
|
|
// self.targetTeam.Dispose();
|
|
// self.targetTeam = null;
|
|
// self.mainStory = null;
|
|
// self.mineKillInfo.Dispose();
|
|
// self.targetKillInfo.Dispose();
|
|
// }
|
|
// }
|
|
// public static class IdleBattleSystem
|
|
// {
|
|
// private const int StartTime = 5 * 1000;
|
|
//
|
|
// public static void Awake(this IdleBattle self, Team team)
|
|
// {
|
|
// self.team = team;
|
|
// self.mineKillInfo = new MonsterKillInfo(self, team);
|
|
// self.isRunning = false;
|
|
// self.quitBattleAction = OnQuitBattle;
|
|
// }
|
|
// public static void Init(this IdleBattle self, MainStory mainStory)
|
|
// {
|
|
// self.mainStory = mainStory;
|
|
// self.ReadyBeforeBattle();
|
|
// long now = TimeHelper.ClientNow();
|
|
// self.startTime = now;
|
|
// }
|
|
// public static void Update(this IdleBattle 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);
|
|
// OnTargetVictory(self, anotherTeam);
|
|
// return;
|
|
// }
|
|
// CheckCanStartSkill(self, now);
|
|
// }
|
|
// private static void CheckCanStartSkill(IdleBattle self, long now)
|
|
// {
|
|
// foreach (Unit unit in self.team.GetUnits())
|
|
// {
|
|
// if (!unit.IsAlive) continue;
|
|
// if (unit.GetComponent<SkillAI>().CheckCD(now))
|
|
// {
|
|
// BattleHelper.PlayerSkill(unit, now);
|
|
// }
|
|
// }
|
|
// foreach (Unit unit in self.targetTeam.GetUnits())
|
|
// {
|
|
// if (!unit.IsAlive) continue;
|
|
// if (unit.GetComponent<SkillAI>().CheckCD(now))
|
|
// {
|
|
// BattleHelper.MonsterSkill(unit);
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// public static void ReadyBeforeBattle(this IdleBattle self)
|
|
// {
|
|
// try
|
|
// {
|
|
// Team team = self.team;
|
|
// MainStory mainStory = self.mainStory;
|
|
// if (mainStory == null)
|
|
// {
|
|
// BattleMgrCompnent.Instance.RemoveBattle(self);
|
|
// return;
|
|
// }
|
|
// team.ChangeState(TeamState.Fight);
|
|
// LinkedList<Unit> teamList = team.GetUnits();
|
|
//
|
|
// MonsterBase monsterBase = MonsterFactoryHelper.MainstoryGenerate(self, mainStory);
|
|
//
|
|
// self.targetKillInfo = new MonsterKillInfo(self, self.targetTeam);
|
|
// //!+设置每个人的状态/行动值
|
|
// foreach (Unit u in teamList)
|
|
// {
|
|
// u.GetComponent<BattleComponent>().BattleType = BattleType.IdleBattle;
|
|
//
|
|
// NumericComponent num = u.GetComponent<NumericComponent>();
|
|
// int energy = num.GetAsInt(NumericType.Energy);
|
|
// if (energy > 0)
|
|
// {
|
|
// int oldEnergy = energy;
|
|
// switch ((MonsterType)monsterBase.MonsterType)
|
|
// {
|
|
// case MonsterType.None:
|
|
// throw new Exception("怪物类型错误");
|
|
// case MonsterType.Normal:
|
|
// energy -= 3;
|
|
// break;
|
|
// case MonsterType.Elite:
|
|
// energy -= 3;
|
|
// break;
|
|
// case MonsterType.Suzerain:
|
|
// energy -= 1;
|
|
// break;
|
|
// default:
|
|
// break;
|
|
// }
|
|
//
|
|
// num.Set(NumericType.Energy, energy);
|
|
// StatisticsHelper.AddEnergyCost(u.Id, StatisticsTypes.EnergyCostType_IdleBattle,oldEnergy-energy);
|
|
// }
|
|
// }
|
|
// //!+设置目标/技能信息
|
|
// LinkedList<Unit> 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, OnTargetVictory);
|
|
// Log.Info($"\n{team.GetMemberName()}开始挂机战斗,[{mainStory.SceneId}][{mainStory.Layer}]*************");
|
|
//
|
|
//
|
|
// self.SendMonsterInfo();
|
|
// self.isRunning = true;
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// BattleMgrCompnent.Instance.RemoveBattle(self);
|
|
// Log.Error(e);
|
|
// }
|
|
// }
|
|
//
|
|
//
|
|
// private static void SendMonsterInfo(this IdleBattle 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<MonsterInfo>().monsterId
|
|
// };
|
|
//
|
|
// m2C_MainStoryMonsterInfo.MonsterUnitInfoList.Add(retUnitInfo);
|
|
// }
|
|
// foreach (Unit u in self.team.GetUnits())
|
|
// {
|
|
// MessageHelper.SendActor(u, m2C_MainStoryMonsterInfo);
|
|
// }
|
|
// }
|
|
// public static void ReSendMonsterInfo(this IdleBattle self, Unit unit)
|
|
// {
|
|
// M2C_ReMainStoryMonsterInfo m2C_MainStoryMonsterInfo = new M2C_ReMainStoryMonsterInfo();
|
|
// foreach (Unit unitMonster in self.targetTeam.GetUnits())
|
|
// {
|
|
// //!给玩家返回怪物信息
|
|
// NumericComponent num = unitMonster.GetComponent<NumericComponent>();
|
|
// ReMonsterUnitInfo retUnitInfo = new ReMonsterUnitInfo()
|
|
// {
|
|
// Id = unitMonster.Id,
|
|
// MonsterId = unitMonster.GetComponent<MonsterInfo>().monsterId,
|
|
// Hp = num.GetAsInt(NumericType.Hp),
|
|
// MaxHp = num.GetAsInt(NumericType.MaxHp),
|
|
// };
|
|
//
|
|
// m2C_MainStoryMonsterInfo.MonsterUnitInfoList.Add(retUnitInfo);
|
|
// }
|
|
// MessageHelper.SendActor(unit, m2C_MainStoryMonsterInfo);
|
|
// }
|
|
//
|
|
// private static void OnVictory(BattleBase self, Team team)
|
|
// {
|
|
// try
|
|
// {
|
|
// if (self == null)
|
|
// {
|
|
// Log.Error($"battle == null");
|
|
// return;
|
|
// }
|
|
// if (!self.isRunning) return;
|
|
// Execute(self.As<IdleBattle>(), team).Coroutine();
|
|
// static async ETVoid Execute(IdleBattle self, Team team)
|
|
// {
|
|
// self.isRunning = false;
|
|
//
|
|
// LinkedList<Unit> teamList = team.GetUnits();
|
|
// Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
|
//
|
|
// Log.Info($"{team.GetMemberName()}挂机战斗胜利了!");
|
|
//
|
|
// UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
// //!触发通关任务事件
|
|
// BattleHelper.UpdateChangeMapTaskStateEvent(unitScene, teamList).Coroutine();
|
|
//
|
|
// 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.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);
|
|
// }
|
|
// }
|
|
// public static void OnTargetVictory(this BattleBase self, Team team)
|
|
// {
|
|
// try
|
|
// {
|
|
// if (self == null)
|
|
// {
|
|
// Log.Error($"battle == null");
|
|
// return;
|
|
// }
|
|
// if (!self.isRunning) return;
|
|
// Execute(self.As<IdleBattle>(), team).Coroutine();
|
|
// static async ETVoid Execute(IdleBattle self, Team team)
|
|
// {
|
|
// self.isRunning = false;
|
|
//
|
|
// LinkedList<Unit> teamList = team.GetUnits();
|
|
// await TimerComponent.Instance.WaitAsync(5500);
|
|
//
|
|
// BattleHelper.EnermyClearOption(self, team);
|
|
//
|
|
// Team anotherTeam = self.GetAnotherTeam(team);
|
|
// await self.OnDefeat(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)
|
|
// {
|
|
// if (team.AddVote(Id))
|
|
// {
|
|
// Team anotherTeam = self.GetAnotherTeam(team);
|
|
// OnTargetVictory(self, anotherTeam);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|