281 lines
11 KiB
C#
281 lines
11 KiB
C#
// using Cal;
|
|
// using Cal.DataTable;
|
|
// using System;
|
|
// using System.Collections.Generic;
|
|
//
|
|
// namespace ET
|
|
// {
|
|
// public class PersonalPvpBattleAwakeSystem : AwakeSystem<PersonalPvpBattle, Team>
|
|
// {
|
|
// public override void Awake(PersonalPvpBattle self, Team team)
|
|
// {
|
|
// self.Awake(team);
|
|
// }
|
|
// }
|
|
// public class PersonalPvpBattleUpdateSystem : UpdateSystem<PersonalPvpBattle>
|
|
// {
|
|
// public override void Update(PersonalPvpBattle self)
|
|
// {
|
|
// self.Update();
|
|
// }
|
|
// }
|
|
// public class PersonalPvpBattleDestroySystem : DestroySystem<PersonalPvpBattle>
|
|
// {
|
|
// public override void Destroy(PersonalPvpBattle self)
|
|
// {
|
|
// self.team.ChangeState(TeamState.None);
|
|
// self.targetTeam.ChangeState(TeamState.None);
|
|
// self.team = null;
|
|
// self.targetTeam = null;
|
|
// self.mineKillInfo.Dispose();
|
|
// self.targetKillInfo.Dispose();
|
|
// }
|
|
// }
|
|
// public static class PersonalPvpBattleSystem
|
|
// {
|
|
// private const int StartTime = 5 * 1000;
|
|
// public static void Awake(this PersonalPvpBattle self, Team team)
|
|
// {
|
|
// self.team = team;
|
|
// self.mineKillInfo = new MonsterKillInfo(self, team);
|
|
// self.isRunning = false;
|
|
// self.quitBattleAction = OnQuitBattle;
|
|
// }
|
|
// public static void Init(this PersonalPvpBattle self, Team targetTeam)
|
|
// {
|
|
// self.targetTeam = targetTeam;
|
|
// self.ReadyBeforeBattle();
|
|
// self.startTime = TimeHelper.ClientNow();
|
|
// }
|
|
// public static void Update(this PersonalPvpBattle self)
|
|
// {
|
|
// if (!self.isRunning) return;
|
|
// long now = TimeHelper.ClientNow();
|
|
// if (now - self.startTime < StartTime)
|
|
// return;
|
|
// CheckCanStartSkill(self, now);
|
|
// }
|
|
//
|
|
// private static void CheckCanStartSkill(PersonalPvpBattle 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.PlayerSkill(unit, now);
|
|
// }
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
// public static void ReadyBeforeBattle(this PersonalPvpBattle self)
|
|
// {
|
|
// try
|
|
// {
|
|
// Team team = self.team;
|
|
// team.ChangeState(TeamState.Fight);
|
|
// self.targetTeam.ChangeState(TeamState.Fight);
|
|
//
|
|
// self.targetKillInfo = new MonsterKillInfo(self, self.targetTeam);
|
|
// LinkedList<Unit> teamList = team.GetUnits();
|
|
//
|
|
// //!+设置每个人的状态
|
|
// foreach (Unit u in teamList)
|
|
// {
|
|
// u.GetComponent<BattleComponent>().BattleType = BattleType.PersonalPvp;
|
|
// }
|
|
// //!+设置目标/技能信息
|
|
// LinkedList<Unit> monsterTeamList = self.targetTeam.GetUnits();
|
|
// foreach (Unit u in monsterTeamList)
|
|
// {
|
|
// u.GetComponent<BattleComponent>().BattleType = BattleType.PersonalPvp;
|
|
// }
|
|
// Game.EventSystem.Publish(new EventType.BattleStart { teamList = teamList, targetTeamList = monsterTeamList, isPvp = true }).Coroutine();
|
|
// BattleHelper.SetTargets(self, teamList, monsterTeamList);
|
|
// //!+保存主怪Id
|
|
// //MainStoryMap.Instance.GetBattleInteractiveInfo(team.LeaderId).LeaderMonsterId = trialCopy.MonsterId;
|
|
// //!+创建击破信息
|
|
// int totalCount = self.targetTeam.MemberCount;
|
|
// self.mineKillInfo.Init(totalCount, OnVictory);
|
|
// int mineTotalCount = self.team.MemberCount;
|
|
// self.targetKillInfo.Init(mineTotalCount, OnVictory);
|
|
//
|
|
//
|
|
// foreach (Unit u in teamList)
|
|
// {
|
|
// ModifierContainerComponent modifierContainerComponent = u.GetComponent<ModifierContainerComponent>();
|
|
// modifierContainerComponent.AddState(ModifierStateType.禁用药水);
|
|
// }
|
|
// foreach (Unit u in monsterTeamList)
|
|
// {
|
|
// ModifierContainerComponent modifierContainerComponent = u.GetComponent<ModifierContainerComponent>();
|
|
// modifierContainerComponent.AddState(ModifierStateType.禁用药水);
|
|
// }
|
|
// Log.Info($"\n{team.GetMemberName()}开始竞技场战斗,对方队伍:\n{self.targetTeam.GetMemberName()}*************");
|
|
//
|
|
// self.SendMonsterInfo();
|
|
// self.isRunning = true;
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// BattleMgrCompnent.Instance.RemoveBattle(self);
|
|
// Log.Error(e);
|
|
// }
|
|
// }
|
|
// private static void SendMonsterInfo(this PersonalPvpBattle self)
|
|
// {
|
|
// Team team = self.team;
|
|
// Team targetTeam = self.targetTeam;
|
|
// //!同步血量
|
|
// Game.EventSystem.Publish(new EventType.ChangeAllUnitCharacter { team = team, targetTeam = targetTeam }).Coroutine();
|
|
// //!给双方通知
|
|
// M2C_SendStartPK sendProto = new M2C_SendStartPK();
|
|
// sendProto.TargetIdList.AddRange(targetTeam.GetUnitIds());
|
|
// foreach (Unit unit in team.GetUnits())
|
|
// {
|
|
// MessageHelper.SendActor(unit, sendProto);
|
|
// }
|
|
// sendProto = new M2C_SendStartPK();
|
|
// sendProto.TargetIdList.AddRange(team.GetUnitIds());
|
|
// foreach (Unit unit in targetTeam.GetUnits())
|
|
// {
|
|
// MessageHelper.SendActor(unit, sendProto);
|
|
// }
|
|
// }
|
|
// public static void ReSendMonsterInfo(this PersonalPvpBattle self,Unit unit)
|
|
// {
|
|
// Team team = self.team;
|
|
// Team targetTeam = self.targetTeam;
|
|
//
|
|
// M2C_SendStartPK sendProto = new M2C_SendStartPK();
|
|
// sendProto.TargetIdList.AddRange(targetTeam.GetUnitIds());
|
|
// sendProto.TargetIdList.AddRange(team.GetUnitIds());
|
|
// MessageHelper.SendActor(unit, sendProto);
|
|
//
|
|
// }
|
|
//
|
|
// private static void OnVictory(BattleBase self, Team team)
|
|
// {
|
|
// try
|
|
// {
|
|
// if (self == null)
|
|
// {
|
|
// Log.Error($"battle == null");
|
|
// return;
|
|
// }
|
|
// if (!self.isRunning) return;
|
|
// Execute(self.As<PersonalPvpBattle>(), team).Coroutine();
|
|
// static async ETVoid Execute(PersonalPvpBattle self, Team team)
|
|
// {
|
|
// self.isRunning = false;
|
|
//
|
|
// LinkedList<Unit> teamList = team.GetUnits();
|
|
// Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
|
|
//
|
|
//
|
|
// UnitScene unitScene = unit.GetComponent<UnitScene>();
|
|
// //!触发通关任务事件
|
|
// //BattleHelper.UpdateChangeMapTaskStateEvent(unitScene, teamList).Coroutine();
|
|
//
|
|
// await TimerComponent.Instance.WaitAsync(5000);
|
|
// foreach (Unit item in teamList)
|
|
// {
|
|
// MessageHelper.SendActor(item, new M2C_BattleVictory() { BattleType = (int)self.battleType });
|
|
// }
|
|
//
|
|
// VictoryOption(self, team).Coroutine();
|
|
// Team anotherTeam = self.GetAnotherTeam(team);
|
|
// await OnDefeat(self, anotherTeam);
|
|
//
|
|
// await PvpMap.inatance.SettleBattle(team,anotherTeam);
|
|
// BattleMgrCompnent.Instance.RemoveBattle(self);
|
|
// }
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// Log.Error(e);
|
|
// BattleMgrCompnent.Instance.RemoveBattle(self);
|
|
// }
|
|
// }
|
|
// internal static async ETTask VictoryOption(BattleBase self, Team team)
|
|
// {
|
|
// try
|
|
// {
|
|
// Log.Info($"{team.GetMemberName()} 竞技场胜利了!");
|
|
// LinkedList<Unit> teamList = team.GetUnits();
|
|
// team.ChangeState(TeamState.None);
|
|
//
|
|
//
|
|
// 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);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// Log.Error(e);
|
|
// }
|
|
//
|
|
// }
|
|
// private static async ETTask OnDefeat(PersonalPvpBattle self,Team team)
|
|
// {
|
|
// try
|
|
// {
|
|
// Log.Info($"{team.GetMemberName()} 竞技场失败了!");
|
|
// LinkedList<Unit> teamList = team.GetUnits();
|
|
// team.ChangeState(TeamState.None);
|
|
// 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);
|
|
// }
|
|
// }
|
|
// private static void OnQuitBattle(BattleBase self, Team team,long Id)
|
|
// {
|
|
// try
|
|
// {
|
|
// if (team.AddVote(Id))
|
|
// {
|
|
// Team anotherTeam = self.GetAnotherTeam(team);
|
|
// OnVictory(self, anotherTeam);
|
|
// }
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// Log.Error(e);
|
|
// BattleMgrCompnent.Instance.RemoveBattle(self);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|