From ffd98ca236a8e6d8d8bd68c46ca56519e6f758ae Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期五, 23 一月 2026 18:06:49 +0800
Subject: [PATCH] 432 自动挂机优化-客户端 自动替换高战力装备
---
Main/System/Equip/EquipExchangeWin.cs | 86 ++++++++++++++++++++++++++++++++++--------
1 files changed, 69 insertions(+), 17 deletions(-)
diff --git a/Main/System/Equip/EquipExchangeWin.cs b/Main/System/Equip/EquipExchangeWin.cs
index 0eaab9c..2fb9f49 100644
--- a/Main/System/Equip/EquipExchangeWin.cs
+++ b/Main/System/Equip/EquipExchangeWin.cs
@@ -1,10 +1,4 @@
-锘縰sing Spine;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-using UnityEngine;
-using UnityEngine.UI;
+锘縰sing UnityEngine;
//鑾峰緱瑁呭鐣岄潰
public class EquipExchangeWin : UIBase
@@ -12,13 +6,13 @@
[SerializeField] EquipExchangeCell oldEquipObj;
[SerializeField] EquipExchangeCell newEquipObj;
-
-
-
protected override void OnPreOpen()
{
// 閫氱煡涓绘垬鍦烘殏鍋�
BattleManager.Instance.storyBattleField.IsPause = true;
+ AutoFightModel.Instance.hasAutoExchanged = false;
+ AutoFightModel.Instance.startServerTime = TimeUtility.AllSeconds;
+
EquipModel.Instance.OnEquipOPResultAction += OnRefreshItem;
Display();
@@ -29,17 +23,12 @@
// }
}
-
-
protected override void OnClose()
{
EquipModel.Instance.OnEquipOPResultAction -= OnRefreshItem;
// 閫氱煡涓绘垬鍦�
BattleManager.Instance.storyBattleField.IsPause = false;
}
-
-
-
void Display()
{
@@ -69,14 +58,77 @@
}
-
-
void OnRefreshItem(bool isDone, int index)
{
+ AutoFightModel.Instance.hasAutoExchanged = false;
Display();
}
+ private void LateUpdate()
+ {
+ TryAutoExchangeEquip();
+ }
+ /// <summary>
+ /// 灏濊瘯鑷姩鎹㈣
+ /// </summary>
+ private void TryAutoExchangeEquip()
+ {
+ // 宸蹭氦鎹㈣繃锛屼笉鍐嶅鐞�
+ if (AutoFightModel.Instance.hasAutoExchanged)
+ return;
+
+ if (!AutoFightModel.Instance.isAutoAttack)
+ return;
+
+ if (!AutoFightModel.Instance.isAutoChangeBetterEquip)
+ return;
+
+ int elapsedSeconds = TimeUtility.AllSeconds - AutoFightModel.Instance.startServerTime;
+ if (elapsedSeconds < AutoFightModel.Instance.autoChangeBetterEquipWaitTimeS)
+ return;
+
+ // 妫�鏌ユ槸鍚︽湁鏂拌澶�
+ if (EquipModel.Instance.selectFloorEquip == null)
+ return;
+
+
+ AutoFightModel.Instance.hasAutoExchanged = true;
+ AutoExchangeEquip();
+ }
+
+ /// <summary>
+ /// 鑷姩浜ゆ崲瑁呭
+ /// </summary>
+ private void AutoExchangeEquip()
+ {
+ // 妫�鏌ユ柊瑁呭鎴樺姏鏄惁鏇撮珮
+ long fightPowerChange = FightPowerManager.Instance.GetFightPowerChange(EquipModel.Instance.selectFloorEquip);
+ bool isFightPowerUp = fightPowerChange > 0;
+ int equipPlace = EquipModel.Instance.selectFloorEquip.config.EquipPlace - 1;
+ var oldEquip = PackManager.Instance.GetItemByIndex(PackType.Equip, equipPlace);
+ //鏄惁鏇挎崲鍚庤嚜鍔ㄥ垎瑙e師瑁呭
+
+ if (isFightPowerUp)
+ {
+ if (oldEquip == null)
+ {
+ EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)EquipModel.Instance.selectFloorEquip.gridIndex }, 2);
+ }
+ else
+ {
+ EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)EquipModel.Instance.selectFloorEquip.gridIndex }, 2, AutoFightModel.Instance.isAutoExchangeDecomposeOld);
+ }
+ }
+ else
+ {
+ //鏄惁鏇挎崲鍚庤嚜鍔ㄥ垎瑙e師瑁呭
+ if (AutoFightModel.Instance.isAutoExchangeDecomposeOld)
+ {
+ EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)EquipModel.Instance.selectFloorEquip.gridIndex }, 1);
+ }
+ }
+ }
}
--
Gitblit v1.8.0