From af0d59c2da7eb91de99d568ed17cbf2aa441f5b3 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 15 一月 2026 23:24:15 +0800
Subject: [PATCH] 429 【主界面】自动挂机-补充自动挑战自动任务
---
Main/System/Main/AutoFightModel.cs | 105 +++++++++++++++++++++++--
Main/System/Settlement/BattleSettlementManager.cs | 9 ++
Main/System/Main/HomeWin.cs | 9 --
Main/System/Battle/BattleField/OperationAgent/AutoModeOperationAgent.cs | 70 +++++++++++------
Main/System/KnapSack/Logic/ItemLogicUtility.cs | 2
Main/System/Main/AutoFightWin.cs | 25 ++----
6 files changed, 159 insertions(+), 61 deletions(-)
diff --git a/Main/System/Battle/BattleField/OperationAgent/AutoModeOperationAgent.cs b/Main/System/Battle/BattleField/OperationAgent/AutoModeOperationAgent.cs
index d72f5d3..80913fc 100644
--- a/Main/System/Battle/BattleField/OperationAgent/AutoModeOperationAgent.cs
+++ b/Main/System/Battle/BattleField/OperationAgent/AutoModeOperationAgent.cs
@@ -10,40 +10,19 @@
}
float lastTime;
- float lastSendTime;
public override void Run()
{
- //鏈�浣�1绉�
- if (Time.time - lastTime < 0.2f)
+ if (Time.time - lastTime < 0.3f)
return;
lastTime = Time.time;
+
if (AutoFightModel.Instance.isPause)
return;
+
// 鑷姩鎸戞垬boss
- if (AutoFightModel.Instance.isAutoChallengeBoss)
+ if (AutoChallengeBoss())
{
- if (!MainLevelManager.Instance.CanChallengeBoss())
- {
- DoNext();
- return;
- }
- //涓婃鎸戞垬boss澶辫触浜嗭紝鍐嶆灏濊瘯瑕佺瓑CD
- if (AutoFightModel.Instance.nowChallengeCount > 0 &&
- Time.time - AutoFightModel.Instance.lastChallengeTime < AutoFightModel.Instance.maxTryChallengeCD)
- {
- DoNext();
- return;
- }
- //宸茬粡寮�濮媌oss鎴樻枟
- BattleField battleField = BattleManager.Instance.GetActiveBattleFieldByName(BattleConst.StoryBossBattleField);
- if (battleField != null)
- return;
- if (Time.time - lastSendTime < 1.0f)
- return;
- lastSendTime = Time.time;
- Debug.Log($"寮�濮嬫寫鎴榖oss ServerNow{TimeUtility.ServerNow}");
- FightBoss();
return;
}
DoNext();
@@ -60,4 +39,45 @@
BattleManager.Instance.storyBattleField.CleanBattle();
AutoFightModel.Instance.isPause = true;
}
+
+ bool AutoChallengeBoss()
+ {
+ // 鑷姩鎸戞垬boss
+ if (AutoFightModel.Instance.isAutoChallengeBoss)
+ {
+ if (AutoFightModel.Instance.nowChallengeCount == -1)
+ {
+ return false;
+ }
+ if (!MainLevelManager.Instance.CanChallengeBoss())
+ {
+ return false;
+ }
+ //涓婃鎸戞垬boss澶辫触浜嗭紝鍐嶆灏濊瘯瑕佺瓑CD
+ if (Time.time - AutoFightModel.Instance.lastChallengeTime < AutoFightModel.Instance.maxTryChallengeCD)
+ {
+ return false;
+ }
+
+ if (!UIManager.Instance.IsOpened<HomeWin>())
+ {
+ return false;
+ }
+
+ if (NewBieCenter.Instance.inGuiding)
+ {
+ return false;
+ }
+
+ if (UIManager.Instance.ExistAnyFullScreenOrMaskWin(""))
+ {
+ return false;
+ }
+ FightBoss();
+ return true;
+ }
+ return false;
+ }
+
+
}
\ No newline at end of file
diff --git a/Main/System/KnapSack/Logic/ItemLogicUtility.cs b/Main/System/KnapSack/Logic/ItemLogicUtility.cs
index 58c40e0..3a85a90 100644
--- a/Main/System/KnapSack/Logic/ItemLogicUtility.cs
+++ b/Main/System/KnapSack/Logic/ItemLogicUtility.cs
@@ -1184,7 +1184,7 @@
// 濡傛灉鍚屾椂鏈夊绉嶅鍔卞皝鍖咃紝鍚屼竴涓簨浠跺綊闆嗭紝涓嶅悓浜嬩欢鐩存帴椤舵帀鏄剧ず鏈�鏂�
public Dictionary<Int2, Item> totalShowItems = new Dictionary<Int2, Item>(); //Int2 鐗╁搧ID+useType
public event Action OnGetItemShowEvent;
- private string getItemEventName;
+ public string getItemEventName;
public string sourceTip; //棰嗗鍘熷洜
// isMergeItem 鏄惁鍚堝苟鐩稿悓ID鐨勭墿鍝� 榛樿鍚堝苟
diff --git a/Main/System/Main/AutoFightModel.cs b/Main/System/Main/AutoFightModel.cs
index 1eecad8..f76e468 100644
--- a/Main/System/Main/AutoFightModel.cs
+++ b/Main/System/Main/AutoFightModel.cs
@@ -1,4 +1,5 @@
锘縰sing System;
+using System.Collections.Generic;
using LitJson;
using UnityEngine;
@@ -92,7 +93,7 @@
}
}
- //褰撳墠鎴樿触浜唜娆�
+ //褰撳墠鎴樿触浜唜娆★紱-1浠h〃鍋滄缁х画鎸戞垬
private int m_NowChallengeCount = 0;
public float lastChallengeTime = 0;
public int nowChallengeCount
@@ -105,9 +106,7 @@
Debug.Log($"褰撳墠鍦ㄤ富绾緽oss鎴樿触浜唟m_NowChallengeCount}娆�,涓婃鎴樿触鏃堕棿鏄瘂lastChallengeTime}");
if (m_NowChallengeCount >= tryChallengeCount)
{
- isAutoAttackSet = false;
- isAutoAttack = false;
- SaveAutoFightSetting();
+ m_NowChallengeCount = -1; //浠h〃鍋滄缁х画鎸戞垬
}
}
}
@@ -145,10 +144,11 @@
public int[] autoCostWithBlessLV; //鑷姩鎴樻枟娑堣�楀�嶆暟鍏宠仈绁濈绛夌骇
public int speed2UnlockMissionID;
- public int openAutoChallengeBossMissionID;//鑷姩鎸戞垬棣栭瑙i攣鐨勪换鍔D(闇�瀹屾垚)
- public int maxTryChallengeCount;//鑷姩鎸戞垬棣栭鏈�澶ф垬璐ユ鏁帮紙涓嬫媺鍒楄〃鐨勬渶澶у�硷級
- public int maxTryChallengeCD;
- public int openAutoFinishMissionID;//鑷姩瀹屾垚浠诲姟瑙i攣鐨勪换鍔D(闇�瀹屾垚)
+ public int openAutoChallengeBossCond;//鏁板��1锛氳嚜鍔ㄦ寫鎴橀棰嗚В閿佺殑鍏冲崱锛堥渶杩囧叧锛�
+ public int maxTryChallengeCount;//鏈�澶ф垬璐ユ鏁帮紙涓嬫媺鍒楄〃鐨勬渶澶у�硷級瑙i攣鏈堝崱鏈夋晥
+ public int maxTryChallengeCD; //鎵撲富绾縝oss鎴樿触鍚庯紝闂撮殧x绉掑悗閲嶈瘯
+ public int openAutoFinishCond;//鑷姩瀹屾垚浠诲姟闇�绁濈鏍慩绾�
+ public int autoCloseWinCD;
public override void Init()
{
@@ -160,6 +160,7 @@
BlessLVManager.Instance.OnBlessLVUpdateEvent += UpdateRedpint;
TaskManager.Instance.OnTaskUpdate += OnTaskUpdate;
InvestModel.Instance.onInvestUpdate += OnInvestUpdate;
+ GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
}
@@ -172,6 +173,7 @@
BlessLVManager.Instance.OnBlessLVUpdateEvent -= UpdateRedpint;
TaskManager.Instance.OnTaskUpdate -= OnTaskUpdate;
InvestModel.Instance.onInvestUpdate -= OnInvestUpdate;
+ GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
}
@@ -181,11 +183,12 @@
autoCostWithBlessLV = JsonMapper.ToObject<int[]>(config.Numerical1);
speed2UnlockMissionID = int.Parse(config.Numerical2);
maxCost = autoCostWithBlessLV.Length;
+ autoCloseWinCD = int.Parse(config.Numerical3);
config = FuncConfigConfig.Get("AutoGuaji1");
- openAutoChallengeBossMissionID = int.Parse(config.Numerical1);
+ openAutoChallengeBossCond = int.Parse(config.Numerical1);
maxTryChallengeCount = int.Parse(config.Numerical2);
maxTryChallengeCD = int.Parse(config.Numerical3);
- openAutoFinishMissionID = int.Parse(config.Numerical4);
+ openAutoFinishCond = int.Parse(config.Numerical4);
}
@@ -200,6 +203,88 @@
nowChallengeCount = 0;
}
+ Dictionary<string, int> winWaitCloseDict = new Dictionary<string, int>();
+ void OnSecondEvent()
+ {
+ ProccessCloseWin();
+ }
+ void ProccessCloseWin()
+ {
+ if (!isAutoAttack)
+ return;
+ if (isAutoChallengeBoss)
+ {
+ if (UIManager.Instance.IsOpened<BattleVictoryWin>())
+ {
+ if (!winWaitCloseDict.ContainsKey("BattleVictoryWin"))
+ {
+ winWaitCloseDict["BattleVictoryWin"] = 0;
+ }
+
+ if (winWaitCloseDict["BattleVictoryWin"] == 0)
+ {
+ winWaitCloseDict["BattleVictoryWin"] = (int)Time.time;
+ }
+ else if (Time.time - winWaitCloseDict["BattleVictoryWin"] > AutoFightModel.Instance.autoCloseWinCD)
+ {
+ UIManager.Instance.CloseWindow<BattleVictoryWin>();
+ winWaitCloseDict["BattleVictoryWin"] = 0;
+ }
+ }
+
+ if (UIManager.Instance.IsOpened<BattleFailWin>())
+ {
+ if (!winWaitCloseDict.ContainsKey("BattleFailWin"))
+ {
+ winWaitCloseDict["BattleFailWin"] = 0;
+ }
+
+ if (winWaitCloseDict["BattleFailWin"] == 0)
+ {
+ winWaitCloseDict["BattleFailWin"] = (int)Time.time;
+ }
+ else if (Time.time - winWaitCloseDict["BattleFailWin"] > autoCloseWinCD)
+ {
+ UIManager.Instance.CloseWindow<BattleFailWin>();
+ winWaitCloseDict["BattleFailWin"] = 0;
+ }
+ }
+ }
+
+ if (isAutoFinishTask)
+ {
+ if (TaskManager.Instance.GetMainTaskState() == 2 && UIManager.Instance.IsOpened<HomeWin>()
+ && !UIManager.Instance.ExistAnyFullScreenOrMaskWin("") && !NewBieCenter.Instance.inGuiding)
+ {
+ //棰嗗彇浠诲姟濂栧姳
+ CA504_tagCMPlayerGetReward getReward = new CA504_tagCMPlayerGetReward();
+ getReward.RewardType = 66;
+ getReward.DataEx = (uint)TaskManager.Instance.mainTask.TaskID;
+ GameNetSystem.Instance.SendInfo(getReward);
+ return;
+ }
+
+ if (UIManager.Instance.IsOpened<CommonGetItemWin>() && ItemLogicUtility.Instance.getItemEventName == "Task")
+ {
+ if (!winWaitCloseDict.ContainsKey("CommonGetItemWin"))
+ {
+ winWaitCloseDict["CommonGetItemWin"] = 0;
+ }
+
+ if (winWaitCloseDict["CommonGetItemWin"] == 0)
+ {
+ winWaitCloseDict["CommonGetItemWin"] = (int)Time.time;
+ }
+ else if (Time.time - winWaitCloseDict["CommonGetItemWin"] > autoCloseWinCD)
+ {
+ UIManager.Instance.CloseWindow<CommonGetItemWin>();
+ winWaitCloseDict["CommonGetItemWin"] = 0;
+ }
+ }
+ }
+ }
+
+
public void SaveAutoFightSetting()
{
if (PlayerDatas.Instance.baseData.UseHarmerCount != fightCost)
diff --git a/Main/System/Main/AutoFightWin.cs b/Main/System/Main/AutoFightWin.cs
index cedfa01..f9472f8 100644
--- a/Main/System/Main/AutoFightWin.cs
+++ b/Main/System/Main/AutoFightWin.cs
@@ -82,9 +82,9 @@
autoChallengeBossToggle.AddListener((bool value) =>
{
- if (!IsOpenTryChallenge(out int needtaskCount))
+ if (!IsOpenTryChallenge())
{
- SysNotifyMgr.Instance.ShowTip("autofight2", needtaskCount);
+ SysNotifyMgr.Instance.ShowTip("autofight5", AutoFightModel.Instance.openAutoChallengeBossCond / 100, AutoFightModel.Instance.openAutoChallengeBossCond % 100);
autoChallengeBossToggle.SetIsOnWithoutNotify(false);
return;
}
@@ -93,9 +93,9 @@
autoFinishTaskToggle.AddListener((bool value) =>
{
- if (!IsOpenAutoFinishTask(out int needtaskCount))
+ if (!IsOpenAutoFinishTask())
{
- SysNotifyMgr.Instance.ShowTip("autofight2", needtaskCount);
+ SysNotifyMgr.Instance.ShowTip("autofight4", AutoFightModel.Instance.openAutoFinishCond);
autoFinishTaskToggle.SetIsOnWithoutNotify(false);
return;
}
@@ -135,16 +135,14 @@
speedScroll.OnRefreshCell -= OnRefreshSpeedCell;
tryChallengeScroll.OnRefreshCell -= OnRefreshTryChallengeCell;
}
- bool IsOpenTryChallenge(out int needtaskCount)
+ bool IsOpenTryChallenge()
{
- needtaskCount = TaskManager.Instance.GetNeedFinishTaskCount(AutoFightModel.Instance.openAutoChallengeBossMissionID);
- return needtaskCount <= 0;
+ return PlayerDatas.Instance.baseData.ExAttr1 / 100 > AutoFightModel.Instance.openAutoChallengeBossCond;
}
- bool IsOpenAutoFinishTask(out int needtaskCount)
+ bool IsOpenAutoFinishTask()
{
- needtaskCount = TaskManager.Instance.GetNeedFinishTaskCount(AutoFightModel.Instance.openAutoChallengeBossMissionID);
- return needtaskCount <= 0;
+ return BlessLVManager.Instance.m_TreeLV >= AutoFightModel.Instance.openAutoFinishCond;
}
void DislayTip(string key, Vector3 worldPos)
@@ -304,18 +302,13 @@
void OnRefreshTryChallengeCell(ScrollerDataType type, CellView cell)
{
- bool isOpen = IsOpenTryChallenge(out int needtaskCount);
+ bool isOpen = IsOpenTryChallenge();
bool isbuy = InvestModel.Instance.IsInvested(InvestModel.monthCardType);
var btn = cell.GetComponent<Button>();
btn.AddListener(() =>
{
if (cell.index != 1)
{
- if (!isOpen)
- {
- SysNotifyMgr.Instance.ShowTip("autofight2", needtaskCount);
- return;
- }
if (!isbuy)
{
SysNotifyMgr.Instance.ShowTip("autofight3");
diff --git a/Main/System/Main/HomeWin.cs b/Main/System/Main/HomeWin.cs
index 222a427..276f012 100644
--- a/Main/System/Main/HomeWin.cs
+++ b/Main/System/Main/HomeWin.cs
@@ -588,14 +588,7 @@
}
awardIcon.SetItemSprite(taskConfig.AwardItemList[0][0]);
awardCnt.text = taskConfig.AwardItemList[0][1].ToString();
- if (AutoFightModel.Instance.isAutoFinishTask)
- {
- if (TaskManager.Instance.GetMainTaskState() != 2)
- {
- return;
- }
- OnClickTaskButton();
- }
+
}
}
diff --git a/Main/System/Settlement/BattleSettlementManager.cs b/Main/System/Settlement/BattleSettlementManager.cs
index 75e8410..effc78c 100644
--- a/Main/System/Settlement/BattleSettlementManager.cs
+++ b/Main/System/Settlement/BattleSettlementManager.cs
@@ -153,7 +153,14 @@
if (battleName == BattleConst.StoryBossBattleField)
{
- AutoFightModel.Instance.nowChallengeCount += result != 1 ? 1 : 0;
+ if (result == 1)
+ {
+ AutoFightModel.Instance.nowChallengeCount = 0;
+ }
+ else
+ {
+ AutoFightModel.Instance.nowChallengeCount += 1;
+ }
}
if (battleName == activeBattleName)
--
Gitblit v1.8.0