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/System/Battle/BattleManager.cs |  653 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 643 insertions(+), 10 deletions(-)

diff --git a/Main/System/Battle/BattleManager.cs b/Main/System/Battle/BattleManager.cs
index 017432e..13c35bb 100644
--- a/Main/System/Battle/BattleManager.cs
+++ b/Main/System/Battle/BattleManager.cs
@@ -1,43 +1,676 @@
 using System.Collections.Generic;
 using UnityEngine;
-
-
+using LitJson;
+using System;
+using System.Linq;
 
 public class BattleManager : GameSystemManager<BattleManager>
 {
-    public StoryBattleField storyBattleField = new StoryBattleField();//涓荤嚎鎴樺満
+    public StoryBattleField storyBattleField = null;
 
-    protected Dictionary<int, BattleField> battleFields = new Dictionary<int, BattleField>();
+    //  鍚屾椂鍙兘鏈変竴鍦烘垬鏂楀湪杩涜 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 readonly int[] speedIndexfuncIdArr = new int[] { 34, 35, 36 };  // 鎴樻枟鍊嶆暟瀵瑰簲鐨勫姛鑳絀D
+    public readonly int passFuncId = 33;    // 璺宠繃鎴樻枟瀵瑰簲鐨勫姛鑳絀D
+    public int passRound;   // 瓒呰繃X鍥炲悎鍙烦杩�
+    public int fightGuideID;
+    public int fightGuideMainLevelLimit;
+    public int fightGuideNoClickSeconds;
+    public int[] challengeBossGuides;
+
+    public Action<string, BattleField> onBattleFieldCreate;
+
+    public Action onBattleFieldDestroy;
+
+    public bool isWaitServerStory = false;  //涓荤嚎绛夋湇鍔$鍥炴姤 0425
 
     public override void Init()
     {
         base.Init();
+
+        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);
+
+        config = FuncConfigConfig.Get("FightGuide");
+        fightGuideID = int.Parse(config.Numerical1);
+        fightGuideMainLevelLimit = int.Parse(config.Numerical2);
+        fightGuideNoClickSeconds = int.Parse(config.Numerical3);
+        challengeBossGuides = JsonMapper.ToObject<int[]>(config.Numerical4);
+
+        config = FuncConfigConfig.Get("BattleButton");
+        passRound= int.Parse(config.Numerical1);
+    }
+
 
     public override void Release()
     {
         base.Release();
+        LogicEngine.Instance.OnUpdate -= Run;
+        DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
+        DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= BeforePlayerInit;
     }
 
-    public void StartStoryBattle()
+    protected void OnPlayerLoginOk()
+    {
+        long exAttr1 = PlayerDatas.Instance.baseData.ExAttr1;
+        long exAttr2 = PlayerDatas.Instance.baseData.ExAttr2;
+
+        int MapID = 1;
+        int FuncLineID = (int)exAttr2;
+
+        CreateStoryBattle(MapID, FuncLineID, null, null);
+    }
+
+    void BeforePlayerInit()
+    {
+        isWaitServerStory = false;  //鍚庣画鑰冭檻鏂嚎閲嶈繛
+    }
+
+    //  涓婃父鎴忕殑鏃跺�� 绛夋垬鏂楅樀瀹规洿鏂板畬姣� 鍒涘缓涓荤嚎鍓湰 鏁屾柟鐨勬暟鎹彲浠ユ殏鏃朵笉鏄剧ず 宸辨柟琛ㄧ幇涓虹潯瑙�
+    //  濡傛灉涓荤嚎鍓湰瀛樺湪 閭d箞缁存寔褰撳墠鐨勫壇鏈笉鍙�
+    protected void CreateStoryBattle(int MapID, int FuncLineID, JsonData extendData, List<TeamBase> blueTeamList = null)
     {
         if (null == storyBattleField)
         {
-            storyBattleField = new StoryBattleField();
+            var redTeamList = new List<TeamBase>();
 
+            TeamBase storyTeam = TeamManager.Instance.GetTeam(TeamType.Story);
+
+            redTeamList.Add(storyTeam);
+
+            HB424_tagSCTurnFightInit vNetData = new HB424_tagSCTurnFightInit();
+            vNetData.MapID = (uint)MapID;
+            vNetData.FuncLineID = (uint)FuncLineID;
+
+            CreateBattleField(string.Empty, vNetData, extendData, redTeamList, blueTeamList);
+        }
+        else
+        {
+            // storyBattleField
         }
     }
 
