From 8d9d42bfc92bef2a54448dfd5fcb688b8b3563e5 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期五, 30 一月 2026 17:52:01 +0800
Subject: [PATCH] 411 定军阁-客户端 自动战斗
---
Main/System/Settlement/BattleSettlementManager.cs | 2
Main/System/WarlordPavilion/WarlordPavilionManager.cs | 98 ++++++++++++++++++++++++
Main/System/WarlordPavilion/WarlordPavilionWin.cs | 16 ---
Main/System/Settlement/WarlordPavilionVictoryWin.cs | 61 +++++++++++++-
Main/System/Battle/BattleField/WarlordPavilionBattleField.cs | 9 -
5 files changed, 158 insertions(+), 28 deletions(-)
diff --git a/Main/System/Battle/BattleField/WarlordPavilionBattleField.cs b/Main/System/Battle/BattleField/WarlordPavilionBattleField.cs
index 4d2ec9c..edf6be1 100644
--- a/Main/System/Battle/BattleField/WarlordPavilionBattleField.cs
+++ b/Main/System/Battle/BattleField/WarlordPavilionBattleField.cs
@@ -10,7 +10,7 @@
{
}
-
+ WarlordPavilionManager manager { get { return WarlordPavilionManager.Instance; } }
public override void Init(int MapID, int FuncLineID, JsonData _extendData,
List<TeamBase> _redTeamList, List<TeamBase> _blueTeamList, byte turnMax)
{
@@ -63,12 +63,7 @@
{
AutoFightModel.Instance.isPause = false;
Destroy();
-
- if (UIManager.Instance.IsOpened<WarlordPavilionBattleWin>())
- {
- UIManager.Instance.CloseWindow<WarlordPavilionBattleWin>();
- UIManager.Instance.OpenWindow<WarlordPavilionWin>();
- }
+ manager.TryNext();
}
public override void Run()
diff --git a/Main/System/Settlement/BattleSettlementManager.cs b/Main/System/Settlement/BattleSettlementManager.cs
index bd29530..29bfb86 100644
--- a/Main/System/Settlement/BattleSettlementManager.cs
+++ b/Main/System/Settlement/BattleSettlementManager.cs
@@ -51,6 +51,7 @@
PopupWindowsProcessor.Instance.Add("TianziBillboradVictoryWin", false, BattleConst.TianziBillboradBattleField);
break;
case BattleConst.WarlordPavilionBattleField:
+ WarlordPavilionManager.Instance.isAutoNext = isWin;
PopupWindowsProcessor.Instance.Add(isWin ? "WarlordPavilionVictoryWin" : "WarlordPavilionFailWin", false, BattleConst.WarlordPavilionBattleField);
break;
default:
@@ -89,6 +90,7 @@
UIManager.Instance.OpenWindow<TianziBillboradVictoryWin>();
break;
case BattleConst.WarlordPavilionBattleField:
+ WarlordPavilionManager.Instance.isAutoNext = isWin;
if (isWin)
{
UIManager.Instance.OpenWindow<WarlordPavilionVictoryWin>();
diff --git a/Main/System/Settlement/WarlordPavilionVictoryWin.cs b/Main/System/Settlement/WarlordPavilionVictoryWin.cs
index dcacf58..b1a6406 100644
--- a/Main/System/Settlement/WarlordPavilionVictoryWin.cs
+++ b/Main/System/Settlement/WarlordPavilionVictoryWin.cs
@@ -6,9 +6,16 @@
{
[SerializeField] ButtonEx detailBtn;
[SerializeField] TextEx txtFuncName;
+ [SerializeField] Transform autoNext;
+ [SerializeField] TextEx txtTime;
+ [SerializeField] TextEx txtMax;
+ [SerializeField] ButtonEx btnNext;
+ [SerializeField] TextEx txtNext;
+
[SerializeField] ScrollerController scroller;
-
string battleName = BattleConst.WarlordPavilionBattleField;
+ bool hasNext = false;
+ WarlordPavilionManager manager { get { return WarlordPavilionManager.Instance; } }
protected override void InitComponent()
{
@@ -16,20 +23,41 @@
{
BattleSettlementManager.Instance.OpenBattleDetailWin(battleName);
});
+
+ btnNext.SetListener(() =>
+ {
+ CloseWindow();
+ });
}
protected override void OnPreOpen()
{
scroller.OnRefreshCell += OnRefreshCell;
+ GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
+ btnClickEmptyCloseEvent = OnPopConfirmCancelExBtn;
CreateScroller();
int funcId = (int)FuncOpenEnum.WarlordPavilion;
txtFuncName.text = FuncOpenLVConfig.HasKey(funcId) ? FuncOpenLVConfig.Get(funcId).Name : string.Empty;
+
+ bool isAutoFuncOpen = manager.IsAutoFuncOpen(false);
+ autoNext.SetActive(isAutoFuncOpen);
+ if (!isAutoFuncOpen)
+ return;
+ manager.GetCurrentFinishProgress(out int layerNum, out int levelNum);
+ hasNext = FBDJGLevelConfig.TryGetNextLevel(layerNum, levelNum, out int nextLayerNum, out int nextLevelNum);
+ manager.TryGetShowLayerNumAndLevelNum(out int showLayerNum, out int showLevelNum);
+ btnNext.SetActive(hasNext);
+ txtMax.SetActive(!hasNext);
+ txtNext.text = hasNext ? Language.Get("WarlordPavilion33", showLayerNum, showLevelNum) : string.Empty;
+ lastTime = TimeUtility.AllSeconds;
+ OnSecondEvent();
}
protected override void OnPreClose()
{
scroller.OnRefreshCell -= OnRefreshCell;
+ GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
BattleSettlementManager.Instance.WinShowOver(battleName);
}
@@ -64,17 +92,12 @@
scroller.Restart();
}
-
-
int SortItem(Item itemA, Item itemB)
{
var itemConfigA = ItemConfig.Get(itemA.id);
var itemConfigB = ItemConfig.Get(itemB.id);
return itemConfigB.ItemColor - itemConfigA.ItemColor;
}
-
-
-
void OnRefreshCell(ScrollerDataType type, CellView cell)
{
@@ -83,4 +106,30 @@
_cell?.Display(item.id, item.countEx);
}
+ private int lastTime = 0;
+ public int GetRemainingTime()
+ {
+ int nowTime = TimeUtility.AllSeconds;
+ int elapsed = nowTime - lastTime;
+ return elapsed >= manager.autoWaitTime ? 0 : manager.autoWaitTime - elapsed;
+ }
+
+ private void OnSecondEvent()
+ {
+ if (!manager.IsAutoFuncOpen(false))
+ return;
+ int remainingTime = GetRemainingTime();
+ txtTime.text = Language.Get("WarlordPavilion32", remainingTime);
+ if (remainingTime <= 0)
+ {
+ lastTime = TimeUtility.AllSeconds;
+ CloseWindow();
+ }
+ }
+
+ void OnPopConfirmCancelExBtn()
+ {
+ manager.isAutoNext = false;
+ CloseWindow();
+ }
}
\ No newline at end of file
diff --git a/Main/System/WarlordPavilion/WarlordPavilionManager.cs b/Main/System/WarlordPavilion/WarlordPavilionManager.cs
index 582461b..d96df4c 100644
--- a/Main/System/WarlordPavilion/WarlordPavilionManager.cs
+++ b/Main/System/WarlordPavilion/WarlordPavilionManager.cs
@@ -20,9 +20,16 @@
public int giftGirdMaxCnt; //鏁堟灉妲界殑鎬绘暟
public int bonusPresetMaxCnt; //棰勮鍔犳垚鏁堟灉鍙璁炬暟
public int[] funcOpenArr;
+ public int[] autoOpenArr;
public int openLayerNum;
public int openLevelNum;
public int openLV;
+
+ public int autoOpenLayerNum;
+ public int autoOpenLevelNum;
+ public int autoOpenLV;
+ public int autoWaitTime;
+
public int backLayerCnt; // 姣忔棩鍥為��灞傛暟锛屾瘡鏃ヤ粠鍥為��鍚庣殑灞傜1鍏冲紑濮嬫寫鎴橈紝鑻ュ洖閫�鍚庣殑灞傛暟澶т簬1锛屽垯寮哄埗闇�鍏堣繘琛屽揩閫熸寫鎴樻墠鑳界户缁寫鎴�
public int[] sortIndexList;
private int m_SelectEffID;
@@ -71,6 +78,8 @@
UpdateSelectReplaceGiftGirdIndexEvent?.Invoke();
}
}
+
+ public bool isAutoNext = true;
public event Action UpdateSelectReplaceGiftGirdIndexEvent;
public event Action UpdateSelectGiftGirdIndexEvent;
public event Action<List<int>> OnUpdateDingjungeInfoEvent;
@@ -93,7 +102,17 @@
openLayerNum = funcOpenArrNotExist ? 0 : funcOpenArr[0];
openLevelNum = funcOpenArrNotExist ? 0 : funcOpenArr[1];
openLV = funcOpenArrNotExist ? 0 : funcOpenArr[2];
+
+ autoOpenArr = JsonMapper.ToObject<int[]>(config.Numerical4);
+ bool autoOpenArrNotExist = funcOpenArr == null || funcOpenArr.Length < 3;
+ autoOpenLayerNum = funcOpenArrNotExist ? 0 : funcOpenArr[0];
+ autoOpenLevelNum = funcOpenArrNotExist ? 0 : funcOpenArr[1];
+ autoOpenLV = funcOpenArrNotExist ? 0 : funcOpenArr[2];
+
+ autoWaitTime = int.Parse(config.Numerical5);
}
+
+
public override void Release()
{
@@ -113,12 +132,14 @@
UnSelectCnt = 0;
SelectAuto = 0;
SelectSetAttrIDList = null;
+ isAutoNext = true;
}
private void PlayerDataRefresh(PlayerDataType type)
{
if (PlayerDataType.LV == type)
{
+ isAutoNext = true;
UpdateRedpoint();
}
}
@@ -166,6 +187,38 @@
return isOpen;
}
+ public bool IsAutoFuncOpen(bool isTip = false)
+ {
+ TryGetHistoryMaxFinishProgress(out int layerNum, out int levelNum);
+
+ int lv = PlayerDatas.Instance.baseData.LV;
+ bool isOpen = false;
+ if (lv >= autoOpenLV)
+ {
+ if (layerNum < autoOpenLayerNum)
+ {
+ isOpen = false;
+ }
+ else if (layerNum == autoOpenLayerNum)
+ {
+ isOpen = levelNum >= autoOpenLevelNum;
+ }
+ else
+ {
+ isOpen = true;
+ }
+ }
+ else
+ {
+ isOpen = false;
+ }
+
+ if (!isOpen && isTip)
+ {
+ SysNotifyMgr.Instance.ShowTip("WarlordPavilion01", autoOpenLayerNum, autoOpenLevelNum, autoOpenLV);
+ }
+ return isOpen;
+ }
public Redpoint parentRedpoint = new Redpoint(MainRedDot.WarlordPavilionRepoint);
public void UpdateRedpoint()
{
@@ -657,6 +710,50 @@
return true;
}
+ public void TryNext()
+ {
+ bool isOpenBattleChangeTab = FuncOpen.Instance.IsFuncOpen(ArenaManager.Instance.BattleChangeTabFuncId);
+ if (isOpenBattleChangeTab)
+ {
+ UIManager.Instance.GetUI<MainWin>()?.RestoreSubUI();
+ }
+ else
+ {
+ UIManager.Instance.OpenWindow<MainWin>();
+ }
+
+ if (!IsAutoFuncOpen(false))
+ {
+ UIManager.Instance.OpenWindow<WarlordPavilionWin>();
+ return;
+ }
+
+ GetCurrentFinishProgress(out int layerNum, out int levelNum);
+ bool hasNext = FBDJGLevelConfig.TryGetNextLevel(layerNum, levelNum, out int nextLayerNum, out int nextLevelNum);
+ if (!hasNext)
+ {
+ UIManager.Instance.OpenWindow<WarlordPavilionWin>();
+ return;
+ }
+
+ bool hasBonusToSelect = HasBonusToSelect();
+ bool isAutoPresetOn = IsAutoPresetOn();
+ if (hasBonusToSelect && !isAutoPresetOn)
+ {
+ UIManager.Instance.OpenWindow<WarlordPavilionWin>();
+ UIManager.Instance.OpenWindow<WarlordPavilionSelectBonusWin>();
+ return;
+ }
+
+ if (!isAutoNext)
+ {
+ UIManager.Instance.OpenWindow<WarlordPavilionWin>();
+ return;
+ }
+
+ BattleManager.Instance.SendTurnFight((uint)DataMapID, 0);
+ }
+
public void UpdateDingjungeInfo(HB202_tagSCDingjungeInfo vNetData)
{
@@ -667,6 +764,7 @@
SelectSetAttrIDList = vNetData.SelectSetAttrIDList;
List<int> effectIndexList = GetEffectIndexList(vNetData.EffList);
+ isAutoNext = true;
EffList = vNetData.EffList;
UpdateRedpoint();
OnUpdateDingjungeInfoEvent?.Invoke(effectIndexList);
diff --git a/Main/System/WarlordPavilion/WarlordPavilionWin.cs b/Main/System/WarlordPavilion/WarlordPavilionWin.cs
index 66a0d5f..2f788c1 100644
--- a/Main/System/WarlordPavilion/WarlordPavilionWin.cs
+++ b/Main/System/WarlordPavilion/WarlordPavilionWin.cs
@@ -82,7 +82,7 @@
UIManager.Instance.OpenWindow<WarlordPavilionBonusPresetWin>();
});
- funPresetBtn.AddListener(()=>
+ funPresetBtn.AddListener(() =>
{
FuncPresetManager.Instance.ClickBattlePreset((int)BattlePreSetType.Story);
});
@@ -114,20 +114,6 @@
for (int i = 0; i < giftCells.Length; i++)
{
giftCells[i].Display(i, indexs.Contains(i));
- }
- }
-
- private void OnUpdateViewNPCAttrRet(uint mapID, uint funcLineID)
- {
- if (mapID != manager.DataMapID)
- return;
- if (npcConfig == null)
- return;
- uint npcID = (uint)npcConfig.NPCID;
- if (ViewNPCManager.Instance.TryGetNPCAttr(mapID, funcLineID, npcID, out var npcAttr) && npcAttr != null && npcAttr.AttrDict != null)
- {
- AttributeManager.Instance.OpenTotalAttributeWin(npcAttr.AttrDict);
- return;
}
}
--
Gitblit v1.8.0