| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using LitJson; |
| | | |
| | | |
| | | |
| | | using System; |
| | | |
| | | public class BattleManager : GameSystemManager<BattleManager> |
| | | { |
| | |
| | | |
| | | protected LogicUpdate logicUpdate = new LogicUpdate(); |
| | | |
| | | public Action<string, BattleField> onBattleFieldCreate; |
| | | |
| | | public Action<string, BattleField> onBattleFieldDestroy; |
| | | |
| | | public override void Init() |
| | | { |
| | | base.Init(); |
| | | // StartStoryBattle(); |
| | | logicUpdate.Start(Run); |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | } |
| | |
| | | { |
| | | |
| | | } |
| | | |
| | | |
| | | #region 截断网络派发包 只收入当前包的后续 b425是主线的 非主线的包并不会走b425 |
| | | private bool allow = true; |
| | |
| | | List<GameNetPackBasic> packQueueSnapshot = new List<GameNetPackBasic>(packQueue); |
| | | |
| | | List<GameNetPackBasic> newPackList = new List<GameNetPackBasic>(); |
| | | HashSet<int> skipIndexes = new HashSet<int>(); |
| | | |
| | | // 这里已经是按照Dequeue的顺序了 |
| | | for (int i = 0; i < packQueueSnapshot.Count; i++) |
| | | { |
| | | if (skipIndexes.Contains(i)) continue; |
| | | |
| | | GameNetPackBasic pack = packQueueSnapshot[i]; |
| | | |
| | | // 碰到B421 截断 往下收集b421里的全部内容 |
| | |
| | | HB421_tagMCTurnFightObjAction b421Pack = pack as HB421_tagMCTurnFightObjAction; |
| | | |
| | | List<GameNetPackBasic> b421PackList = new List<GameNetPackBasic>(); |
| | | |
| | | i++; // 跳过当前的B421包 |
| | | |
| | | for (; i < packQueueSnapshot.Count; i++) |
| | |
| | | else |
| | | { |
| | | b421PackList.Add(nextPack); |
| | | skipIndexes.Add(i); // 标记已被合包 |
| | | } |
| | | } |
| | | |
| | | // 可能没用了 主要就是利用一下skill的combine 暂留 看之后还有没有别的需求 |
| | | CustomB421ActionPack actionPack = CustomB421ActionPack.CreateB421ActionPack(GetGUID(b421Pack.packUID), b421PackList); |
| | | |
| | | while (actionPack.actionPacks.Count > 0) |
| | | { |
| | | GameNetPackBasic actionPackItem = actionPack.actionPacks.Dequeue(); |
| | | newPackList.Add(actionPackItem); |
| | | } |
| | | newPackList.Add(actionPack); |
| | | } |
| | | else |
| | | { |
| | |
| | | DistributeNextPackage(); |
| | | } |
| | | |
| | | // 专属于主线战斗的派发 |
| | | public bool DistributeNextPackage() |
| | | { |
| | | if (packQueue.Count > 0) |
| | |
| | | { |
| | | CustomHB426CombinePack combinePack = pack as CustomHB426CombinePack; |
| | | combinePack.Distribute(); |
| | | } |
| | | else if (pack is CustomB421ActionPack) |
| | | { |
| | | CustomB421ActionPack actionPack = pack as CustomB421ActionPack; |
| | | actionPack.Distribute(); |
| | | } |
| | | else |
| | | { |
| | |
| | | return battleField; |
| | | } |
| | | |
| | | |
| | | |
| | | public string GetGUID(ulong packUID) |
| | | { |
| | | foreach (var kv in battlePackRelationList) |
| | |
| | | } |
| | | return string.Empty; |
| | | } |
| | | |
| | | |
| | | public void DistributeNextReportPackage(string guid) |
| | | { |
| | |
| | | |
| | | battleField = BattleFieldFactory.CreateBattleField(guid, MapID, FuncLineID, extendData, redTeamList, blueTeamList); |
| | | |
| | | onBattleFieldCreate?.Invoke(guid, battleField); |
| | | |
| | | if (string.IsNullOrEmpty(guid)) |
| | | { |
| | | storyBattleField = (StoryBattleField)battleField; |
| | |
| | | return; |
| | | } |
| | | |
| | | onBattleFieldDestroy?.Invoke(battleField.guid, battleField); |
| | | |
| | | string guid = battleField.guid; |
| | | |
| | | if (battleFields.ContainsKey(guid)) |
| | | { |
| | | battleFields.Remove(guid); |
| | | } |
| | | |
| | | |
| | | if (storyBattleField == battleField) |
| | | { |
| | | storyBattleField = null; |
| | | } |
| | | |
| | | GameObject.DestroyImmediate(battleField.battleRootNode.gameObject); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | public void Run() |
| | | { |
| | | // if (null != storyBattleField) |
| | | // { |
| | | // storyBattleField.Run(); |
| | | // } |
| | | |
| | | foreach (var battleField in battleFields) |
| | | { |
| | | battleField.Value?.Run(); |