CTT/Server/Hotfix/Game/System/Battle/New/PKBattleSystem.cs

222 lines
8.6 KiB
C#
Executable File
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// using Cal.DataTable;
// using System;
// using System.Collections.Generic;
//
// namespace ET
// {
// public class PKBattleAwakeSystem : AwakeSystem<PKBattle, Team>
// {
// public override void Awake(PKBattle self, Team team)
// {
// self.Awake(team);
// }
// }
// public class PKBattleUpdateSystem : UpdateSystem<PKBattle>
// {
// public override void Update(PKBattle self)
// {
// self.Update();
// }
// }
// public class PKBattleDestroySystem : DestroySystem<PKBattle>
// {
// public override void Destroy(PKBattle 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 PKBattleSystem
// {
// 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 PKBattle self, Team team)
// {
// self.team = team;
// self.mineKillInfo = new MonsterKillInfo(self, team);
// self.isRunning = false;
// self.quitBattleAction = OnQuitBattle;
// }
// public static void Init(this PKBattle self, Team targetTeam)
// {
// self.targetTeam = targetTeam;
// self.ReadyBeforeBattle();
// self.startTime = TimeHelper.ClientNow();
// }
// public static void Update(this PKBattle self)
// {
// if (!self.isRunning) return;
// long now = TimeHelper.ClientNow();
// if (now - self.startTime < StartTime)
// return;
// CheckCanStartSkill(self, now);
// }
//
// private static void CheckCanStartSkill(PKBattle 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 PKBattle 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.TrialCopy;
// }
// //!+设置目标/技能信息
// LinkedList<Unit> monsterTeamList = self.targetTeam.GetUnits();
// foreach (Unit u in monsterTeamList)
// {
// u.GetComponent<BattleComponent>().BattleType = BattleType.TrialCopy;
// }
// 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);
//
//
// Log.Info($"\n{team.GetMemberName()}开始PK战斗对方队伍:\n{self.targetTeam.GetMemberName()}*************");
//
// self.SendMonsterInfo();
// self.isRunning = true;
// }
// catch (Exception e)
// {
// BattleMgrCompnent.Instance.RemoveBattle(self);
// Log.Error(e);
// }
// }
// private static void SendMonsterInfo(this PKBattle 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 PKBattle 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<PKBattle>(), team).Coroutine();
// static async ETVoid Execute(PKBattle self, Team team)
// {
// self.isRunning = false;
//
// LinkedList<Unit> teamList = team.GetUnits();
// Unit unit = MapUnitComponent.Instance.Get(team.LeaderId);
//
// Log.Info($"{team.GetMemberName()} PK胜利了");
//
// 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 });
// }
//
// BattleHelper.VictoryOption(self, team).Coroutine();
//
// 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)
// {
// try
// {
// if (team.AddVote(Id))
// {
// Team anotherTeam = self.GetAnotherTeam(team);
// OnVictory(self, anotherTeam);
// }
// }
// catch (Exception e)
// {
// Log.Error(e);
// BattleMgrCompnent.Instance.RemoveBattle(self);
// }
// }
//
//
// }
// }