From ed98029a88cd89702980ac7c40b711afddc5aeb2 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 20 十一月 2025 14:44:59 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts
---
Main/Core/NetworkPackage/CustomServerPack/CustomHB426CombinePack.cs | 349 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 318 insertions(+), 31 deletions(-)
diff --git a/Main/Core/NetworkPackage/CustomServerPack/CustomHB426CombinePack.cs b/Main/Core/NetworkPackage/CustomServerPack/CustomHB426CombinePack.cs
index beb0ffd..0a434a6 100644
--- a/Main/Core/NetworkPackage/CustomServerPack/CustomHB426CombinePack.cs
+++ b/Main/Core/NetworkPackage/CustomServerPack/CustomHB426CombinePack.cs
@@ -1,5 +1,5 @@
-
using System.Collections.Generic;
+using System.Linq;
using UnityEngine;
public class CustomHB426CombinePack : GameNetPackBasic
@@ -31,8 +31,7 @@
}
endTag = _endTag;
toIndex = _toIndex;
-
- packList = CombineToSkillPackFromList(guid, packList);
+ PrintAllPack();
}
@@ -45,6 +44,27 @@
}
fromIndex = _fromIndex;
startTag = tag;
+
+
+ }
+
+ public void PrintAllPack()
+ {
+ string temp = "CustomHB426CombinePack startTag: " + (startTag != null ? startTag.Tag : "null") +
+ " fromIndex: " + fromIndex + " toIndex: " + toIndex + " packList.Count: " + packList.Count + "\n";
+ for (int i = 0; i < packList.Count; i++)
+ {
+ var pack = packList[i];
+ if (pack is CustomHB426CombinePack b426Pack)
+ {
+ temp += " pack type is " + pack.GetType().Name + " tag is " + (b426Pack.startTag != null ? b426Pack.startTag.Tag : "null") + "\n";
+ }
+ else
+ {
+ temp += " pack type is " + pack.GetType().Name + "\n";
+ }
+ }
+ BattleDebug.LogError(temp);
}
public void AddPack(GameNetPackBasic pack)
@@ -74,68 +94,228 @@
return startTag.Tag == tag.Tag && tag.Sign == 1;
}
-
public static List<GameNetPackBasic> CombineToSkillPackFromList(string _guid, List<GameNetPackBasic> b421SeriesPackList)
{
- CustomHB426CombinePack combinePack = null;
+ Dictionary<string, CustomHB426CombinePack> combineDict = new Dictionary<string, CustomHB426CombinePack>();
+
+ Dictionary<int, GameNetPackBasic> indexDict = new Dictionary<int, GameNetPackBasic>();
+
+ Dictionary<uint, HB427_tagSCUseSkill> skillDict = new Dictionary<uint, HB427_tagSCUseSkill>();
+
for (int i = 0; i < b421SeriesPackList.Count; i++)
{
var pack = b421SeriesPackList[i];
+
if (pack is HB426_tagSCTurnFightTag)
{
var tag = pack as HB426_tagSCTurnFightTag;
- if (null == combinePack)
+ CustomHB426CombinePack combinePack;
+
+ if (!combineDict.TryGetValue(tag.Tag, out combinePack))
{
combinePack = new CustomHB426CombinePack();
combinePack.guid = _guid;
+ combineDict.Add(tag.Tag, combinePack);
+
+ indexDict.Add(i, combinePack);
+ }
+
+ if (tag.Sign == 0)
+ {
combinePack.SetHB426Start(i, tag);
continue;
}
+ // 鎵惧埌瀵瑰簲鐨勫紑濮嬫爣绛�
+ if (combinePack.IsEndPack(tag))
+ {
+ combinePack.SetHB426End(i, tag);
+ continue;
+ }
+
+ Debug.LogError("No matching start tag or end tag found: " + tag.Tag);
+ continue;
+ }
+ else
+ {
+ if (pack is HB427_tagSCUseSkill skillPack)
+ {
+ // 澶勭悊鎶�鑳戒箣闂寸殑閾炬帴鍏崇郴
+ if (skillPack.RelatedSkillID > 0)
+ {
+ // 濡傛灉鏄 HB426_tagSCTurnFightTag 鍖呰9鐨勭涓�涓妧鑳藉寘 骞朵笖鍓嶉潰娌℃湁CustomHB426CombinePack
+ // 鍒欓渶瑕佹妸CustomHB426CombinePack鍔犲叆skillPack鐨剆ubSkillCombinePackList閲�
+ // 鍚屾椂 闇�瑕佹妸indexDict閲屽垹鎺夊搴旂殑subSkillCombinePackList
+ // subSkillList鍒犳帀瀵瑰簲skillPack锛屼絾鏄痵killPack鐨刾arentSkill涓嶅彉
+
+ skillDict.TryGetValue(skillPack.RelatedSkillID, out var parentSkill);
+ if (parentSkill != null && skillPack.BattleType == 4)//4=瀛愭妧鑳�
+ {
+ parentSkill.subSkillList.Add(skillPack);
+ skillPack.parentSkill = parentSkill;
+ }
+ indexDict.Add(i, pack);
+ }
+ else
+ {
+ indexDict.Add(i, pack);
+ }
+
+ if (skillDict.ContainsKey(skillPack.SkillID))
+ {
+ skillDict[skillPack.SkillID] = skillPack;
+ }
+ else
+ {
+ skillDict.Add(skillPack.SkillID, skillPack);
+ }
+ }
else
{
- if (combinePack.IsEndPack(tag))
+ indexDict.Add(i, pack);
+ }
+ }
+ }
+
+ // 濡傛灉鏄 HB426_tagSCTurnFightTag 鍖呰9鐨勭涓�涓妧鑳藉寘 骞朵笖鍓嶉潰娌℃湁CustomHB426CombinePack
+ // 缈昏瘧涓�涓嬪氨鏄� 濡傛灉CombinePack閲岀殑涓讳綋Skill鍖� skillPack.RelatedSkillID > 0
+
+
+
+ // 宓屽鍖呭唴鐨勫寘鍚堝苟
+ foreach (var combinePack in combineDict.Values)
+ {
+ for (int i = combinePack.fromIndex + 1; i < combinePack.toIndex; i++)
+ {
+ if (indexDict.TryGetValue(i, out var pack))
+ {
+ indexDict.Remove(i);
+ combinePack.AddPack(pack);
+ if (pack is CustomHB426CombinePack cbPack)
{
- combinePack.SetHB426End(i, tag);
- break;
+ // 濡傛灉鏄祵濂楃殑鍖� 鍔犲叆涔嬪悗 璋冩暣i
+ i = cbPack.toIndex;
}
}
}
+ }
- if (null != combinePack)
+
+ for (int i = 0; i < b421SeriesPackList.Count; i++)
+ {
+ if (indexDict.TryGetValue(i, out var pack))
{
- combinePack.AddPack(pack);
+ if (pack is CustomHB426CombinePack cbPack)
+ {
+ HB427_tagSCUseSkill skillPack = cbPack.GetMainHB427SkillPack();
+
+ if (null == skillPack)
+ {
+ continue;
+ }
+
+ // 濡傛灉鏄瓙鎶�鑳�
+ if (skillPack.isSubSkill)
+ {
+ // 璁╁埆浜烘潵澶勭悊
+ continue;
+ }
+ else
+ {
+ // 澶勭悊瀛愭妧鑳�
+ if (skillPack.subSkillList.Count > 0)
+ {
+ var parentSkill = skillPack;
+ List<HB427_tagSCUseSkill> toRemoveSubSkills = new List<HB427_tagSCUseSkill>();
+ foreach (var subSkill in parentSkill.subSkillList)
+ {
+ CustomHB426CombinePack innerCBPack = null;
+ if (cbPack.IsInnerCBPackContainsSkill(subSkill, ref innerCBPack))
+ {
+ if (cbPack.GetMainHB427SkillPack() == subSkill)
+ {
+ parentSkill.subSkillList.Remove(subSkill);
+ Debug.LogError("瀛愭妧鑳戒笉鑳芥槸涓绘妧鑳�: " + subSkill.SkillID);
+ continue;
+ }
+ subSkill.parentCombinePack = innerCBPack;
+ cbPack.packList.Remove(innerCBPack);
+ toRemoveSubSkills.Add(subSkill);
+ parentSkill.subSkillCombinePackList.Add(innerCBPack);
+ indexDict.Remove(innerCBPack.fromIndex);
+ }
+ }
+ foreach (var subSkill in toRemoveSubSkills)
+ {
+ parentSkill.subSkillList.Remove(subSkill);
+ }
+ }
+ else
+ {
+ // 涓绘妧鑳芥病鏈夊瓙鎶�鑳� 鐩存帴璺宠繃
+ continue;
+ }
+ }
+ }
+ else if (pack is HB427_tagSCUseSkill skillPack)
+ {
+ // Debug.LogError("钀藉崟鐨勬妧鑳�");
+ }
}
}
List<GameNetPackBasic> newPackList = new List<GameNetPackBasic>();
- if (null != combinePack)
+ // string temp = string.Empty;
+
+ for (int i = 0; i < b421SeriesPackList.Count; i++)
{
- // 鎶�鑳藉寘鍓嶉潰鐨勫寘锛堜笉鍖呮嫭b426鐨勫紑濮嬫爣绛撅級
- for (int i = 0; i < combinePack.fromIndex; i++)
+ if (indexDict.TryGetValue(i, out var pack))
{
- newPackList.Add(b421SeriesPackList[i]);
+ newPackList.Add(pack);
}
-
- // 鎶婂悎骞剁殑鎶�鑳藉寘鍔犺繘鏉�
- newPackList.Add(combinePack);
-
- // 鎶�鑳藉寘鍚庨潰鐨勫寘锛堜笉鍖呮嫭b426鐨勭粨鏉熸爣绛撅級
- for (int i = combinePack.toIndex + 1; i < b421SeriesPackList.Count; i++)
- {
- newPackList.Add(b421SeriesPackList[i]);
- }
-
- return CombineToSkillPackFromList(_guid, newPackList);
-
- }
- else
- {
- return b421SeriesPackList;
}
+ // newPackList = BattleManager.ParseBattlePackList(_guid, newPackList);
+
+ // Debug.LogError(temp);
+
+ return newPackList;
}
+ public HB427_tagSCUseSkill GetMainHB427SkillPack()
+ {
+ for (int i = 0; i < packList.Count; i++)
+ {
+ var pack = packList[i];
+ if (pack is HB427_tagSCUseSkill skillPack)
+ {
+ return skillPack;
+ }
+ else if (pack is CustomHB426CombinePack)
+ {
+ return null;
+ }
+ }
+
+ return null;
+ }
+
+ public bool IsInnerCBPackContainsSkill(HB427_tagSCUseSkill skill, ref CustomHB426CombinePack innerCBPack)
+ {
+ for (int i = 0; i < packList.Count; i++)
+ {
+ var pack = packList[i];
+ if (pack is CustomHB426CombinePack cbPack)
+ {
+ if (cbPack.packList.Contains(skill))
+ {
+ innerCBPack = cbPack;
+ return true;
+ }
+ }
+ }
+ return false;
+ }
public void Distribute()
{
BattleField battleField = BattleManager.Instance.GetBattleField(guid);
@@ -151,6 +331,58 @@
{
battleField.PlayRecord(skillAction);
}
+ else
+ {
+ battleField.DistributeNextPackage();
+ }
+
+ }
+
+ public static SkillRecordAction CreateSkillAction(string guid, List<GameNetPackBasic> _packList)
+ {
+ BattleField battleField = BattleManager.Instance.GetBattleField(guid);
+
+ if (null == battleField)
+ {
+ Debug.LogError("BattleField not found for guid: " + guid);
+ return null;
+ }
+
+ while (_packList.Count > 0)
+ {
+ var pack = _packList[0];
+ _packList.RemoveAt(0);
+
+ if (pack is HB427_tagSCUseSkill)
+ {
+ _packList.Insert(0, pack);
+ break;
+ }
+ else if (pack is CustomHB426CombinePack)
+ {
+ Debug.LogError("鏃犳硶鎵惧埌Skill鍖咃紝鍏堝彂鐜颁簡宓屽鍖�");
+ return null;
+ }
+ else
+ {
+ // Debug.LogError("鍙戠幇闈濻kill鍖咃紝鍏堝垎鍙戞帀: " + pack.GetType().Name);
+ PackageRegedit.Distribute(pack);
+ }
+ }
+
+ HB427_tagSCUseSkill skill = _packList[0] as HB427_tagSCUseSkill;
+ _packList.RemoveAt(0);
+ if (null == skill)
+ {
+ Debug.LogError("No HB427_tagSCUseSkill found in packList.");
+ return null;
+ }
+
+ BattleObject _caster = battleField.battleObjMgr.GetBattleObject((int)skill.ObjID);
+
+ SkillRecordAction skillAction = new SkillRecordAction(battleField, _caster, skill, _packList);
+ return skillAction;
+
}
public SkillRecordAction CreateSkillAction()
@@ -163,14 +395,69 @@
return null;
}
+ // 鏈嶅姟鍣ㄤ慨鏀逛簡 鐜板湪绗竴涓笉涓�瀹氭槸B427 涔熸湁鍙兘鏄疊428 鍏堟斁Buff
+ while (packList.Count > 0)
+ {
+ var pack = packList[0];
+ packList.RemoveAt(0);
+
+ if (pack is HB427_tagSCUseSkill)
+ {
+ packList.Insert(0, pack);
+ break;
+ }
+ else if (pack is CustomHB426CombinePack)
+ {
+ Debug.LogError("鏃犳硶鎵惧埌Skill鍖咃紝鍏堝彂鐜颁簡宓屽鍖�");
+ return null;
+ }
+ else
+ {
+ // Debug.LogError("鍙戠幇闈濻kill鍖咃紝鍏堝垎鍙戞帀: " + pack.GetType().Name);
+ PackageRegedit.Distribute(pack);
+ }
+ }
+
if (startTag.Tag.StartsWith("Skill_"))
{
+ if (packList.Count <= 0)
+ {
+ Debug.LogError("No HB427_tagSCUseSkill found in packList." + startTag.Tag);
+ return null;
+ }
HB427_tagSCUseSkill skill = packList[0] as HB427_tagSCUseSkill;
+ packList.RemoveAt(0);
+ if (null == skill)
+ {
+ Debug.LogError("No HB427_tagSCUseSkill found in packList.");
+ return null;
+ }
+
BattleObject _caster = battleField.battleObjMgr.GetBattleObject((int)skill.ObjID);
+ // BattleDebug.LogError("_caster == null : " + (_caster == null) + " skill.ObjID : " + skill.ObjID);
+
SkillRecordAction skillAction = new SkillRecordAction(battleField, _caster, skill, packList);
return skillAction;
}
return null;
}
+
+#if UNITY_EDITOR
+ public static CustomHB426CombinePack CreateCustomPack(string _guid, HB427_tagSCUseSkill skill)
+ {
+ CustomHB426CombinePack pack = new CustomHB426CombinePack();
+ pack.guid = string.Empty;
+
+ pack.startTag = new HB426_tagSCTurnFightTag
+ {
+ Tag = "Skill_Start",
+ Sign = 0
+ };
+
+ pack.packList.Add(skill);
+
+ return pack;
+ }
+#endif
}
\ No newline at end of file
--
Gitblit v1.8.0