|   | 
| using System.Collections.Generic; | 
| using UnityEngine; | 
|   | 
| public class CustomHB426CombinePack : GameNetPackBasic | 
| { | 
|   | 
|     public HB426_tagSCTurnFightTag startTag; | 
|   | 
|     public HB426_tagSCTurnFightTag endTag; | 
|   | 
|     public int fromIndex; | 
|   | 
|     public int toIndex; | 
|   | 
|     public string guid; | 
|   | 
|     public List<GameNetPackBasic> packList = new List<GameNetPackBasic>(); | 
|   | 
|     public override void ReadFromBytes(byte[] vBytes) | 
|     { | 
|         base.ReadFromBytes(vBytes); | 
|     } | 
|   | 
|     public void SetHB426End(int _toIndex, HB426_tagSCTurnFightTag _endTag) | 
|     { | 
|         if (endTag.Sign != 1) | 
|         { | 
|             Debug.LogError("HB426_tagSCTurnFightTag Sign must be 1 for end tag, but got: " + endTag.Sign); | 
|             return; | 
|         } | 
|         endTag = _endTag; | 
|   | 
|         packList = CombineToSkillPackFromList(guid, packList); | 
|     } | 
|   | 
|   | 
|     public void SetHB426Start(int _fromIndex, HB426_tagSCTurnFightTag tag) | 
|     { | 
|         if (tag.Sign != 0) | 
|         { | 
|             Debug.LogError("HB426_tagSCTurnFightTag Sign must be 0 for start tag, but got: " + tag.Sign); | 
|             return; | 
|         } | 
|         fromIndex = _fromIndex; | 
|         startTag = tag; | 
|     } | 
|   | 
|     public void AddPack(GameNetPackBasic pack) | 
|     { | 
|         if (startTag == null) | 
|         { | 
|             Debug.LogError("startTag is null, please set it first."); | 
|             return; | 
|         } | 
|   | 
|         packList.Add(pack); | 
|     } | 
|   | 
|     public bool IsEndPack(HB426_tagSCTurnFightTag tag) | 
|     { | 
|         if (endTag == null) | 
|         { | 
|             Debug.LogError("endTag is null, please set it first."); | 
|             return false; | 
|         } | 
|   | 
|         return endTag.Tag == tag.Tag && endTag.Sign == 1; | 
|     } | 
|   | 
|   | 
|     public static List<GameNetPackBasic> CombineToSkillPackFromList(string _guid, List<GameNetPackBasic> b421SeriesPackList) | 
|     { | 
|         CustomHB426CombinePack combinePack = null; | 
|         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) | 
|                 { | 
|                     combinePack = new CustomHB426CombinePack(); | 
|                     combinePack.guid = _guid; | 
|                     combinePack.SetHB426Start(i, tag); | 
|                 } | 
|                 else | 
|                 { | 
|                     if (combinePack.IsEndPack(tag)) | 
|                     { | 
|                         combinePack.SetHB426End(i, tag); | 
|                         break; | 
|                     } | 
|                 } | 
|             } | 
|   | 
|             if (null != combinePack) | 
|             { | 
|                 combinePack.AddPack(pack); | 
|             } | 
|         } | 
|   | 
|         List<GameNetPackBasic> newPackList = new List<GameNetPackBasic>(); | 
|   | 
|         if (null != combinePack) | 
|         { | 
|             //  技能包前面的包(不包括b426的开始标签) | 
|             for (int i = 0; i < combinePack.fromIndex; i++) | 
|             { | 
|                 newPackList.Add(b421SeriesPackList[i]); | 
|             } | 
|   | 
|             //  把合并的技能包加进来 | 
|             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; | 
|         } | 
|   | 
|     } | 
|   | 
|     public void Distribute() | 
|     { | 
|         BattleField battleField = BattleManager.Instance.GetBattleField(guid); | 
|   | 
|         if (null == battleField) | 
|         { | 
|             Debug.LogError("BattleField not found for guid: " + guid); | 
|             return; | 
|         } | 
|   | 
|         //  技能包 | 
|         if (startTag.Tag.StartsWith("Skill_")) | 
|         { | 
|             H0604_tagUseSkillAttack skill = packList[0] as H0604_tagUseSkillAttack; | 
|             BattleObject caster = battleField.battleObjMgr.GetBattleObject((int)skill.ObjID); | 
|             //  注意处理packList | 
|             SkillRecordAction skillRecordAction = new SkillRecordAction(battleField, caster, skill, packList); | 
|             battleField.PlayRecord(skillRecordAction); | 
|         } | 
|     } | 
| } |