yyl
2025-09-04 cdf7098c937c5f4a70383ef70897bf9fedbb3d99
Main/Core/NetworkPackage/CustomServerPack/CustomHB426CombinePack.cs
@@ -31,8 +31,6 @@
        }
        endTag = _endTag;
        toIndex = _toIndex;
        packList = CombineToSkillPackFromList(guid, packList);
    }
@@ -74,66 +72,96 @@
        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>();
        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;
                }
                else
                //  找到对应的开始标签
                if (combinePack.IsEndPack(tag))
                {
                    if (combinePack.IsEndPack(tag))
                    combinePack.SetHB426End(i, tag);
                    continue;
                }
                Debug.LogError("No matching start tag or end tag found: " + tag.Tag);
                continue;
            }
            else
            {
                indexDict.Add(i, pack);
            }
        }
        //  嵌套包内的包合并
        foreach (var combinePack in combineDict.Values)
        {
            for (int i = combinePack.fromIndex + 1; i < combinePack.toIndex; i++)
            {
                if (indexDict.TryGetValue(i, out var pack))
                {
                    if (pack is CustomHB426CombinePack)
                    {
                        combinePack.SetHB426End(i, tag);
                        break;
                        //  如果是嵌套的包 加入之后 调整i
                        combinePack.AddPack(pack);
                        i = (pack as CustomHB426CombinePack).toIndex;
                    }
                    else
                    {
                        combinePack.AddPack(pack);
                        indexDict.Remove(i);
                    }
                }
            }
            if (null != combinePack)
            {
                combinePack.AddPack(pack);
            }
        }
        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);
                if (pack is CustomHB426CombinePack)
                {
                    var cbpack = pack as CustomHB426CombinePack;
                    // temp += "pack type is " + pack.GetType().Name + " tag is " + cbpack.startTag.Tag + "\n";
                }
                else
                {
                    // temp += "pack type is " + pack.GetType().Name + "\n";
                }
            }
            //  把合并的技能包加进来
            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;
        }
        // Debug.LogError(temp);
        return newPackList;
    }
    public void Distribute()
@@ -151,6 +179,7 @@
        {
            battleField.PlayRecord(skillAction);
        }
    }
    public SkillRecordAction CreateSkillAction()