-    public void Run()
+    public void OnBattleClose(BattleField _battleField)
     {
-        if (null != storyBattleField)
+
+    }
+
+    #region 鎴柇缃戠粶娲惧彂鍖� 鍙敹鍏ュ綋鍓嶅寘鐨勫悗缁� b425鏄富绾跨殑 闈炰富绾跨殑鍖呭苟涓嶄細璧癰425
+    private bool allow = true;
+
+    private Queue<GameNetPackBasic> packQueue = new Queue<GameNetPackBasic>();
+
+    public bool IsCanDistributePackage(GameNetPackBasic _package)
+    {
+        if (_package is HB425_tagSCTurnFightReportSign)
         {
-            storyBattleField.Run();
+            HB425_tagSCTurnFightReportSign pkg = _package as HB425_tagSCTurnFightReportSign;
+
+            // 0-鎴樻姤鐗囨寮�濮嬶紱1-鎴樻姤鐗囨缁撴潫锛�
+            if (pkg.Sign == 0)
+            {
+                allow = false;
+            }
+            else
+            {
+                allow = true;
+
+                //  鍙戦�佹垬鎶ョ墖娈电粨鏉熷寘
+                AnalysisPackQueueAndDistribute();
+
+            }
+        }
+        else
+        {
+            if (!allow)
+            {
+                _package.socketType = ServerType.MainFight;
+                packQueue.Enqueue(_package);
+            }
         }
 
+        return allow;
+    }
+
+    protected int continousEmptyCount = 0; // 杩炵画绌哄寘璁℃暟
+
+    protected void AnalysisPackQueueAndDistribute()
+    {
+        // 寤鸿鍓嶇鍋氫竴涓槻鑼冩満鍒讹細褰撹繛缁娆¤姹傚緱鍒扮┖鐨勬垬鏂楃墖娈靛皝鍖呮椂锛堜笉鍖呭惈B425鏍囪鐨勫紑濮嬭窡缁撴潫灏佸寘锛屽嵆寮�濮嬭窡涓棿娌℃湁浠讳綍灏佸寘锛夛紝寮哄埗鑷姩甯帺瀹跺洖鍩庝紤鎭紝
+        // 鍘熷洜鍙兘鍓嶅悗绔暟鎹笉涓�鑷碽ug锛堟瘮濡傛垬閿ゅ彲鑳藉悗绔病鏈変簡锛屽墠绔涓鸿繕鏈夛級鎴栬�� 鍚庣鏈塨ug瀵艰嚧娌℃湁澶勭悊鎴樻枟
+        // 涓洪槻姝㈡寰幆锛屽彲寮哄埗鍥炲煄浼戞伅锛岃鐜╁閲嶆柊鐐瑰嚮鍏冲崱鎴樻枟鎴栨寫鎴榖oss锛�
+        // 姝e父鎯呭喌涓嬪湪鎴橀敜瓒冲鏃剁悊璁轰笂閮藉彲浠ヤ竴鐩村惊鐜埛鎬紝濡傛灉杩炵画澶氭娌℃湁鎴樻枟鐗囨灏佸寘锛屾瘮濡傞檺鍒朵釜杩炵画10娆′互鍐咃紝灏卞彲浠ョ悊瑙d负寮傚父浜�
+
+        const int MaxContinousEmptyCount = 10; // 杩炵画绌哄寘鏈�澶ф鏁�
+
+        List<GameNetPackBasic> packQueueSnapshot = new List<GameNetPackBasic>(packQueue);
+
+        List<GameNetPackBasic> newPackList = ParseBattlePackList(string.Empty, packQueueSnapshot);
+
+#if UNITY_EDITOR
+        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();
+#endif
+        // HashSet<int> skipIndexes = new HashSet<int>();
+
+        // // 杩欓噷宸茬粡鏄寜鐓equeue鐨勯『搴忎簡
+        // for (int i = 0; i < packQueueSnapshot.Count; i++)
+        // {
+        //     if (skipIndexes.Contains(i)) continue;
+
+        //     GameNetPackBasic pack = packQueueSnapshot[i];
+
+        //     // 纰板埌B421 鎴柇 寰�涓嬫敹闆哹421閲岀殑鍏ㄩ儴鍐呭
+        //     if (pack is HB421_tagMCTurnFightObjAction)
+        //     {
+        //         HB421_tagMCTurnFightObjAction b421Pack = pack as HB421_tagMCTurnFightObjAction;
+
+        //         List<GameNetPackBasic> b421PackList = new List<GameNetPackBasic>();
+        //         i++;    // 璺宠繃褰撳墠鐨凚421鍖�
+
+        //         // 鏀堕泦鎵�鏈夐潪B421鍖咃紝鐩村埌閬囧埌涓嬩竴涓狟421鎴栭槦鍒楃粨鏉�
+        //         for (; i < packQueueSnapshot.Count; i++)
+        //         {
+        //             GameNetPackBasic nextPack = packQueueSnapshot[i];
+        //             if (nextPack is HB421_tagMCTurnFightObjAction)
+        //             {
+        //                 i--; // 鍥為��涓�涓綅缃紝鐣欑粰澶栧眰寰幆澶勭悊
+        //                 break;
+        //             }
+        //             else
+        //             {
+        //                 b421PackList.Add(nextPack);
+        //                 skipIndexes.Add(i); // 鏍囪宸茶鍚堝寘
+        //             }
+        //         }
+
+
+
+        //         // 鍚堝苟鎵�鏈夌浉鍏冲寘
+        //         CustomB421ActionPack actionPack = CustomB421ActionPack.CreateB421ActionPack(GetGUID(b421Pack.packUID), b421PackList);
+
+        //         newPackList.Add(actionPack);
+        //     }
+        //     else
+        //     {
+        //         newPackList.Add(pack);
+        //     }
+        // }
+
+        // 闃茶寖鏈哄埗锛氳繛缁娆℃病鏈夋垬鏂楃墖娈靛皝鍖呮椂鑷姩鍥炲煄
+        if (newPackList.Count == 0)
+        {
+            continousEmptyCount++;
+            Debug.LogWarning($"杩炵画绌烘垬鏂楃墖娈靛皝鍖呮鏁帮細{continousEmptyCount}");
+            if (continousEmptyCount >= MaxContinousEmptyCount)
+            {
+                Debug.LogError("杩炵画澶氭娌℃湁鎴樻枟鐗囨灏佸寘锛岃嚜鍔ㄥ洖鍩庝紤鎭紒");
+                MainFightRequest(0); // 0-鍋滄鎴樻枟鍥炲煄
+                continousEmptyCount = 0;
+                packQueue.Clear();
+                return;
+            }
+        }
+        else
+        {
+            continousEmptyCount = 0; // 鏈夊寘灏遍噸缃�
+        }
+
+
+        // b421璺焍426鐨勫寘宸茬粡澶勭悊瀹屼簡
+        packQueue.Clear();
+        for (int i = 0; i < newPackList.Count; i++)
+        {
+            var pack = newPackList[i];
+
+            packQueue.Enqueue(pack);
+        }
+
+    
+
+            // packQueue = new Queue<GameNetPackBasic>(newPackList);
+
+        DistributeNextPackage();
+    }
+
+    public static List<GameNetPackBasic> ParseBattlePackList(string guid, List<GameNetPackBasic> packQueueSnapshot)
+    {
+        var list = CustomHB426CombinePack.CombineToSkillPackFromList(guid, packQueueSnapshot);
+        // string str = "ParseBattlePackList \n";
+        // for (int i = 0; i < list.Count; i++)
+        // {
+        //     str += "  " + list[i].GetType().Name + "\n";
+        // }
+        // BattleDebug.LogError(str);
+        return list;
+
+    }
+
+    //  涓撳睘浜庝富绾挎垬鏂楃殑娲惧彂
+    public bool DistributeNextPackage()
+    {
+        if (packQueue == null)
+        {
+            Debug.LogWarning("DistributeNextPackage: packQueue涓虹┖鎴栧凡澶勭悊瀹屾瘯");
+            return false;
+        }
+
+        if (packQueue.Count <= 0)
+        {
+            return false;
+        }
+
+        GameNetPackBasic pack = null;
+        try
+        {
+            pack = packQueue.Dequeue();
+        }
+        catch (Exception ex)
+        {
+            Debug.LogError("DistributeNextPackage: Peek寮傚父 " + ex);
+            return false;
+        }
+
+        try
+        {
+            if (pack is CustomHB426CombinePack combinePack)
+            {
+                combinePack.Distribute();
+            }
+            else if (pack is CustomB421ActionPack actionPack)
+            {
+                actionPack.Distribute();
+            }
+            else
+            {
+                PackageRegedit.Distribute(pack);
+            }
+        }
+        catch (Exception ex)
+        {
+            Debug.LogError("DistributeNextPackage: 鍒嗗彂鍖呭紓甯� " + ex);
+            // 鍑洪敊鏃朵富鍔ㄧЩ闄ゅ綋鍓嶅寘锛岄槻姝㈡寰幆
+            if (packQueue.Count > 0)
+            {
+                packQueue.Dequeue();
+            }
+            return false;
+        }
+
+        return packQueue.Count > 0;
+    }
+
+    public void OnConnected()
+    {
+        if (!allow)
+        {
+            allow = true;
+            packQueue.Clear();
+
+            //  閲嶆柊鍙戦�佽涓婁竴缁勬垬鏂楀寘鐨勮姹�
+            //  TODO YYL
+        }
+    }
+
+    #endregion
+
+    #region 鎴樻姤閮ㄥ垎
+
+    protected Dictionary<string, Queue<GameNetPackBasic>> battleReportDict = new Dictionary<string, Queue<GameNetPackBasic>>();
+
+    protected Dictionary<string, List<ulong>> battlePackRelationList = new Dictionary<string, List<ulong>>();
+
+    public void PushPackage(string guid, GameNetPackBasic vNetPack)
+    {
+        Queue<GameNetPackBasic> queue = null;
+
+        if (!battleReportDict.TryGetValue(guid, out queue))
+        {
+            queue = new Queue<GameNetPackBasic>();
+            battleReportDict.Add(guid, queue);
+        }
+
+        queue.Enqueue(vNetPack);
+
+        List<ulong> uidList = null;
+
+        if (!battlePackRelationList.TryGetValue(guid, out uidList))
+        {
+            uidList = new List<ulong>();
+            battlePackRelationList.Add(guid, uidList);
+        }
+
+        if (!uidList.Contains(vNetPack.packUID))
+        {
+            uidList.Add(vNetPack.packUID);
+        }
+    }
+
+    public void PushPackUID(string guid, ulong packUID)
+    {
+        List<ulong> uidList = null;
+
+        if (!battlePackRelationList.TryGetValue(guid, out uidList))
+        {
+            uidList = new List<ulong>();
+            battlePackRelationList.Add(guid, uidList);
+        }
+
+        if (!uidList.Contains(packUID))
+        {
+            uidList.Add(packUID);
+        }
+
+    }
+
+    public BattleField GetBattleField(ulong packUID)
+    {
+        string guid = GetGUID(packUID);
+        BattleField battleField = GetBattleField(GetGUID(packUID));
+        if (battleField == null || battleField.rejectNewPackage)
+        {
+            return null;
+        }
+        return battleField;
+    }
+
+    public BattleField GetBattleField(string guid)
+    {
+        BattleField battleField = null;
+        battleFields.TryGetValue(guid, out battleField);
+        return battleField;
+    }
+
+    public string GetGUID(ulong packUID)
+    {
+        foreach (var kv in battlePackRelationList)
+        {
+            if (kv.Value.Contains(packUID))
+            {
+                return kv.Key;
+            }
+        }
+        return string.Empty;
+    }
+
+    public void DistributeNextReportPackage(string guid)
+    {
+        Queue<GameNetPackBasic> queue = null;
+
+
+        if (!battleReportDict.TryGetValue(guid, out queue))
+        {
+            BattleDebug.LogError("DistributeNextReportPackage could not find queue for guid : " + guid);
+            return;
+        }
+
+        if (queue.Count <= 0)
+        {
+            return;
+        }
+
+        var pack = queue.Dequeue();
+
+        // Debug.LogError("DistributeNextReportPackage for guid : " + guid + " pack type : " + pack.GetType());
+
+        try
+        {
+            if (pack is CustomHB426CombinePack combinePack)
+            {
+                combinePack.Distribute();
+            }
+            else if (pack is CustomB421ActionPack actionPack)
+            {
+                actionPack.Distribute();
+            }
+            else
+            {
+                PackageRegedit.Distribute(pack);
+            }
+        }
+        catch (Exception ex)
+        {
+            Debug.LogError("DistributeNextPackage: 鍒嗗彂鍖呭紓甯� " + ex);
+        }
+    }
+    #endregion
+
+    public BattleField CreateBattleField(string guid, HB424_tagSCTurnFightInit vNetData, JsonData extendData, List<TeamBase> redTeamList, List<TeamBase> blueTeamList)
+    {
+        BattleField battleField = null;
+
+        int MapID = (int)vNetData.MapID;
+        int FuncLineID = (int)vNetData.FuncLineID;
+
+        bool isCreate = true;
+        if (battleFields.TryGetValue(guid, out battleField))
+        {
+            //涓荤嚎鎴樺満闇�涓�鐩村瓨鍦�
+            if (string.IsNullOrEmpty(guid))
+            {
+                isCreate = false;
+            }
+            else
+            {
+                BattleDebug.LogError("鎴樺満宸插瓨鍦� 鍏堣繘琛岄攢姣�");
+                battleField.Destroy();
+            }
+        }
+
+        var bf = GetBattleFieldByMapID(MapID);
+        if (bf != null && !string.IsNullOrEmpty(guid))
+        {
+            BattleDebug.LogError("鐩稿悓鍦板浘ID鐨勬垬鍦哄凡瀛樺湪 鍏堣繘琛岄攢姣�");
+            bf.Destroy();
+        }
+
+        if (isCreate)
+        {
+            battleField = BattleFieldFactory.CreateBattleField(guid, MapID, FuncLineID, extendData, redTeamList, blueTeamList);
+
+            if (string.IsNullOrEmpty(guid))
+            {
+                storyBattleField = (StoryBattleField)battleField;
+            }
+            battleFields.Add(guid, battleField);
+            onBattleFieldCreate?.Invoke(guid, battleField);
+        }
+
+
+
+        battleField.Init(MapID, FuncLineID, extendData, redTeamList, blueTeamList, vNetData.TurnMax);
+
+        return battleField;
+    }
+
+    public void DestroyBattleField(BattleField battleField)
+    {
+        if (battleField == null)
+        {
+            BattleDebug.LogError("DestroyBattleField called with null battleField");
+            return;
+        }
+
+        battleField.Release();
+
+        string guid = battleField.guid;
+
+        battleFields.Remove(guid);
+        battleReportDict.Remove(guid);
+        battlePackRelationList.Remove(guid);
+
+        if (storyBattleField == battleField)
+        {
+            storyBattleField = null;
+        }
+
+        GameObject.DestroyImmediate(battleField.battleRootNode.gameObject);
+
+        onBattleFieldDestroy?.Invoke();
+
+    }
+
+
+    // 鐩墠鏀寔  BYTE ReqType; // 0-鍋滄鎴樻枟鍥炲煄锛�1-璁剧疆娑堣�楀�嶅�硷紱2-鎸戞垬鍏冲崱灏忔�紱3-鎸戞垬鍏冲崱boss锛�4-缁х画鎴樻枟锛�
+    // 0-鍋滄鎴樻枟鍥炲煄   -  鐜╁涓诲姩鐐瑰嚮鍥炲煄鏃跺彂閫�
+    // 1-璁剧疆娑堣�楀�嶅��   -  鐜╁璁剧疆娑堣�楀�嶅�硷紝瀵瑰簲鍒扮帺瀹秛seHarmerCount鐨勫��
+    // 2-鎸戞垬鍏冲崱灏忔��   -  鐜╁鐐瑰嚮寮�濮嬫垬鏂楁椂鍙戦�侊紝浠呬粠浼戞伅鐘舵�佸埌寮�濮嬫垬鏂楁椂鍙戦�佸嵆鍙�
+    // 3-閲嶅畾涔夋殏鏈娇鐢�
+    // 4-缁х画鎴樻枟          -   鐜╁涓荤嚎鎴樻枟涓紙鍖呭惈涓荤嚎灏忔��佷富绾縝oss锛夛紝鍓嶇琛ㄧ幇瀹屽悗绔悓姝ョ殑鎴樻枟鐗囨鍚庯紝鍙啀鍥炲璇ュ�硷紝鍚庣浼氭牴鎹垬鏂楅�昏緫鍙婃祦绋嬭嚜鍔ㄥ洖澶嶄笅涓�娈电殑鎴樻枟鐗囨灏佸寘锛屼竴鐩村惊鐜�
+    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;
+
+        GameNetSystem.Instance.SendInfo(req);
+        if (reqType >= 2)
+            isWaitServerStory = true;
+    }
+
+
+    public void Run()
+    {
+        try
+        {
+            List<string> keys = new List<string>(battleFields.Keys);
+            for (int i = keys.Count - 1; i >= 0; i--)
+            {
+                var battleField = battleFields[keys[i]];
+                battleField?.Run();
+            }
+        }
+        catch (System.Exception ex)
+        {
+            Debug.LogError(ex);
+        }
+    }
+
+    public BattleField GetBattleFieldByMapID(int v)
+    {
         foreach (var battleField in battleFields)
         {
-            battleField.Value?.Run();
+            if (battleField.Value.MapID == v)
+            {
+                return battleField.Value;
+            }
+        }
+
+        return null;
+    }
+
+    //鍙戣繘鍏ユ垬鏂楀寘
+    private float lastTime = 0f;
+    private float turnCoolDown = 0.5f; // 鍐峰嵈鏃堕棿
+    public void SendTurnFight(uint mapID, uint funcLineID = 0, byte tagType = 0, uint tagID = 0, uint[] valueList = null)
+    {
+        // 杩炵画棰戠箒鍙戝寘锛岃Е鍙戞彁绀�
+        float currentTime = Time.time;
+        if (currentTime - lastTime < turnCoolDown)
+        {
+            SysNotifyMgr.Instance.ShowTip("BattleCoolDown");
+            return;
+        }
+        lastTime = currentTime;
+
+        CB410_tagCMTurnFight pack = new CB410_tagCMTurnFight();
+        pack.MapID = mapID;
+        pack.FuncLineID = funcLineID;
+        pack.TagType = tagType;
+        pack.TagID = tagID;
+        if (!valueList.IsNullOrEmpty())
+        {
+            pack.ValueList = valueList;
+            pack.ValueCount = (byte)valueList.Length;
+        }
+        GameNetSystem.Instance.SendInfo(pack);
+    }
+
+    // 鑾峰彇褰撳墠姝e湪鏄剧ず鐨勬垬鏂楀満鏅悕绉帮紝濡傛灉娌℃湁鍒欒繑鍥炵┖瀛楃涓�
+    public string GetActiveBattleName()
+    {
+        foreach (var kvp in battleFields)
+        {
+            BattleField battleField = kvp.Value;
+            if (battleField == null)
+                continue;
+
+            var battleName = battleField.ToString();
+            if (BattleConst.battleNameToWinName.ContainsKey(battleName)
+            && UIManager.Instance.IsOpened(BattleConst.battleNameToWinName[battleName]))
+                return battleName;
+        }
+        return "";
+    }
+
+    // 鑾峰彇褰撳墠姝e湪鏄剧ず鐨勬垬鏂楀満鏅�,濡傛灉娌℃湁鍒欒繑鍥瀗ull
+    public BattleField GetActiveBattleFieldByName(string battleName)
+    {
+        foreach (var kvp in battleFields)
+        {
+            BattleField battleField = kvp.Value;
+            if (battleField == null)
+                continue;
+
+            var name = battleField.ToString();
+            if (name == battleName)
+                return battleField;
+        }
+        return null;
+    }
+
+    public void DestroyAllBattleField()
+    {
+        var battleFieldsList = battleFields.Values.ToList();
+        foreach (var battleField in battleFieldsList)
+        {
+            if (battleField == null)
+                continue;
+            battleField.Destroy();
         }
     }
 

--
Gitblit v1.8.0