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/Main/AutoFightModel.cs | 61 +++++++++++++++
Main/System/Setting/QuickSetting.cs | 3
Main/System/Equip/EquipExchangeCell.cs | 18 ++-
Main/System/Main/AutoFightWin.cs | 21 +++++
Main/System/Equip/EquipExchangeWin.cs | 86 +++++++++++++++++----
5 files changed, 164 insertions(+), 25 deletions(-)
diff --git a/Main/System/Equip/EquipExchangeCell.cs b/Main/System/Equip/EquipExchangeCell.cs
index 66e9e13..5850d8f 100644
--- a/Main/System/Equip/EquipExchangeCell.cs
+++ b/Main/System/Equip/EquipExchangeCell.cs
@@ -39,12 +39,12 @@
[SerializeField] RectTransform bgRect;
int cmpResult = 0; // 瑁呭瀵规瘮缁撴灉 0鐩稿悓 1鏇村己 2鏇村急
- bool isToggle = true;
void Start()
{
putonButton.AddListener(() =>
{
+ AutoFightModel.Instance.hasAutoExchanged = true;
EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)EquipModel.Instance.selectFloorEquip.gridIndex }, 2);
});
@@ -54,7 +54,7 @@
decomposeCheck.onValueChanged.RemoveAllListeners();
decomposeCheck.onValueChanged.AddListener((bool isOn) =>
{
- isToggle = !isToggle;
+ AutoFightModel.Instance.isAutoExchangeDecomposeOld = !AutoFightModel.Instance.isAutoExchangeDecomposeOld;
});
}
@@ -90,7 +90,7 @@
equipedText.SetActive(false);
fightPowerGO.SetActive(true);
btnsGO.SetActive(true);
- decomposeCheck.isOn = isToggle;
+ decomposeCheck.isOn = AutoFightModel.Instance.isAutoExchangeDecomposeOld;
if (oldEquip == null)
{
@@ -172,7 +172,7 @@
//寤惰繜澶勭悊鐗规晥澶у皬
async UniTask RefreshEffect(ItemModel equip)
- {
+ {
await UniTask.DelayFrame(1);
int effectID = EquipModel.Instance.equipUIEffects[Math.Min(equip.config.ItemColor, EquipModel.Instance.equipUIEffects.Length) - 1];
if (effectID == 0)
@@ -216,13 +216,15 @@
{
if (ok)
{
+ AutoFightModel.Instance.hasAutoExchanged = true;
EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)EquipModel.Instance.selectFloorEquip.gridIndex }, 2, decomposeCheck.isOn);
}
-
+
});
}
else
{
+ AutoFightModel.Instance.hasAutoExchanged = true;
EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)EquipModel.Instance.selectFloorEquip.gridIndex }, 2, decomposeCheck.isOn);
}
@@ -239,13 +241,15 @@
{
if (ok)
{
+ AutoFightModel.Instance.hasAutoExchanged = true;
EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)EquipModel.Instance.selectFloorEquip.gridIndex }, 1);
}
-
+
});
}
else
{
+ AutoFightModel.Instance.hasAutoExchanged = true;
EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)EquipModel.Instance.selectFloorEquip.gridIndex }, 1);
}
}
@@ -255,7 +259,7 @@
ItemModel oldEquip = null;
if (isNewEquip)
- {
+ {
//鎵惧姣旇澶�
oldEquip = PackManager.Instance.GetItemByIndex(PackType.Equip, EquipModel.Instance.selectFloorEquip.config.EquipPlace - 1);
}
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);
+ }
+ }
+ }
}
diff --git a/Main/System/Main/AutoFightModel.cs b/Main/System/Main/AutoFightModel.cs
index a2d0d14..203ec8a 100644
--- a/Main/System/Main/AutoFightModel.cs
+++ b/Main/System/Main/AutoFightModel.cs
@@ -80,6 +80,57 @@
}
}
+ public bool isAutoChangeBetterEquip
+ {
+ get
+ {
+ return QuickSetting.Instance.GetQuickSettingBool(QuickSettingType.AutoFight_AutoChangeBetterEquip, 0);
+ }
+ set
+ {
+ QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_AutoChangeBetterEquip, value);
+ }
+ }
+ public int startServerTime; // 寮�濮嬫椂鐨勬湇鍔″櫒鏃堕棿鎴�
+ bool m_HasAutoExchanged = false;
+ public bool hasAutoExchanged // 鏄惁宸茶嚜鍔ㄤ氦鎹㈣繃
+ {
+ get
+ {
+ return m_HasAutoExchanged;
+ }
+ set
+ {
+ if (m_HasAutoExchanged == value)
+ return;
+ m_HasAutoExchanged = value;
+ if (!value)
+ {
+ startServerTime = TimeUtility.AllSeconds;
+ }
+ }
+ }
+
+ bool m_IsAutoExchangeDecomposeOld = false;
+ public bool isAutoExchangeDecomposeOld //鏄惁鏇挎崲鍚庤嚜鍔ㄥ垎瑙e師瑁呭
+ {
+ get
+ {
+ return m_IsAutoExchangeDecomposeOld;
+ }
+ set
+ {
+ if (m_IsAutoExchangeDecomposeOld == value)
+ return;
+ m_IsAutoExchangeDecomposeOld = value;
+ if (value)
+ {
+ hasAutoExchanged = false;
+ }
+ }
+ }
+
+
public event Action<bool> OnAutoChallengeBossEvent;
//鑷姩鎸戞垬棣栭
public bool isAutoChallengeBoss
@@ -143,6 +194,9 @@
}
public event Action ChangeAutoEvent;
+
+
+
public int maxSpeed = 3; //鏈�楂橀�熷害 绱㈠紩
public int maxCost; //鏈�楂樻秷鑰�
public int[] autoCostWithBlessLV; //鑷姩鎴樻枟娑堣�楀�嶆暟鍏宠仈绁濈绛夌骇
@@ -153,6 +207,7 @@
public int maxTryChallengeCD; //鎵撲富绾縝oss鎴樿触鍚庯紝闂撮殧x绉掑悗閲嶈瘯
public int openAutoFinishCond;//鑷姩瀹屾垚浠诲姟闇�绁濈鏍慩绾�
public int autoCloseWinCD;
+ public int autoChangeBetterEquipWaitTimeS;//瑁呭瀵规瘮鐣岄潰鎵撳紑x绉掑悗锛屼负鐜╁鏇挎崲楂樻垬鍔涜澶�
public override void Init()
{
@@ -172,7 +227,7 @@
{
BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField;
DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= BeforePlayerInit;
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitializeEventOnRelogin;
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin -= OnBeforePlayerDataInitializeEventOnRelogin;
EventBroadcast.Instance.RemoveListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnSkillCast);
BlessLVManager.Instance.OnBlessLVUpdateEvent -= UpdateRedpint;
TaskManager.Instance.OnTaskUpdate -= OnTaskUpdate;
@@ -188,6 +243,7 @@
speed2UnlockMissionID = int.Parse(config.Numerical2);
maxCost = autoCostWithBlessLV.Length;
autoCloseWinCD = int.Parse(config.Numerical3);
+ autoChangeBetterEquipWaitTimeS = int.Parse(config.Numerical5);
config = FuncConfigConfig.Get("AutoGuaji1");
openAutoChallengeBossCond = int.Parse(config.Numerical1);
maxTryChallengeCount = int.Parse(config.Numerical2);
@@ -200,11 +256,14 @@
{
fightingHeroSkinID = 0;
heroGuid = "";
+ startServerTime = 0;
+ hasAutoExchanged = false;
}
private void OnBeforePlayerDataInitializeEventOnRelogin()
{
nowChallengeCount = 0;
+ isAutoExchangeDecomposeOld = true;
}
Dictionary<string, int> winWaitCloseDict = new Dictionary<string, int>();
diff --git a/Main/System/Main/AutoFightWin.cs b/Main/System/Main/AutoFightWin.cs
index f16f046..2a3a72b 100644
--- a/Main/System/Main/AutoFightWin.cs
+++ b/Main/System/Main/AutoFightWin.cs
@@ -22,6 +22,7 @@
[SerializeField] ScrollerController speedScroll;
[SerializeField] Toggle betterEquipToggle;
+ [SerializeField] Toggle autoChangeBetterEquipToggle; // 鑷姩鏇挎崲楂樻垬鍔涜澶�
[SerializeField] Toggle autoChallengeBossToggle;
[SerializeField] Button tryChallengeBtn;
@@ -75,9 +76,25 @@
tryChallengeArrow.transform.localRotation = Quaternion.Euler(0, 0, isOpenTryChallengeScroll ? 180 : 0);
AutoFightModel.Instance.ClickSpeedRed();
});
+
betterEquipToggle.AddListener((bool value) =>
{
betterEquipToggle.isOn = value;
+ //鍙栨秷鍕鹃�夋椂锛屽彇娑堣嚜鍔ㄦ浛鎹㈤珮鎴樺姏瑁呭鐨勯�夐」
+ if (!value)
+ {
+ autoChangeBetterEquipToggle.isOn = false;
+ }
+ });
+
+ autoChangeBetterEquipToggle.AddListener((bool value) =>
+ {
+ autoChangeBetterEquipToggle.isOn = value;
+ //鍕鹃�夋椂锛屽嬀閫夎澶囨垬鍔涙彁鍗囨椂鍋滄鐨勯�夐」
+ if (value)
+ {
+ betterEquipToggle.isOn = true;
+ }
});
autoChallengeBossToggle.AddListener((bool value) =>
@@ -164,6 +181,7 @@
speedText.text = AutoFightModel.Instance.fightSpeed.ToString();
tryChallengeText.text = AutoFightModel.Instance.tryChallengeCount.ToString();
betterEquipToggle.isOn = AutoFightModel.Instance.isStopFightByBetterEquip;
+ autoChangeBetterEquipToggle.isOn = AutoFightModel.Instance.isAutoChangeBetterEquip;
autoChallengeBossToggle.isOn = AutoFightModel.Instance.isAutoChallengeBoss;
autoFinishTaskToggle.isOn = AutoFightModel.Instance.isAutoFinishTask;
costTip.text = Language.Get("AutoFight2", ItemConfig.Get(GeneralDefine.MoneyDisplayModel[41]).ItemName, AutoFightModel.Instance.fightCost);
@@ -341,10 +359,12 @@
AutoFightModel.Instance.fightCost = int.Parse(costText.text);
AutoFightModel.Instance.fightSpeed = int.Parse(speedText.text);
AutoFightModel.Instance.isStopFightByBetterEquip = betterEquipToggle.isOn;
+ AutoFightModel.Instance.isAutoChangeBetterEquip = autoChangeBetterEquipToggle.isOn;
AutoFightModel.Instance.isAutoChallengeBoss = autoChallengeBossToggle.isOn;
AutoFightModel.Instance.nowChallengeCount = 0;
AutoFightModel.Instance.tryChallengeCount = int.Parse(tryChallengeText.text);
AutoFightModel.Instance.isAutoFinishTask = autoFinishTaskToggle.isOn;
+ AutoFightModel.Instance.hasAutoExchanged = false;
AutoFightModel.Instance.SaveAutoFightSetting();
CloseWindow();
SysNotifyMgr.Instance.ShowTip("autofight1");
@@ -362,6 +382,7 @@
AutoFightModel.Instance.fightCost = int.Parse(costText.text);
AutoFightModel.Instance.fightSpeed = int.Parse(speedText.text);
AutoFightModel.Instance.isStopFightByBetterEquip = betterEquipToggle.isOn;
+ AutoFightModel.Instance.isAutoChangeBetterEquip = autoChangeBetterEquipToggle.isOn;
AutoFightModel.Instance.isAutoChallengeBoss = autoChallengeBossToggle.isOn;
AutoFightModel.Instance.tryChallengeCount = int.Parse(tryChallengeText.text);
AutoFightModel.Instance.isAutoFinishTask = autoFinishTaskToggle.isOn;
diff --git a/Main/System/Setting/QuickSetting.cs b/Main/System/Setting/QuickSetting.cs
index cfee59f..9823211 100644
--- a/Main/System/Setting/QuickSetting.cs
+++ b/Main/System/Setting/QuickSetting.cs
@@ -24,6 +24,7 @@
quickSettingDic.Add(QuickSettingType.AutoFight_ChallengeBoss, new QuickSettingRange(QuickSettingType.AutoFight_ChallengeBoss, 18, 1));
quickSettingDic.Add(QuickSettingType.AutoFight_TryChallengeCount, new QuickSettingRange(QuickSettingType.AutoFight_TryChallengeCount, 19, 1));
quickSettingDic.Add(QuickSettingType.AutoFight_AutoFinishTask, new QuickSettingRange(QuickSettingType.AutoFight_AutoFinishTask, 20, 1));
+ quickSettingDic.Add(QuickSettingType.AutoFight_AutoChangeBetterEquip, new QuickSettingRange(QuickSettingType.AutoFight_AutoChangeBetterEquip, 21, 1));
setting = new string(UCharacter, 100);
DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= BeforePlayerDataInitializeEvent;
@@ -156,6 +157,7 @@
if (PlayerDatas.Instance.baseData.LV == 1 && !AutoFightModel.Instance.isStopFightByBetterEquip)
{
AutoFightModel.Instance.isStopFightByBetterEquip = true;
+ AutoFightModel.Instance.isAutoChangeBetterEquip = false;
AutoFightModel.Instance.SaveAutoFightSetting();
}
}
@@ -175,6 +177,7 @@
AutoFight_ChallengeBoss, //鑷姩鎸戞垬棣栭
AutoFight_TryChallengeCount, //鑷姩鎸戞垬棣栭锛屾垬璐娆″仠姝�
AutoFight_AutoFinishTask, //鑷姩瀹屾垚浠诲姟
+ AutoFight_AutoChangeBetterEquip, //鑷姩鏇挎崲楂樻垬鍔涜澶�
}
public class QuickSettingRange
--
Gitblit v1.8.0