From a03d6a0b9a2d94809e6a17f92de4e3163e26a2f2 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期日, 31 八月 2025 23:58:45 +0800
Subject: [PATCH] 125 【战斗】战斗系统 - 主线战斗的关卡显示
---
Main/Core/GameEngine/Player/PlayerBaseData.cs | 8
Main/System/Boss/MainBossEnterWin.cs | 26 +++-
Main/Config/PartialConfigs/MainLevelConfig.cs.meta | 11 ++
Main/System/Main/AutoFightModel.cs | 23 ++++
Main/System/Main/MainLevelWaveCell.cs | 55 +++++++++++
Main/Core/GameEngine/Player/PlayerDatas.cs | 4
Main/System/Main/MainLevelWaveCell.cs.meta | 11 ++
Main/System/Main/HomeWin.cs | 107 +++++++++++++++++++++
Main/Config/PartialConfigs/MainLevelConfig.cs | 50 ++++++++++
9 files changed, 278 insertions(+), 17 deletions(-)
diff --git a/Main/Config/PartialConfigs/MainLevelConfig.cs b/Main/Config/PartialConfigs/MainLevelConfig.cs
new file mode 100644
index 0000000..d7b205b
--- /dev/null
+++ b/Main/Config/PartialConfigs/MainLevelConfig.cs
@@ -0,0 +1,50 @@
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+
+public partial class MainLevelConfig : ConfigBase<int, MainLevelConfig>
+{
+ static Dictionary<int, Dictionary<int, MainLevelConfig>> configDics = new Dictionary<int, Dictionary<int, MainLevelConfig>>();
+
+ protected override void OnConfigParseCompleted()
+ {
+ Dictionary<int, MainLevelConfig> tempDic = null;
+ if (!configDics.TryGetValue(ChapterID, out tempDic))
+ {
+ tempDic = new Dictionary<int, MainLevelConfig>();
+ configDics.Add(ChapterID, tempDic);
+ }
+
+ tempDic[LevelNum] = this;
+ }
+
+ public static MainLevelConfig GetMainLevelConfig(int chapterID, int LevelNum)
+ {
+ Dictionary<int, MainLevelConfig> tempDic = null;
+ if (!configDics.TryGetValue(chapterID, out tempDic))
+ {
+ return null;
+ }
+ MainLevelConfig config = null;
+ tempDic.TryGetValue(LevelNum, out config);
+ return config;
+ }
+
+ public static int GetwaveCount(MainLevelConfig config)
+ {
+ int[][] waveLineupLists = new int[][]
+ {
+ config.WaveLineupIDList1,
+ config.WaveLineupIDList2,
+ config.WaveLineupIDList3,
+ config.WaveLineupIDList4,
+ config.WaveLineupIDList5,
+ config.WaveLineupIDList6
+ };
+
+ // 缁熻闈炵┖鏁扮粍鐨勬暟閲�
+ return waveLineupLists.Count(list => list.Length > 0);
+ }
+
+
+}
\ No newline at end of file
diff --git a/Main/Config/PartialConfigs/MainLevelConfig.cs.meta b/Main/Config/PartialConfigs/MainLevelConfig.cs.meta
new file mode 100644
index 0000000..f9b1db0
--- /dev/null
+++ b/Main/Config/PartialConfigs/MainLevelConfig.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0c654df83f955ce4ca0495942771519c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Main/Core/GameEngine/Player/PlayerBaseData.cs b/Main/Core/GameEngine/Player/PlayerBaseData.cs
index f0f8fe1..cd63f6f 100644
--- a/Main/Core/GameEngine/Player/PlayerBaseData.cs
+++ b/Main/Core/GameEngine/Player/PlayerBaseData.cs
@@ -34,8 +34,8 @@
public byte FBID; //fb id
public byte realmLevel; //瀹樿亴
public byte VIPLv; //VIP绛夌骇
- public uint ExAttr1; // 绛栧垝閰嶇疆鍏冲崱ID涓�201锛屽嵆 杩囧叧2-1(0/1) ,浣跨敤 ExAttr1 鍊煎垽鏂紝濡侲xAttr1鍊间负20103浠h〃褰撳墠宸茬粡杩囦簡绗�2绔犵1鍏崇3娉紝鍖呭惈浜嗘尝锛岄渶瑕佸嚮璐ヨ鍏冲崱boss鍚庢墠绠楄鍏宠繃鍏�
- public uint teamAutoOperateFlag; //鎵╁睍灞炴��2锛屽悇椤圭洰涓撶敤
+ public int ExAttr1; // 绛栧垝閰嶇疆鍏冲崱ID涓�201锛屽嵆 杩囧叧2-1(0/1) ,浣跨敤 ExAttr1 鍊煎垽鏂紝濡侲xAttr1鍊间负20103浠h〃褰撳墠宸茬粡杩囦簡绗�2绔犵1鍏崇3娉紝鍖呭惈浜嗘尝锛岄渶瑕佸嚮璐ヨ鍏冲崱boss鍚庢墠绠楄鍏宠繃鍏�
+ public int ExAttr2; // 鐢ㄤ簬璁板綍涓荤嚎褰撳墠鍒锋�墍鍦ㄧ珷鑺傚叧鍗¤褰曪紝璁板綍鍊� = 绔犺妭*10000+鍏冲崱缂栧彿*100+绗瑇娉� 锛� 0418鍒锋柊绫诲瀷103
public int dungeonLineId; // 鍓湰绾胯矾id
public int dungeonMapId; // 鍓湰鐢ㄤ綔 DataMapId,鍗曚汉鍓湰瀛樺湪1.鍋囧壇鏈� 2.鏈嶅姟绔�1瀵瑰鎴风澶氬湴鍥惧悓鍒嗙嚎 3.鏈嶅姟绔�1瀵瑰鎴风澶氬湴鍥句笉鍚屽垎绾�
public uint shield; //鎶ょ浘鍊�
@@ -167,8 +167,8 @@
CON = _serverInfo.CON;
Setting = _serverInfo.Setting;
FBID = _serverInfo.FBID;
- ExAttr1 = _serverInfo.ExAttr1; //绛栧垝閰嶇疆鍏冲崱ID涓�201锛屽嵆 杩囧叧2-1(0/1) ,浣跨敤 ExAttr1 鍊煎垽鏂紝濡侲xAttr1鍊间负20103浠h〃褰撳墠宸茬粡杩囦簡绗�2绔犵1鍏崇3娉紝鍖呭惈浜嗘尝锛岄渶瑕佸嚮璐ヨ鍏冲崱boss鍚庢墠绠楄鍏宠繃鍏�
- teamAutoOperateFlag = _serverInfo.ExAttr2;
+ ExAttr1 = (int)_serverInfo.ExAttr1; //绛栧垝閰嶇疆鍏冲崱ID涓�201锛屽嵆 杩囧叧2-1(0/1) ,浣跨敤 ExAttr1 鍊煎垽鏂紝濡侲xAttr1鍊间负20103浠h〃褰撳墠宸茬粡杩囦簡绗�2绔犵1鍏崇3娉紝鍖呭惈浜嗘尝锛岄渶瑕佸嚮璐ヨ鍏冲崱boss鍚庢墠绠楄鍏宠繃鍏�
+ ExAttr2 = (int)_serverInfo.ExAttr2; //鐢ㄤ簬璁板綍涓荤嚎褰撳墠鍒锋�墍鍦ㄧ珷鑺傚叧鍗¤褰曪紝璁板綍鍊� = 绔犺妭*10000+鍏冲崱缂栧彿*100+绗瑇娉� 锛� 0418鍒锋柊绫诲瀷103
dungeonLineId = (int)_serverInfo.ExAttr3 % 1000;
dungeonMapId = (int)_serverInfo.ExAttr3 / 1000;
shield = _serverInfo.ExAttr4;
diff --git a/Main/Core/GameEngine/Player/PlayerDatas.cs b/Main/Core/GameEngine/Player/PlayerDatas.cs
index 99b278b..0c0811b 100644
--- a/Main/Core/GameEngine/Player/PlayerDatas.cs
+++ b/Main/Core/GameEngine/Player/PlayerDatas.cs
@@ -233,10 +233,10 @@
extersion.luckValue = (int)value;
break;
case PlayerDataType.ExAttr1:
- baseData.ExAttr1 = value;
+ baseData.ExAttr1 = (int)value;
break;
case PlayerDataType.ExAttr2:
- baseData.teamAutoOperateFlag = value;
+ baseData.ExAttr2 = (int)value;
break;
case PlayerDataType.ExAttr3:
baseData.dungeonLineId = (int)value % 1000;
diff --git a/Main/System/Boss/MainBossEnterWin.cs b/Main/System/Boss/MainBossEnterWin.cs
index 481cb72..83546ab 100644
--- a/Main/System/Boss/MainBossEnterWin.cs
+++ b/Main/System/Boss/MainBossEnterWin.cs
@@ -16,18 +16,22 @@
[SerializeField] Button CloseBtn;
[SerializeField] Button rankBtn;
+ [SerializeField] Button fightBtn;
+
protected override void InitComponent()
{
CloseBtn.AddListener(CloseWindow);
- rankBtn.AddListener(()=>
+ rankBtn.AddListener(() =>
{
RankModel.Instance.ResetQueryParam();
RankModel.Instance.QueryRankByPage(0, watchID: (int)PlayerDatas.Instance.baseData.PlayerID);
var win = UIManager.Instance.OpenWindow<PlayerRankWin>();
win.rankType = 0;
-
+
});
+
+ fightBtn.AddListener(FightBoss);
}
protected override void OnPreOpen()
@@ -35,21 +39,25 @@
}
- protected override void OnOpen()
- {
- }
protected override void OnPreClose()
{
}
- protected override void OnClose()
+ void Display()
{
- base.OnClose();
+ var canChallengeBoss = AutoFightModel.Instance.CanChallengeBoss();
+ fightBtn.interactable = canChallengeBoss;
+ fightBtn.SetColorful(null, canChallengeBoss);
}
-
-
+ void FightBoss()
+ {
+ if (AutoFightModel.Instance.CanChallengeBoss())
+ {
+ BattleManager.Instance.MainFightRequest(3);
+ }
+ }
}
diff --git a/Main/System/Main/AutoFightModel.cs b/Main/System/Main/AutoFightModel.cs
index 77d3471..8e9a422 100644
--- a/Main/System/Main/AutoFightModel.cs
+++ b/Main/System/Main/AutoFightModel.cs
@@ -211,7 +211,7 @@
public int fightingHeroSkinID; //褰撳墠鎴樻枟鐨勮嫳闆勭毊鑲D
public string heroGuid; //鎴樻枟涓殑姝﹀皢
- public event Action<bool> OnFightEvent; //鏄惁鎴樻枟閫氱煡
+ public event Action<bool> OnFightEvent; //鎴樻枟妯″紡鍙樻洿閫氱煡 鎴樻枟閲婃斁鎶�鑳介�氱煡
/// <summary>
@@ -243,6 +243,27 @@
OnFightEvent?.Invoke(true);
}
+ public bool CanChallengeBoss()
+ {
+ //鏈�鍚庝竴娉㈤�氳繃锛屼笖褰撳墠娉㈣繕鏄渶鍚庝竴娉紱鍊掗��鍙�掗��娉笉浼氬�掗��鍏冲崱
+ if (PlayerDatas.Instance.baseData.ExAttr2 != PlayerDatas.Instance.baseData.ExAttr1)
+ {
+ return false;
+ }
+ var value = PlayerDatas.Instance.baseData.ExAttr2;
+ var chapterID = value / 10000;
+ var levelNum = value % 10000 / 100;
+ var waveID = value % 100;
+
+ var config = MainLevelConfig.GetMainLevelConfig(chapterID, levelNum);
+ if (waveID < MainLevelConfig.GetwaveCount(config))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
#endregion
diff --git a/Main/System/Main/HomeWin.cs b/Main/System/Main/HomeWin.cs
index 08fd8b7..b1c52d6 100644
--- a/Main/System/Main/HomeWin.cs
+++ b/Main/System/Main/HomeWin.cs
@@ -25,12 +25,22 @@
//鍏冲崱
[SerializeField] Button bossBtn;
+ [SerializeField] MainLevelWaveCell[] mainLevelWaves;
+ [SerializeField] ScrollRect mainLevelScrollRect;
+ [SerializeField] Text levelName;
- [SerializeField] Button changeHeroPosBtn;
+ [SerializeField] GameObject restMark;
+ [SerializeField] Button restBtn;
+ [SerializeField] GameObject fightMark;
+ [SerializeField] ScaleTween bossTween;
+ [SerializeField] GameObject bossActiveGo;
+ [SerializeField] GameObject bitemeGo;
+ [SerializeField] Text processText;
//鍗$墝
[SerializeField] HeroFightingCardCell[] heroFightingCardCells;
+ [SerializeField] Button changeHeroPosBtn;
//搴曢儴鍔熻兘
[SerializeField] Button autoBtn;
@@ -104,6 +114,8 @@
return;
UIManager.Instance.OpenWindow<OfficialUpWin>();
});
+
+ restBtn.AddListener(GotoRest);
}
@@ -117,6 +129,8 @@
ShowBlessLV();
DisplayAutoFight();
DisplayCard(TeamType.Story);
+ DisplayLevel();
+ DisplayRestState();
}
@@ -126,6 +140,7 @@
TaskManager.Instance.OnTaskUpdate += UpdateTask;
BlessLVManager.Instance.OnBlessLVUpdateEvent += ShowBlessLV;
AutoFightModel.Instance.ChangeAutoEvent += DisplayAutoFight;
+ AutoFightModel.Instance.OnFightEvent += ChangeMode;
TeamManager.Instance.OnTeamChange += DisplayCard;
UIManager.Instance.OnCloseWindow += OnCloseWindow;
Display();
@@ -141,6 +156,7 @@
TaskManager.Instance.OnTaskUpdate -= UpdateTask;
BlessLVManager.Instance.OnBlessLVUpdateEvent -= ShowBlessLV;
AutoFightModel.Instance.ChangeAutoEvent -= DisplayAutoFight;
+ AutoFightModel.Instance.OnFightEvent -= ChangeMode;
TeamManager.Instance.OnTeamChange -= DisplayCard;
UIManager.Instance.OnCloseWindow -= OnCloseWindow;
@@ -158,6 +174,9 @@
break;
case PlayerDataType.LV:
playerLevelText.text = PlayerDatas.Instance.baseData.LV.ToString();
+ break;
+ case PlayerDataType.ExAttr2:
+ DisplayLevel();
break;
}
@@ -187,6 +206,8 @@
autoCloseImg.SetActive(true);
autoOpenEffect.Stop();
}
+
+
}
/// <summary>
@@ -269,4 +290,88 @@
DisplayCard(TeamType.Story);
}
}
+
+
+ private void DisplayLevel()
+ {
+ var value = PlayerDatas.Instance.baseData.ExAttr2;
+ var chapterID = value / 10000;
+ var levelNum = value % 10000 / 100;
+ var waveID = value % 100;
+
+ var config = MainLevelConfig.GetMainLevelConfig(chapterID, levelNum);
+ var totalWave = MainLevelConfig.GetwaveCount(config);
+ for (int i = 0; i < mainLevelWaves.Length; i++)
+ {
+ if (i < totalWave)
+ {
+ mainLevelWaves[i].SetActive(true);
+ mainLevelWaves[i].Display(i);
+ }
+ else
+ {
+ mainLevelWaves[i].SetActive(false);
+ }
+ }
+
+ mainLevelScrollRect.normalizedPosition = new Vector2(waveID > 2 ? 0.95f : 0, 0);
+
+ var chapterConfig = MainChapterConfig.Get(chapterID);
+ //銆愭櫘閫氥�戝叧鍗″悕瀛�1-6
+ levelName.text = Language.Get("mainui7", chapterConfig.Level, chapterConfig.ChapterName, chapterID, levelNum);
+
+ bool canChallengeBoss = AutoFightModel.Instance.CanChallengeBoss();
+ //BOSS
+ if (canChallengeBoss)
+ {
+ bossActiveGo.SetActive(true);
+ processText.SetActive(false);
+ bossTween.Play();
+ bitemeGo.SetActive(true);
+ }
+ else
+ {
+ bossActiveGo.SetActive(false);
+ processText.SetActive(true);
+ processText.text = (waveID - 1) * 100 / totalWave + "%";
+ bossTween.Stop();
+ bitemeGo.SetActive(false);
+ }
+
+ }
+
+ void DisplayRestState()
+ {
+ if (BattleManager.Instance.storyBattleField != null &&
+ BattleManager.Instance.storyBattleField.GetBattleMode() == BattleMode.Stop)
+ {
+ //浼戞伅涓�
+ restMark.SetActive(true);
+ fightMark.SetActive(false);
+ }
+ else
+ {
+ //鎴樻枟涓�
+ restMark.SetActive(false);
+ fightMark.SetActive(true);
+ }
+
+ }
+
+ void ChangeMode(bool isFight)
+ {
+ if (isFight)
+ return;
+ DisplayRestState();
+ DisplayLevel();
+ }
+
+ void GotoRest()
+ {
+ if (BattleManager.Instance.storyBattleField != null &&
+ BattleManager.Instance.storyBattleField.GetBattleMode() != BattleMode.Stop)
+ {
+ BattleManager.Instance.storyBattleField.HaveRest();
+ }
+ }
}
\ No newline at end of file
diff --git a/Main/System/Main/MainLevelWaveCell.cs b/Main/System/Main/MainLevelWaveCell.cs
new file mode 100644
index 0000000..9e36913
--- /dev/null
+++ b/Main/System/Main/MainLevelWaveCell.cs
@@ -0,0 +1,55 @@
+锘縰sing UnityEngine;
+using UnityEngine.UI;
+using System.Collections.Generic;
+
+
+//涓荤嚎鍏冲崱鐨� 娉㈡鏄剧ず
+public class MainLevelWaveCell : MonoBehaviour
+{
+
+ [SerializeField] GameObject passLevelBG; //宸查�氬叧鍜屾鍦ㄩ�氬叧鐨�
+ [SerializeField] Image passMark; //宸查�氬叧鐨勬爣璁�
+ [SerializeField] GameObject nowLevelMark; //褰撳墠鍏冲崱
+ [SerializeField] Image levelMark; //鍏冲崱鐨勬爣璁� 绫讳技绮捐嫳鍏筹紝闅忔満鍏崇殑鏍囪瘑锛涗紤鎭椂鍜屾湭閫氬叧鏄剧ず
+
+
+
+
+ //index浠�0寮�濮�
+ public void Display(int index)
+ {
+ var theWave = index + 1;
+ //ExAttr2 鐢ㄤ簬璁板綍涓荤嚎褰撳墠鍒锋�墍鍦ㄧ珷鑺傚叧鍗¤褰曪紝璁板綍鍊� = 绔犺妭*10000+鍏冲崱缂栧彿*100+绗瑇娉� 锛� 0418鍒锋柊绫诲瀷103
+ var value = PlayerDatas.Instance.baseData.ExAttr2;
+ var waveID = value % 100;
+
+ passLevelBG.SetActive(theWave <= waveID);
+ levelMark.SetActive(theWave >= waveID);
+ passMark.SetActive(theWave < waveID);
+
+ if (theWave == waveID)
+ {
+
+ if (BattleManager.Instance.storyBattleField != null &&
+ BattleManager.Instance.storyBattleField.GetBattleMode() == BattleMode.Stop)
+ {
+ levelMark.SetActive(true);
+ nowLevelMark.SetActive(false);
+ }
+ else
+ {
+ nowLevelMark.SetActive(true);
+ levelMark.SetActive(false);
+ }
+ }
+ else
+ {
+ nowLevelMark.SetActive(false);
+ }
+
+ levelMark.SetSprite("MainBossMark" + (index % 2));
+ levelMark.SetNativeSize();
+ }
+
+}
+
diff --git a/Main/System/Main/MainLevelWaveCell.cs.meta b/Main/System/Main/MainLevelWaveCell.cs.meta
new file mode 100644
index 0000000..6ddff7f
--- /dev/null
+++ b/Main/System/Main/MainLevelWaveCell.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1f64b59c72b52da41bc3065533b7eef6
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
--
Gitblit v1.8.0