From e10813023f08c85454f575d3d388dac78e0e8ac2 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 29 八月 2025 19:12:16 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts

---
 Main/System/Main/AutoFightModel.cs |   71 ++++++++++++++++++++++++++++++++++-
 1 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/Main/System/Main/AutoFightModel.cs b/Main/System/Main/AutoFightModel.cs
index ec225e4..5f2fc5f 100644
--- a/Main/System/Main/AutoFightModel.cs
+++ b/Main/System/Main/AutoFightModel.cs
@@ -76,11 +76,15 @@
     {
         ParseConfig();
         DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
+        BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField;
+
     }
 
     public override void Release()
     {
         DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
+        BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField;
+
     }
 
     void ParseConfig()
@@ -104,6 +108,15 @@
             PlayerDatas.Instance.baseData.UseHarmerCount = fightCost;
             BattleManager.Instance.MainFightRequest(1, (uint)fightCost);
         }
+
+        StoryBattleField storyBattleField = BattleManager.Instance.storyBattleField;
+
+        if (storyBattleField != null && storyBattleField.GetBattleMode() != BattleMode.Stop)
+        {
+            //鎴樻枟涓敼鍙樻ā寮�
+            storyBattleField.AutoSetBattleMode();
+        }
+
         QuickSetting.Instance.SendPackage();
         ChangeAutoEvent?.Invoke();
     }
@@ -114,7 +127,7 @@
     {
         if (!isAutoAttack)
             return false;
-            
+
         if (item == null)
             return true;
 
@@ -129,11 +142,63 @@
         {
             if (isStopFightByBetterEquip)
                 return false;
-            
+
             EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)item.gridIndex }, 1);
             return true;
 
         }
-        
+
     }
+
+    #region 鎴樻枟
+
+    public void StartFight()
+    {
+        if (isAutoAttack)
+            return;
+
+        StoryBattleField storyBattleField = BattleManager.Instance.storyBattleField;
+        if (storyBattleField == null)
+        {
+            return;
+        }
+
+        if (UIHelper.GetMoneyCnt(41) < PlayerDatas.Instance.baseData.UseHarmerCount)
+        {
+            if (storyBattleField.GetBattleMode() != BattleMode.Stop)
+                storyBattleField.HaveRest();
+            return;
+        }
+
+        if (isAutoAttackSet)
+        {
+            isAutoAttack = true;
+        }
+
+        //鎵嬪姩浼氫竴鐩磋繘鍏ヨ繖涓�昏緫, 鑷姩瑙﹀彂涓�娆�
+        storyBattleField.AutoSetBattleMode();
+        storyBattleField.operationAgent.DoNext();
+    }
+
+    void OnCreateBattleField(string guid, BattleField battleField)
+    {
+        if (string.IsNullOrEmpty(guid) && BattleManager.Instance.storyBattleField != null)
+        {
+            BattleManager.Instance.storyBattleField.ChangeBattleModeEvent -= ChangeBattleModeEvent;
+            BattleManager.Instance.storyBattleField.ChangeBattleModeEvent += ChangeBattleModeEvent;
+        }
+
+    }
+
+    void ChangeBattleModeEvent(BattleMode _battleMode)
+    {
+        if (_battleMode == BattleMode.Stop)
+        {
+            isAutoAttack = false;
+        }
+    }
+    
+    #endregion
+
+
 }

--
Gitblit v1.8.0