| | |
| | | // 同时只能有一场战斗在进行 guid, battlefield |
| | | protected Dictionary<string, BattleField> battleFields = new Dictionary<string, BattleField>(); |
| | | |
| | | public float[] speedGear; //战斗倍数对应的实际速率 |
| | | public int speedIndex |
| | | { |
| | | get |
| | | { |
| | | return QuickSetting.Instance.GetQuickSettingValue<int>(QuickSettingType.BattleSpeed, 0); |
| | | } |
| | | set |
| | | { |
| | | QuickSetting.Instance.SetQuickSetting(QuickSettingType.BattleSpeed, value); |
| | | QuickSetting.Instance.SendPackage(); |
| | | } |
| | | } |
| | | |
| | | public Action<string, BattleField> onBattleFieldCreate; |
| | | |
| | |
| | | LogicEngine.Instance.OnUpdate += Run; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerInit; |
| | | ParseConfig(); |
| | | |
| | | } |
| | | |
| | | void ParseConfig() |
| | | { |
| | | var config = FuncConfigConfig.Get("AutoGuaji"); |
| | | speedGear = JsonMapper.ToObject<float[]>(config.Numerical4); |
| | | } |
| | | |
| | | |
| | | public override void Release() |
| | | { |
| | |
| | | List<GameNetPackBasic> packQueueSnapshot = new List<GameNetPackBasic>(packQueue); |
| | | |
| | | List<GameNetPackBasic> newPackList = ParseBattlePackList(string.Empty, packQueueSnapshot); |
| | | |
| | | Action printNewPack = () => |
| | | { |
| | | string temp = "After AnalysisPackQueueAndDistribute newPackList count: " + newPackList.Count + "\n"; |
| | | foreach (var pack in newPackList) |
| | | { |
| | | if (pack is CustomHB426CombinePack b426Pack) |
| | | { |
| | | temp += " pack type is " + pack.GetType().Name + " tag is " + (b426Pack.startTag != null ? b426Pack.startTag.Tag : "null") + "\n"; |
| | | } |
| | | else if (pack is CustomB421ActionPack b421Pack) |
| | | { |
| | | temp += " pack type is " + pack.GetType().Name + " guid is " + b421Pack.guid + "\n"; |
| | | } |
| | | else |
| | | { |
| | | temp += " pack type is " + pack.GetType().Name + "\n"; |
| | | } |
| | | } |
| | | Debug.LogWarning(temp); |
| | | }; |
| | | |
| | | printNewPack(); |
| | | |
| | | // HashSet<int> skipIndexes = new HashSet<int>(); |
| | | |
| | | // // 这里已经是按照Dequeue的顺序了 |
| | |
| | | |
| | | public static List<GameNetPackBasic> ParseBattlePackList(string guid, List<GameNetPackBasic> packQueueSnapshot) |
| | | { |
| | | bool wrong = false; |
| | | |
| | | List<GameNetPackBasic> newPackList = new List<GameNetPackBasic>(); |
| | | |
| | | HB421_tagMCTurnFightObjAction b421Pack = null; |
| | | |
| | | for (int i = 0; i < packQueueSnapshot.Count; i++) |
| | | var list = CustomHB426CombinePack.CombineToSkillPackFromList(guid, packQueueSnapshot); |
| | | string str = "ParseBattlePackList \n"; |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | GameNetPackBasic pack = packQueueSnapshot[i]; |
| | | if (null == b421Pack) |
| | | { |
| | | if (pack is HB421_tagMCTurnFightObjAction _b421) |
| | | { |
| | | b421Pack = _b421; |
| | | } |
| | | else |
| | | { |
| | | newPackList.Add(pack); |
| | | } |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | List<GameNetPackBasic> b421List = new List<GameNetPackBasic>(); |
| | | |
| | | bool find = false; |
| | | |
| | | for (int k = i; k < packQueueSnapshot.Count; k++/*, Debug.LogError(k + " : is plusing")*/) |
| | | { |
| | | GameNetPackBasic maybeB426Pack = packQueueSnapshot[k]; |
| | | |
| | | if (maybeB426Pack is HB426_tagSCTurnFightTag b426Pack) |
| | | { |
| | | // Debug.LogError(k + " : find b426 " + maybeB426Pack.packUID + " sign " + b426Pack.Sign + " tag " + b426Pack.Tag); |
| | | if (b426Pack.Sign == 0) |
| | | { |
| | | find = true; |
| | | List<GameNetPackBasic> b426List = new List<GameNetPackBasic>(); |
| | | b426List.Add(b426Pack); |
| | | for (int j = k + 1; j < packQueueSnapshot.Count; j++) |
| | | { |
| | | GameNetPackBasic maybeB426EndPack = packQueueSnapshot[j]; |
| | | if (maybeB426EndPack is HB426_tagSCTurnFightTag b426EndPack) |
| | | { |
| | | // Debug.LogError(j + " : find b426 end pack : " + b426EndPack.packUID + " sign " + b426EndPack.Sign + " tag " + b426EndPack.Tag); |
| | | |
| | | if (b426EndPack.Tag == b426Pack.Tag) |
| | | { |
| | | if (b426EndPack.Sign == 1) |
| | | { |
| | | b426List.Add(maybeB426EndPack); |
| | | k = j; |
| | | i = k; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError("错误的Sign == 1"); |
| | | continue; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // 新的一对 |
| | | } |
| | | } |
| | | else |
| | | { |
| | | b426List.Add(maybeB426EndPack); |
| | | k = j; |
| | | i = k; |
| | | } |
| | | } |
| | | // 这里面的b421还没处理 |
| | | List<GameNetPackBasic> combinedList = CustomHB426CombinePack.CombineToSkillPackFromList(guid, b426List); |
| | | b421List.AddRange(combinedList); |
| | | } |
| | | else |
| | | { |
| | | wrong = true; |
| | | Debug.LogError("错误的b426 分析有问题 " + b426Pack.packUID); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!find) |
| | | { |
| | | newPackList.Add(maybeB426Pack); |
| | | i = k; |
| | | } |
| | | else |
| | | { |
| | | if (maybeB426Pack is HB421_tagMCTurnFightObjAction _b421) |
| | | { |
| | | i = k - 1; |
| | | break; |
| | | } |
| | | |
| | | b421List.Add(maybeB426Pack); |
| | | i = k; |
| | | } |
| | | } |
| | | } |
| | | CustomB421ActionPack actionPack = CustomB421ActionPack.CreateB421ActionPack(guid, b421List); |
| | | newPackList.Add(actionPack); |
| | | b421Pack = null; |
| | | } |
| | | str += " " + list[i].GetType().Name + "\n"; |
| | | } |
| | | // BattleDebug.LogError(str); |
| | | return list; |
| | | |
| | | if (wrong) |
| | | { |
| | | string output = string.Empty; |
| | | for (int f = 0; f < packQueueSnapshot.Count; f++) |
| | | { |
| | | output += (packQueueSnapshot[f].packUID + "&" + packQueueSnapshot[f].GetType().ToString() + "|"); |
| | | } |
| | | |
| | | Debug.LogError(output); |
| | | } |
| | | |
| | | return newPackList; |
| | | } |
| | | |
| | | // 专属于主线战斗的派发 |
| | |
| | | { |
| | | uidList.Add(packUID); |
| | | } |
| | | |
| | | } |
| | | |
| | | public BattleField GetBattleField(ulong packUID) |
| | | { |
| | | return GetBattleField(GetGUID(packUID)); |
| | | string guid = GetGUID(packUID); |
| | | BattleField battleField = GetBattleField(GetGUID(packUID)); |
| | | if (battleField == null || battleField.rejectNewPackage) |
| | | { |
| | | return null; |
| | | } |
| | | return battleField; |
| | | } |
| | | |
| | | public BattleField GetBattleField(string guid) |
| | |
| | | return; |
| | | } |
| | | |
| | | if (queue.Count <= 0) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var pack = queue.Dequeue(); |
| | | |
| | | // Debug.LogError("DistributeNextReportPackage for guid : " + guid + " pack type : " + pack.GetType()); |
| | |
| | | catch (Exception ex) |
| | | { |
| | | Debug.LogError("DistributeNextPackage: 分发包异常 " + ex); |
| | | // 出错时主动移除当前包,防止死循环 |
| | | if (packQueue.Count > 0) |
| | | { |
| | | packQueue.Dequeue(); |
| | | } |
| | | } |
| | | |
| | | if (queue.Count <= 0) |
| | | { |
| | | battleReportDict.Remove(guid); |
| | | battlePackRelationList.Remove(guid); |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | |
| | |
| | | // 4-继续战斗 - 玩家主线战斗中(包含主线小怪、主线boss),前端表现完后端同步的战斗片段后,可再回复该值,后端会根据战斗逻辑及流程自动回复下一段的战斗片段封包,一直循环 |
| | | public void MainFightRequest(byte reqType, uint reqValue = 0) |
| | | { |
| | | // Debug.LogError("MainFightRequest reqType " + reqType + " reqValue " + reqValue); |
| | | CB413_tagCSMainFightReq req = new CB413_tagCSMainFightReq(); |
| | | req.ReqType = reqType; |
| | | req.ReqValue = reqValue; |