From a7f4c5ecc5268c49f6a6caf769b3ebee6f237662 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 04 六月 2025 18:52:55 +0800
Subject: [PATCH] 目录迁移 整理
---
Main/System/Battle/BattleField/BattleField.cs.meta | 0
Main/System/Battle/Motion/MotionBase.cs | 0
Main/System/Battle/Motion/MotionBase.cs.meta | 0
Main/Utility/EffectPenetrationBlocker.cs | 0
Main/System/Chat/ChatCenter.cs | 0
Main/System/Battle/RecordPlayer.meta | 0
Main/System/Card/CardType.cs.meta | 0
Main/Common/StructEx.cs.meta | 0
Main/System/Card/CardSkillMgr.cs.meta | 0
Main/System/ClientVersion/VersionConfig.cs | 0
Main/System/Team/TeamBase.Properties.cs.meta | 0
Main/System/Team/TeamConst.cs | 0
Main/System/Battle/BattleObject/BattleObjMgr.cs.meta | 0
Main/System/Chat/ChatBubbleManager.cs.meta | 0
Main/System/Battle/RecordPlayer/RecordActionType.cs | 0
Main/System/Battle.meta | 0
Main/System/KnapSack/VirtualPackManager.cs | 726 ++--
Main/System/ClientVersion/VersionUtility.cs.meta | 0
Main/System/ClientVersion/VersionConfig.cs.meta | 0
Main/System/UIBase/OneLevelWin.cs.meta | 0
Main/System/Battle/RecordPlayer/RecordAction.cs.meta | 0
Main/System/Card/CardInfo.cs | 0
Main/System/Team/TeamCard.cs | 0
Main/System/Battle/BattleObject/CardObject.cs | 0
Main/System/KnapSack/PackManager.cs.meta | 0
Main/System/UIBase/UIBase.cs.meta | 0
Main/System/Battle/BattleMode.cs | 0
Main/System/Team/TeamBase.Properties.cs | 0
Main/System/Place/PlaceWin.cs.meta | 0
Main/System/KnapSack/VirtualPackManager.cs.meta | 0
Main/System/KnapSack/PackManager.cs | 3804 ++++++++++----------
Main/System/Login/ServerListCenter.cs.meta | 0
Main/System/Battle/BattleObject/BattleObjectFactory.cs.meta | 0
Main/System/Chat/ChatCenter.cs.meta | 0
Main/System/Battle/BattleObject/CardObject.cs.meta | 0
Main/System/Battle/Motion/MotionName.cs | 0
Main/System/Battle/Motion.meta | 0
Main/System/Battle/BattleObject.meta | 0
Main/System/Login/ServerListParser.cs.meta | 0
Main/System/Battle/Motion/MotionName.cs.meta | 0
Main/System/Battle/BattleObject/BattleObjMgr.cs | 0
Main/System/Main/MainWin.cs | 406 +-
Main/System/GMCommand/GMCmdManager.cs.meta | 0
Main/System/Login/ServerData.cs.meta | 0
Main/ResModule/ResManager.cs.meta | 0
Main/System/Main.meta | 2
Main/System/Login/ServerData.cs | 0
Main/System/Place.meta | 0
Main/System/Battle/RecordPlayer/RecordPlayer.cs.meta | 0
Main/System/Card/CardType.cs | 0
Main/System/ClientVersion/VersionUtility.cs | 0
Main/System/Mail/MailManager.cs.meta | 0
Main/System/Main/MainWin.cs.meta | 0
Main/Utility/EffectPenetrationBlocker.cs.meta | 0
Main/ResModule/ResManager.cs | 0
Main/System/Battle/BattleMode.cs.meta | 0
Main/System/Card.meta | 0
Main/System/UIBase/OneLevelWin.cs | 0
Main/System/Team/TeamCard.cs.meta | 0
Main/System/GMCommand/GMCmdManager.cs | 0
Main/System/Battle/BattleObject/BattleObject.cs | 0
Main/System/Chat/ChatBubbleManager.cs | 0
Main/System/Launch/LoadingWin.cs | 144
Main/System/Card/CardInfo.Properties.cs.meta | 0
Main/System/Battle/BattleObject/BattleObject.cs.meta | 0
Main/System/Task/TaskManager.cs | 0
Main/Manager/UIManager.cs | 1842 +++++-----
Main/System/Login/ServerListCenter.cs | 0
Main/System/Chat/ChatManager.cs.meta | 0
Main/System/UIBase/UIBase.cs | 1628 ++++----
Main/System/Battle/BattleManager.cs.meta | 0
Main/System/Card/CardInfo.Properties.cs | 0
Main/System/Team/TeamConst.cs.meta | 0
Main/System/Login/LoginManager.cs | 766 ++--
Main/System/Team/TeamBase.cs.meta | 0
Main/System/Login/ServerListParser.cs | 0
Main/System/Chat/ChatManager.cs | 0
Main/Config/ConfigManager.cs | 516 +-
Main/System/Battle/BattleObject/BattleObjectFactory.cs | 0
Main/System/Team.meta | 0
Main/System/Mail/MailManager.cs | 666 +-
Main/System/Battle/BattleField/BattleField.cs | 0
Main/System/Card/CardSkillMgr.cs | 0
Main/Config/ConfigManager.cs.meta | 0
Main/System/Login/LoginManager.cs.meta | 0
Main/System/Place/PlaceWin.cs | 124
Main/System/Battle/BattleField.meta | 0
Main/System/Team/TeamBase.cs | 0
Main/System/Task/TaskManager.cs.meta | 0
Main/System/Battle/BattleManager.cs | 84
Main/System/Task.meta | 2
Main/System/Card/CardInfo.cs.meta | 0
Main/System/Launch/LoadingWin.cs.meta | 0
Main/System/UIBase.meta | 2
Main/Common/StructEx.cs | 0
/dev/null | 11
Main/System/Battle/RecordPlayer/RecordAction.cs | 0
Main/System/Battle/RecordPlayer/RecordPlayer.cs | 0
Main/Manager/UIManager.cs.meta | 0
Main/System/Battle/RecordPlayer/RecordActionType.cs.meta | 0
100 files changed, 5,356 insertions(+), 5,367 deletions(-)
diff --git a/Main/Card/Motion.meta b/Main/Card/Motion.meta
deleted file mode 100644
index 8ab6d6e..0000000
--- a/Main/Card/Motion.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 613ebae9f200e9d43b75a053fd050971
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/Common/LitJson.meta b/Main/Common/LitJson.meta
deleted file mode 100644
index 8aa4caa..0000000
--- a/Main/Common/LitJson.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 6b7dc6b26b92f9c4193d59105f975880
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/Temp/StructEx.cs b/Main/Common/StructEx.cs
similarity index 100%
rename from Main/Temp/StructEx.cs
rename to Main/Common/StructEx.cs
diff --git a/Main/Temp/StructEx.cs.meta b/Main/Common/StructEx.cs.meta
similarity index 100%
rename from Main/Temp/StructEx.cs.meta
rename to Main/Common/StructEx.cs.meta
diff --git a/Main/Manager/ConfigManager.cs b/Main/Config/ConfigManager.cs
similarity index 99%
rename from Main/Manager/ConfigManager.cs
rename to Main/Config/ConfigManager.cs
index d50013c..b884d3f 100644
--- a/Main/Manager/ConfigManager.cs
+++ b/Main/Config/ConfigManager.cs
@@ -1,258 +1,258 @@
-using System;
-using System.Collections.Generic;
-using UnityEngine;
-using Cysharp.Threading.Tasks;
-using System.Reflection;
-
-
-public class ConfigManager : ManagerBase<ConfigManager>
-{
- public bool isLoadFinished
- {
- get;
- private set;
- }
-
- private float loadingProgress = 0f;
-
- public override void Init()
- {
- base.Init();
- InitConfigs();
- }
-
- public virtual async UniTask InitConfigs()
- {
- // 鍔犺浇閰嶇疆鏂囦欢
- await LoadConfigs();
- }
-
- protected async UniTask LoadConfigs()
- {
- loadingProgress = 0f;
- isLoadFinished = false;
-
- // 鍔犺浇閰嶇疆鏂囦欢
- int totalConfigs = 41;
- Type[] configTypes = new Type[] {
- typeof(AppointItemConfig),
- typeof(AudioConfig),
- typeof(ChestsAwardConfig),
- typeof(ChestsConfig),
- typeof(CTGConfig),
- typeof(CTGSelectItemConfig),
- typeof(DienstgradConfig),
- typeof(DirtyWordConfig),
- typeof(EffectConfig),
- typeof(EmojiPackConfig),
- typeof(FaceConfig),
- typeof(FamilyConfig),
- typeof(FuncConfigConfig),
- typeof(FuncOpenLVConfig),
- typeof(FunctionTeamSetConfig),
- typeof(GetItemWaysConfig),
- typeof(GmCmdConfig),
- typeof(GuideConfig),
- typeof(IconConfig),
- typeof(InitialFunctionConfig),
- typeof(ItemConfig),
- typeof(KickOutReasonConfig),
- typeof(LanguageConfig),
- typeof(MailConfig),
- typeof(NPCConfig),
- typeof(NPCExConfig),
- typeof(OrderInfoConfig),
- typeof(PlayerFaceConfig),
- typeof(PlayerFacePicConfig),
- typeof(PlayerFacePicStarConfig),
- typeof(PlayerFaceStarConfig),
- typeof(PlayerLVConfig),
- typeof(priorbundleConfig),
- typeof(PriorLanguageConfig),
- typeof(RichTextMsgReplaceConfig),
- typeof(RuleConfig),
- typeof(SkillConfig),
- typeof(StoreConfig),
- typeof(SuccessConfig),
- typeof(SysInfoConfig),
- typeof(TitleStarUpConfig)
- };
-
- // 閫愪釜鍔犺浇閰嶇疆骞舵洿鏂拌繘搴�
- for (int i = 0; i < configTypes.Length; i++)
- {
- await LoadConfigByType(configTypes[i]);
- loadingProgress = (float)(i + 1) / totalConfigs;
- }
-
- // 鍔犺浇瀹屾垚鍚庤缃甶sLoadFinished涓簍rue
- loadingProgress = 1f;
- isLoadFinished = true;
- }
-
- public async UniTask LoadConfigByType(Type configType)
- {
- string configName = configType.Name;
- if (configName.EndsWith("Config"))
- {
- configName = configName.Substring(0, configName.Length - 6);
- }
- TextAsset textAsset = ResManager.Instance.LoadAsset<TextAsset>("Config", configName);
- if (textAsset != null)
- {
- string[] lines = textAsset.text.Split('\n');
- var methodInfo = configType.GetMethod("Init", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.FlattenHierarchy);
- if (methodInfo != null)
- {
- methodInfo.Invoke(null, new object[] { lines });
- // 璁剧疆鍒濆鍖栨爣蹇�
- var isInitField = configType.GetField("isInit", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
- if (isInitField != null)
- {
- isInitField.SetValue(null, true);
- }
- Debug.Log($"鍔犺浇閰嶇疆: {configType.Name} 鎴愬姛");
- }
- else
- {
- Debug.LogError($"閰嶇疆绫� {configType.Name} 娌℃湁闈欐�両nit鏂规硶");
- }
- }
- else
- {
- Debug.LogError($"鎵句笉鍒伴厤缃枃浠�: {configName}");
- }
- }
-
- private async UniTask LoadConfig<T>() where T : class
- {
- string configName = typeof(T).Name;
-
- TextAsset textAsset = ResManager.Instance.LoadAsset<TextAsset>("Config", configName);
- if (textAsset != null)
- {
- string[] lines = textAsset.text.Split('\n');
- var methodInfo = typeof(T).GetMethod("Init", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
- if (methodInfo != null)
- {
- methodInfo.Invoke(null, lines);
- // 璁剧疆鍒濆鍖栨爣蹇�
- var isInitField = typeof(T).GetField("isInit", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
- if (isInitField != null)
- {
- isInitField.SetValue(null, true);
- }
- Debug.Log($"鍔犺浇閰嶇疆: {typeof(T).Name} 鎴愬姛");
- }
- else
- {
- Debug.LogError($"閰嶇疆绫� {typeof(T).Name} 娌℃湁闈欐�両nit鏂规硶");
- }
- }
- else
- {
- Debug.LogError($"鎵句笉鍒伴厤缃枃浠�: {configName}");
- }
- }
-
- public float GetLoadingProgress()
- {
- return loadingProgress;
- }
-
- private void ClearConfigDictionary<T>() where T : class
- {
- // 閲嶇疆 T 鍒濆鍖栫姸鎬�
- var isInitField = typeof(T).GetField("isInit", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
- if (isInitField != null)
- {
- isInitField.SetValue(null, false);
- }
- }
-
- public override void Release()
- {
- // 娓呯┖ AppointItemConfig 瀛楀吀
- ClearConfigDictionary<AppointItemConfig>();
- // 娓呯┖ AudioConfig 瀛楀吀
- ClearConfigDictionary<AudioConfig>();
- // 娓呯┖ ChestsAwardConfig 瀛楀吀
- ClearConfigDictionary<ChestsAwardConfig>();
- // 娓呯┖ ChestsConfig 瀛楀吀
- ClearConfigDictionary<ChestsConfig>();
- // 娓呯┖ CTGConfig 瀛楀吀
- ClearConfigDictionary<CTGConfig>();
- // 娓呯┖ CTGSelectItemConfig 瀛楀吀
- ClearConfigDictionary<CTGSelectItemConfig>();
- // 娓呯┖ DienstgradConfig 瀛楀吀
- ClearConfigDictionary<DienstgradConfig>();
- // 娓呯┖ DirtyWordConfig 瀛楀吀
- ClearConfigDictionary<DirtyWordConfig>();
- // 娓呯┖ EffectConfig 瀛楀吀
- ClearConfigDictionary<EffectConfig>();
- // 娓呯┖ EmojiPackConfig 瀛楀吀
- ClearConfigDictionary<EmojiPackConfig>();
- // 娓呯┖ FaceConfig 瀛楀吀
- ClearConfigDictionary<FaceConfig>();
- // 娓呯┖ FamilyConfig 瀛楀吀
- ClearConfigDictionary<FamilyConfig>();
- // 娓呯┖ FuncConfigConfig 瀛楀吀
- ClearConfigDictionary<FuncConfigConfig>();
- // 娓呯┖ FuncOpenLVConfig 瀛楀吀
- ClearConfigDictionary<FuncOpenLVConfig>();
- // 娓呯┖ FunctionTeamSetConfig 瀛楀吀
- ClearConfigDictionary<FunctionTeamSetConfig>();
- // 娓呯┖ GetItemWaysConfig 瀛楀吀
- ClearConfigDictionary<GetItemWaysConfig>();
- // 娓呯┖ GmCmdConfig 瀛楀吀
- ClearConfigDictionary<GmCmdConfig>();
- // 娓呯┖ GuideConfig 瀛楀吀
- ClearConfigDictionary<GuideConfig>();
- // 娓呯┖ IconConfig 瀛楀吀
- ClearConfigDictionary<IconConfig>();
- // 娓呯┖ InitialFunctionConfig 瀛楀吀
- ClearConfigDictionary<InitialFunctionConfig>();
- // 娓呯┖ ItemConfig 瀛楀吀
- ClearConfigDictionary<ItemConfig>();
- // 娓呯┖ KickOutReasonConfig 瀛楀吀
- ClearConfigDictionary<KickOutReasonConfig>();
- // 娓呯┖ LanguageConfig 瀛楀吀
- ClearConfigDictionary<LanguageConfig>();
- // 娓呯┖ MailConfig 瀛楀吀
- ClearConfigDictionary<MailConfig>();
- // 娓呯┖ NPCConfig 瀛楀吀
- ClearConfigDictionary<NPCConfig>();
- // 娓呯┖ NPCExConfig 瀛楀吀
- ClearConfigDictionary<NPCExConfig>();
- // 娓呯┖ OrderInfoConfig 瀛楀吀
- ClearConfigDictionary<OrderInfoConfig>();
- // 娓呯┖ PlayerFaceConfig 瀛楀吀
- ClearConfigDictionary<PlayerFaceConfig>();
- // 娓呯┖ PlayerFacePicConfig 瀛楀吀
- ClearConfigDictionary<PlayerFacePicConfig>();
- // 娓呯┖ PlayerFacePicStarConfig 瀛楀吀
- ClearConfigDictionary<PlayerFacePicStarConfig>();
- // 娓呯┖ PlayerFaceStarConfig 瀛楀吀
- ClearConfigDictionary<PlayerFaceStarConfig>();
- // 娓呯┖ PlayerLVConfig 瀛楀吀
- ClearConfigDictionary<PlayerLVConfig>();
- // 娓呯┖ priorbundleConfig 瀛楀吀
- ClearConfigDictionary<priorbundleConfig>();
- // 娓呯┖ PriorLanguageConfig 瀛楀吀
- ClearConfigDictionary<PriorLanguageConfig>();
- // 娓呯┖ RichTextMsgReplaceConfig 瀛楀吀
- ClearConfigDictionary<RichTextMsgReplaceConfig>();
- // 娓呯┖ RuleConfig 瀛楀吀
- ClearConfigDictionary<RuleConfig>();
- // 娓呯┖ SkillConfig 瀛楀吀
- ClearConfigDictionary<SkillConfig>();
- // 娓呯┖ StoreConfig 瀛楀吀
- ClearConfigDictionary<StoreConfig>();
- // 娓呯┖ SuccessConfig 瀛楀吀
- ClearConfigDictionary<SuccessConfig>();
- // 娓呯┖ SysInfoConfig 瀛楀吀
- ClearConfigDictionary<SysInfoConfig>();
- // 娓呯┖ TitleStarUpConfig 瀛楀吀
- ClearConfigDictionary<TitleStarUpConfig>();
- }
-}
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+using Cysharp.Threading.Tasks;
+using System.Reflection;
+
+
+public class ConfigManager : ManagerBase<ConfigManager>
+{
+ public bool isLoadFinished
+ {
+ get;
+ private set;
+ }
+
+ private float loadingProgress = 0f;
+
+ public override void Init()
+ {
+ base.Init();
+ InitConfigs();
+ }
+
+ public virtual async UniTask InitConfigs()
+ {
+ // 鍔犺浇閰嶇疆鏂囦欢
+ await LoadConfigs();
+ }
+
+ protected async UniTask LoadConfigs()
+ {
+ loadingProgress = 0f;
+ isLoadFinished = false;
+
+ // 鍔犺浇閰嶇疆鏂囦欢
+ int totalConfigs = 41;
+ Type[] configTypes = new Type[] {
+ typeof(AppointItemConfig),
+ typeof(AudioConfig),
+ typeof(ChestsAwardConfig),
+ typeof(ChestsConfig),
+ typeof(CTGConfig),
+ typeof(CTGSelectItemConfig),
+ typeof(DienstgradConfig),
+ typeof(DirtyWordConfig),
+ typeof(EffectConfig),
+ typeof(EmojiPackConfig),
+ typeof(FaceConfig),
+ typeof(FamilyConfig),
+ typeof(FuncConfigConfig),
+ typeof(FuncOpenLVConfig),
+ typeof(FunctionTeamSetConfig),
+ typeof(GetItemWaysConfig),
+ typeof(GmCmdConfig),
+ typeof(GuideConfig),
+ typeof(IconConfig),
+ typeof(InitialFunctionConfig),
+ typeof(ItemConfig),
+ typeof(KickOutReasonConfig),
+ typeof(LanguageConfig),
+ typeof(MailConfig),
+ typeof(NPCConfig),
+ typeof(NPCExConfig),
+ typeof(OrderInfoConfig),
+ typeof(PlayerFaceConfig),
+ typeof(PlayerFacePicConfig),
+ typeof(PlayerFacePicStarConfig),
+ typeof(PlayerFaceStarConfig),
+ typeof(PlayerLVConfig),
+ typeof(priorbundleConfig),
+ typeof(PriorLanguageConfig),
+ typeof(RichTextMsgReplaceConfig),
+ typeof(RuleConfig),
+ typeof(SkillConfig),
+ typeof(StoreConfig),
+ typeof(SuccessConfig),
+ typeof(SysInfoConfig),
+ typeof(TitleStarUpConfig)
+ };
+
+ // 閫愪釜鍔犺浇閰嶇疆骞舵洿鏂拌繘搴�
+ for (int i = 0; i < configTypes.Length; i++)
+ {
+ await LoadConfigByType(configTypes[i]);
+ loadingProgress = (float)(i + 1) / totalConfigs;
+ }
+
+ // 鍔犺浇瀹屾垚鍚庤缃甶sLoadFinished涓簍rue
+ loadingProgress = 1f;
+ isLoadFinished = true;
+ }
+
+ public async UniTask LoadConfigByType(Type configType)
+ {
+ string configName = configType.Name;
+ if (configName.EndsWith("Config"))
+ {
+ configName = configName.Substring(0, configName.Length - 6);
+ }
+ TextAsset textAsset = ResManager.Instance.LoadAsset<TextAsset>("Config", configName);
+ if (textAsset != null)
+ {
+ string[] lines = textAsset.text.Split('\n');
+ var methodInfo = configType.GetMethod("Init", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.FlattenHierarchy);
+ if (methodInfo != null)
+ {
+ methodInfo.Invoke(null, new object[] { lines });
+ // 璁剧疆鍒濆鍖栨爣蹇�
+ var isInitField = configType.GetField("isInit", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
+ if (isInitField != null)
+ {
+ isInitField.SetValue(null, true);
+ }
+ Debug.Log($"鍔犺浇閰嶇疆: {configType.Name} 鎴愬姛");
+ }
+ else
+ {
+ Debug.LogError($"閰嶇疆绫� {configType.Name} 娌℃湁闈欐�両nit鏂规硶");
+ }
+ }
+ else
+ {
+ Debug.LogError($"鎵句笉鍒伴厤缃枃浠�: {configName}");
+ }
+ }
+
+ private async UniTask LoadConfig<T>() where T : class
+ {
+ string configName = typeof(T).Name;
+
+ TextAsset textAsset = ResManager.Instance.LoadAsset<TextAsset>("Config", configName);
+ if (textAsset != null)
+ {
+ string[] lines = textAsset.text.Split('\n');
+ var methodInfo = typeof(T).GetMethod("Init", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
+ if (methodInfo != null)
+ {
+ methodInfo.Invoke(null, lines);
+ // 璁剧疆鍒濆鍖栨爣蹇�
+ var isInitField = typeof(T).GetField("isInit", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
+ if (isInitField != null)
+ {
+ isInitField.SetValue(null, true);
+ }
+ Debug.Log($"鍔犺浇閰嶇疆: {typeof(T).Name} 鎴愬姛");
+ }
+ else
+ {
+ Debug.LogError($"閰嶇疆绫� {typeof(T).Name} 娌℃湁闈欐�両nit鏂规硶");
+ }
+ }
+ else
+ {
+ Debug.LogError($"鎵句笉鍒伴厤缃枃浠�: {configName}");
+ }
+ }
+
+ public float GetLoadingProgress()
+ {
+ return loadingProgress;
+ }
+
+ private void ClearConfigDictionary<T>() where T : class
+ {
+ // 閲嶇疆 T 鍒濆鍖栫姸鎬�
+ var isInitField = typeof(T).GetField("isInit", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
+ if (isInitField != null)
+ {
+ isInitField.SetValue(null, false);
+ }
+ }
+
+ public override void Release()
+ {
+ // 娓呯┖ AppointItemConfig 瀛楀吀
+ ClearConfigDictionary<AppointItemConfig>();
+ // 娓呯┖ AudioConfig 瀛楀吀
+ ClearConfigDictionary<AudioConfig>();
+ // 娓呯┖ ChestsAwardConfig 瀛楀吀
+ ClearConfigDictionary<ChestsAwardConfig>();
+ // 娓呯┖ ChestsConfig 瀛楀吀
+ ClearConfigDictionary<ChestsConfig>();
+ // 娓呯┖ CTGConfig 瀛楀吀
+ ClearConfigDictionary<CTGConfig>();
+ // 娓呯┖ CTGSelectItemConfig 瀛楀吀
+ ClearConfigDictionary<CTGSelectItemConfig>();
+ // 娓呯┖ DienstgradConfig 瀛楀吀
+ ClearConfigDictionary<DienstgradConfig>();
+ // 娓呯┖ DirtyWordConfig 瀛楀吀
+ ClearConfigDictionary<DirtyWordConfig>();
+ // 娓呯┖ EffectConfig 瀛楀吀
+ ClearConfigDictionary<EffectConfig>();
+ // 娓呯┖ EmojiPackConfig 瀛楀吀
+ ClearConfigDictionary<EmojiPackConfig>();
+ // 娓呯┖ FaceConfig 瀛楀吀
+ ClearConfigDictionary<FaceConfig>();
+ // 娓呯┖ FamilyConfig 瀛楀吀
+ ClearConfigDictionary<FamilyConfig>();
+ // 娓呯┖ FuncConfigConfig 瀛楀吀
+ ClearConfigDictionary<FuncConfigConfig>();
+ // 娓呯┖ FuncOpenLVConfig 瀛楀吀
+ ClearConfigDictionary<FuncOpenLVConfig>();
+ // 娓呯┖ FunctionTeamSetConfig 瀛楀吀
+ ClearConfigDictionary<FunctionTeamSetConfig>();
+ // 娓呯┖ GetItemWaysConfig 瀛楀吀
+ ClearConfigDictionary<GetItemWaysConfig>();
+ // 娓呯┖ GmCmdConfig 瀛楀吀
+ ClearConfigDictionary<GmCmdConfig>();
+ // 娓呯┖ GuideConfig 瀛楀吀
+ ClearConfigDictionary<GuideConfig>();
+ // 娓呯┖ IconConfig 瀛楀吀
+ ClearConfigDictionary<IconConfig>();
+ // 娓呯┖ InitialFunctionConfig 瀛楀吀
+ ClearConfigDictionary<InitialFunctionConfig>();
+ // 娓呯┖ ItemConfig 瀛楀吀
+ ClearConfigDictionary<ItemConfig>();
+ // 娓呯┖ KickOutReasonConfig 瀛楀吀
+ ClearConfigDictionary<KickOutReasonConfig>();
+ // 娓呯┖ LanguageConfig 瀛楀吀
+ ClearConfigDictionary<LanguageConfig>();
+ // 娓呯┖ MailConfig 瀛楀吀
+ ClearConfigDictionary<MailConfig>();
+ // 娓呯┖ NPCConfig 瀛楀吀
+ ClearConfigDictionary<NPCConfig>();
+ // 娓呯┖ NPCExConfig 瀛楀吀
+ ClearConfigDictionary<NPCExConfig>();
+ // 娓呯┖ OrderInfoConfig 瀛楀吀
+ ClearConfigDictionary<OrderInfoConfig>();
+ // 娓呯┖ PlayerFaceConfig 瀛楀吀
+ ClearConfigDictionary<PlayerFaceConfig>();
+ // 娓呯┖ PlayerFacePicConfig 瀛楀吀
+ ClearConfigDictionary<PlayerFacePicConfig>();
+ // 娓呯┖ PlayerFacePicStarConfig 瀛楀吀
+ ClearConfigDictionary<PlayerFacePicStarConfig>();
+ // 娓呯┖ PlayerFaceStarConfig 瀛楀吀
+ ClearConfigDictionary<PlayerFaceStarConfig>();
+ // 娓呯┖ PlayerLVConfig 瀛楀吀
+ ClearConfigDictionary<PlayerLVConfig>();
+ // 娓呯┖ priorbundleConfig 瀛楀吀
+ ClearConfigDictionary<priorbundleConfig>();
+ // 娓呯┖ PriorLanguageConfig 瀛楀吀
+ ClearConfigDictionary<PriorLanguageConfig>();
+ // 娓呯┖ RichTextMsgReplaceConfig 瀛楀吀
+ ClearConfigDictionary<RichTextMsgReplaceConfig>();
+ // 娓呯┖ RuleConfig 瀛楀吀
+ ClearConfigDictionary<RuleConfig>();
+ // 娓呯┖ SkillConfig 瀛楀吀
+ ClearConfigDictionary<SkillConfig>();
+ // 娓呯┖ StoreConfig 瀛楀吀
+ ClearConfigDictionary<StoreConfig>();
+ // 娓呯┖ SuccessConfig 瀛楀吀
+ ClearConfigDictionary<SuccessConfig>();
+ // 娓呯┖ SysInfoConfig 瀛楀吀
+ ClearConfigDictionary<SysInfoConfig>();
+ // 娓呯┖ TitleStarUpConfig 瀛楀吀
+ ClearConfigDictionary<TitleStarUpConfig>();
+ }
+}
diff --git a/Main/Manager/ConfigManager.cs.meta b/Main/Config/ConfigManager.cs.meta
similarity index 100%
rename from Main/Manager/ConfigManager.cs.meta
rename to Main/Config/ConfigManager.cs.meta
diff --git a/Main/Login.meta b/Main/Login.meta
deleted file mode 100644
index 8bc1ba1..0000000
--- a/Main/Login.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 07397eca392dcce41b8e20345535c569
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/Login/ClientVersion.meta b/Main/Login/ClientVersion.meta
deleted file mode 100644
index 76dea86..0000000
--- a/Main/Login/ClientVersion.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: fd7ab97ad3c29994d9aee3496ff38f4e
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/Manager/GameSystemManager.meta b/Main/Manager/GameSystemManager.meta
deleted file mode 100644
index c3d55d3..0000000
--- a/Main/Manager/GameSystemManager.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 7b0931f43ab92084b8a1e5faa7fbfda2
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/UI/UIManager.cs b/Main/Manager/UIManager.cs
similarity index 99%
rename from Main/UI/UIManager.cs
rename to Main/Manager/UIManager.cs
index 05a0d37..7063ca0 100644
--- a/Main/UI/UIManager.cs
+++ b/Main/Manager/UIManager.cs
@@ -1,921 +1,921 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using System.Linq;
-
-/// <summary>
-/// UI绠$悊鍣� - 璐熻矗绠$悊鎵�鏈塙I鐣岄潰鐨勬樉绀恒�侀殣钘忓拰灞傜骇
-/// </summary>
-public class UIManager : ManagerBase<UIManager>
-{
- #region 甯搁噺鍜屾灇涓�
-
- // 鍩虹鎺掑簭椤哄簭
- private const int BASE_SORTING_ORDER = 10;
-
- #endregion
-
- #region 瀛楁鍜屽睘鎬�
-
- // UI鏍硅妭鐐�
- private Transform uiRoot;
-
- // 鍚勫眰绾х殑Transform
- private Transform staticTrans;
- private Transform bottomTrans;
- private Transform midTrans;
- private Transform topTrans;
- private Transform systemTrans;
-
- // UI瀛楀吀锛屽瓨鍌ㄦ墍鏈夊凡鍔犺浇鐨刄I锛岄敭涓篣I鍚嶇О锛屽�间负UI瀹炰緥
- private Dictionary<string, List<UIBase>> uiDict = new Dictionary<string, List<UIBase>>();
-
- // 瀛樺偍鍏抽棴浣嗘湭閿�姣佺殑UI锛岄敭涓篣I鍚嶇О锛屽�间负UI瀹炰緥
- private Dictionary<string, List<UIBase>> closedUIDict = new Dictionary<string, List<UIBase>>();
-
- // UI鏍堬紝鐢ㄤ簬绠$悊UI鐨勬樉绀洪『搴�
- private Stack<UIBase> uiStack = new Stack<UIBase>();
-
- // 褰撳墠鏈�楂樼殑鎺掑簭椤哄簭
- private int currentHighestSortingOrder = 0;
-
- // 褰撳墠鍥炲悎鏁帮紝鐢ㄤ簬璁板綍UI鐨勪娇鐢ㄦ儏鍐�
- private int currentRound = 0;
-
- // 缂撳瓨灞傜骇瀵瑰簲鐨勬帓搴忛『搴�
- private Dictionary<UILayer, int> layerSortingOrderCache = new Dictionary<UILayer, int>();
-
- // 缂撳瓨灞傜骇瀵瑰簲鐨凾ransform
- private Dictionary<UILayer, Transform> layerTransformCache = new Dictionary<UILayer, Transform>();
-
- // UI瀹炰緥璁℃暟鍣紝鐢ㄤ簬涓哄悓绫诲瀷UI鐢熸垚鍞竴鏍囪瘑
- private Dictionary<string, int> uiInstanceCounter = new Dictionary<string, int>();
-
- // 涓婃妫�鏌ユ椂闂�
- private float lastCheckTime = 0f;
- // 妫�鏌ラ棿闅旓紙绉掞級
- private const float CHECK_INTERVAL = 5f;
-
- public Action<UIBase> OnOpenWindow;
-
- public Action<UIBase> OnCloseWindow;
-
- #endregion
-
- #region 鍒濆鍖�
-
- /// <summary>
- /// 鍒濆鍖朥I绠$悊鍣�
- /// </summary>
- public override void Init()
- {
- base.Init();
-
- // 鍒濆鍖朥I鏍硅妭鐐�
- InitUIRoot();
-
- // 鍒濆鍖栫紦瀛�
- layerSortingOrderCache.Clear();
- layerTransformCache.Clear();
- uiInstanceCounter.Clear();
-
- Debug.Log("UI绠$悊鍣ㄥ垵濮嬪寲瀹屾垚");
- }
-
- /// <summary>
- /// 鍒濆鍖朥I鏍硅妭鐐�
- /// </summary>
- private void InitUIRoot()
- {
- // 鏌ユ壘UI鏍硅妭鐐�
- GameObject root = GameObject.Find("UIRoot");
-
- // 濡傛灉鍦烘櫙涓病鏈塙I鏍硅妭鐐癸紝鍒欏垱寤轰竴涓�
- if (root == null)
- {
- root = GameObject.Instantiate(BuiltInLoader.LoadPrefab("UIRoot"));
- root.name = "UIRoot";
- if (root == null)
- {
- Debug.LogError("鏃犳硶鎵惧埌UI鏍硅妭鐐�");
- return;
- }
-
- // 娣诲姞DontDestroyOnLoad缁勪欢锛岀‘淇漊I鏍硅妭鐐瑰湪鍦烘櫙鍒囨崲鏃朵笉琚攢姣�
- GameObject.DontDestroyOnLoad(root);
- }
-
- uiRoot = root.transform;
- uiRoot.position = Vector3.zero;
-
- staticTrans = uiRoot.Find("Static");
- bottomTrans = uiRoot.Find("Bottom");
- midTrans = uiRoot.Find("Middle");
- topTrans = uiRoot.Find("Top");
- systemTrans = uiRoot.Find("System");
-
- layerTransformCache.Clear();
- layerTransformCache.Add(UILayer.Static, staticTrans);
- layerTransformCache.Add(UILayer.Bottom, bottomTrans);
- layerTransformCache.Add(UILayer.Mid, midTrans);
- layerTransformCache.Add(UILayer.Top, topTrans);
- layerTransformCache.Add(UILayer.System, systemTrans);
- }
-
- #endregion
-
- #region 杈呭姪鏂规硶
-
- // 鑾峰彇UI灞傜骇瀵瑰簲鐨勫熀纭�鎺掑簭椤哄簭
- private int GetBaseSortingOrderForLayer(UILayer layer)
- {
- // 灏濊瘯浠庣紦瀛樹腑鑾峰彇鎺掑簭椤哄簭
- if (layerSortingOrderCache.TryGetValue(layer, out int order))
- return order;
-
- // 濡傛灉缂撳瓨涓病鏈夛紝浣跨敤鍘熸潵鐨勬柟娉曡绠楀苟缂撳瓨缁撴灉
- int result;
- switch (layer)
- {
- case UILayer.Static:
- result = BASE_SORTING_ORDER;
- break;
- case UILayer.Bottom:
- result = BASE_SORTING_ORDER * 10;
- break;
- case UILayer.Mid:
- result = BASE_SORTING_ORDER * 100;
- break;
- case UILayer.Top:
- result = BASE_SORTING_ORDER * 1000;
- break;
- case UILayer.System:
- result = BASE_SORTING_ORDER * 10000;
- break;
- default:
- result = BASE_SORTING_ORDER * 10;
- break;
- }
-
- // 灏嗙粨鏋滃瓨鍏ョ紦瀛�
- layerSortingOrderCache[layer] = result;
- return result;
- }
-
- // 鑾峰彇灞傜骇瀵瑰簲鐨凾ransform
- private Transform GetTransForLayer(UILayer layer)
- {
- // 灏濊瘯浠庣紦瀛樹腑鑾峰彇Transform
- if (layerTransformCache.TryGetValue(layer, out Transform trans))
- return trans;
-
- // 濡傛灉缂撳瓨涓病鏈夛紝浣跨敤鍘熸潵鐨勬柟娉曡幏鍙栧苟缂撳瓨缁撴灉
- Transform result;
- switch (layer)
- {
- case UILayer.Static:
- result = staticTrans;
- break;
- case UILayer.Bottom:
- result = bottomTrans;
- break;
- case UILayer.Mid:
- result = midTrans;
- break;
- case UILayer.Top:
- result = topTrans;
- break;
- case UILayer.System:
- result = systemTrans;
- break;
- default:
- result = bottomTrans;
- break;
- }
-
- // 灏嗙粨鏋滃瓨鍏ョ紦瀛�
- layerTransformCache[layer] = result;
- return result;
- }
-
- // 鑾峰彇UI瀹炰緥锛屽鏋滀笉瀛樺湪鍒欒繑鍥瀗ull
- public T GetUI<T>() where T : UIBase
- {
- // 鑾峰彇UI绫诲瀷鍚嶇О
- string uiName = typeof(T).Name;
- if (string.IsNullOrEmpty(uiName))
- {
- // 璁板綍閿欒鏃ュ織
- Debug.LogError("UI鍚嶇О涓虹┖");
- return null;
- }
-
- // 灏濊瘯浠庡瓧鍏镐腑鑾峰彇UI瀹炰緥鍒楄〃
- if (uiDict.TryGetValue(uiName, out List<UIBase> uiList) && uiList.Count > 0)
- {
- // 杩斿洖绗竴涓疄渚�
- return uiList[0] as T;
- }
-
- // 濡傛灉涓嶅瓨鍦紝杩斿洖null
- return null;
- }
-
- public List<T> GetUIList<T>() where T : UIBase
- {
- List<T> uiList = new List<T>();
-
- // 鑾峰彇UI绫诲瀷鍚嶇О
- string uiName = typeof(T).Name;
- if (string.IsNullOrEmpty(uiName))
- {
- // 璁板綍閿欒鏃ュ織
- Debug.LogError("UI鍚嶇О涓虹┖");
- return uiList;
- }
-
- // 灏濊瘯浠庡瓧鍏镐腑鑾峰彇UI瀹炰緥鍒楄〃
- List<UIBase> tempList = null;
- uiDict.TryGetValue(uiName, out tempList);
-
- if (tempList != null)
- {
- for (int i = 0; i < tempList.Count; i++)
- {
- UIBase ui = tempList[i];
- if (null != ui)
- {
- uiList.Add(ui as T);
- }
- }
- }
-
- return uiList;
- }
-
- public bool IsOpenedInList<T>() where T : UIBase
- {
- List<T> uiList = GetUIList<T>();
-
- foreach (T ui in uiList)
- {
- if (ui.IsActive())
- {
- return true;
- }
- }
-
- return false;
- }
-
- public bool IsOpened<T>() where T : UIBase
- {
- T ui = GetUI<T>();
-
- if (null != ui)
- {
- return ui.IsActive();
- }
-
- return false;
- }
-
- // 鑾峰彇鎸囧畾绫诲瀷鐨勬墍鏈塙I瀹炰緥
- public List<T> GetAllUI<T>() where T : UIBase
- {
- // 鑾峰彇UI绫诲瀷鍚嶇О
- string uiName = typeof(T).Name;
- if (string.IsNullOrEmpty(uiName))
- {
- // 璁板綍閿欒鏃ュ織
- Debug.LogError("UI鍚嶇О涓虹┖");
- return new List<T>();
- }
-
- // 灏濊瘯浠庡瓧鍏镐腑鑾峰彇UI瀹炰緥鍒楄〃
- if (uiDict.TryGetValue(uiName, out List<UIBase> uiList) && uiList.Count > 0)
- {
- // 灏嗗垪琛ㄤ腑鐨勬墍鏈夊疄渚嬭浆鎹负鎸囧畾绫诲瀷骞惰繑鍥�
- return uiList.Cast<T>().ToList();
- }
-
- // 濡傛灉涓嶅瓨鍦紝杩斿洖绌哄垪琛�
- return new List<T>();
- }
-
- // 鏇存柊鐖剁骇UI鐨勫洖鍚堟暟
- private void UpdateParentUIRounds(UIBase ui)
- {
- // 濡傛灉UI涓虹┖鎴栦笉鏀寔鐖跺瓙鍏崇郴锛岀洿鎺ヨ繑鍥�
- if (ui == null || !ui.supportParentChildRelation)
- return;
-
- // 鑾峰彇鐖剁骇UI
- UIBase parentUI = ui.parentUI;
- // 閬嶅巻鎵�鏈夌埗绾I锛屾洿鏂板洖鍚堟暟
- while (parentUI != null)
- {
- // 鏇存柊鐖剁骇UI鐨勬渶鍚庝娇鐢ㄥ洖鍚堟暟
- parentUI.lastUsedRound = currentRound;
- // 缁х画鍚戜笂鏌ユ壘鐖剁骇UI
- parentUI = parentUI.parentUI;
- }
- }
-
- // 閫掑綊鏀堕泦鎵�鏈夊瓙UI
- private void CollectChildrenUI(UIBase ui, List<UIBase> result)
- {
- // 濡傛灉UI涓虹┖鎴栨病鏈夊瓙UI鎴栦笉鏀寔鐖跺瓙鍏崇郴锛岀洿鎺ヨ繑鍥�
- if (ui == null || !ui.supportParentChildRelation || ui.childrenUI == null || ui.childrenUI.Count == 0)
- return;
-
- // 閬嶅巻鎵�鏈夊瓙UI
- foreach (var childUI in ui.childrenUI)
- {
- // 濡傛灉缁撴灉鍒楄〃涓笉鍖呭惈褰撳墠瀛怳I锛屽垯娣诲姞
- if (!result.Contains(childUI))
- {
- // 娣诲姞鍒扮粨鏋滃垪琛�
- result.Add(childUI);
- // 閫掑綊鏀堕泦瀛怳I鐨勫瓙UI
- CollectChildrenUI(childUI, result);
- }
- }
- }
-
- /// <summary>
- /// 妫�鏌ュ苟鍏抽棴闀挎椂闂存湭浣跨敤鐨刄I
- /// </summary>
- public void CheckAndCloseIdleUI()
- {
- // 濡傛灉娌℃湁UI锛岀洿鎺ヨ繑鍥�
- if (uiDict.Count == 0 && closedUIDict.Count == 0)
- return;
-
- // 鍒涘缓闇�瑕佸叧闂殑UI鍒楄〃
- List<UIBase> uiToClose = new List<UIBase>();
-
- // 閬嶅巻鎵�鏈夋椿璺僓I
- foreach (var uiList in uiDict.Values)
- {
- foreach (var ui in uiList)
- {
- // 濡傛灉UI鏄寔涔呭寲鐨勶紝璺宠繃
- if (ui.isPersistent)
- continue;
-
- if (ui.IsActive())
- continue;
-
- // 璁$畻UI绌洪棽鐨勫洖鍚堟暟
- int idleRounds = currentRound - ui.lastUsedRound;
-
- // 濡傛灉绌洪棽鍥炲悎鏁拌秴杩囨渶澶х┖闂插洖鍚堟暟锛屾坊鍔犲埌鍏抽棴鍒楄〃
- if (idleRounds > ui.maxIdleRounds)
- {
- uiToClose.Add(ui);
- }
- }
- }
-
- // 閬嶅巻鎵�鏈夊叧闂殑UI
- List<string> emptyKeys = new List<string>();
- foreach (var kvp in closedUIDict)
- {
- string uiName = kvp.Key;
- List<UIBase> uiList = kvp.Value;
- List<UIBase> uiToRemove = new List<UIBase>();
-
- foreach (var ui in uiList)
- {
- // 璁$畻UI绌洪棽鐨勫洖鍚堟暟
- int idleRounds = currentRound - ui.lastUsedRound;
-
- // 濡傛灉绌洪棽鍥炲悎鏁拌秴杩囨渶澶х┖闂插洖鍚堟暟锛屾坊鍔犲埌鍏抽棴鍒楄〃
- if (idleRounds > ui.maxIdleRounds)
- {
- uiToClose.Add(ui);
- uiToRemove.Add(ui);
- }
- }
-
- // 浠庡叧闂垪琛ㄤ腑绉婚櫎闇�瑕侀攢姣佺殑UI
- foreach (var ui in uiToRemove)
- {
- uiList.Remove(ui);
- }
-
- // 濡傛灉鍒楄〃涓虹┖锛岃褰曢渶瑕佷粠瀛楀吀涓Щ闄ょ殑閿�
- if (uiList.Count == 0)
- {
- emptyKeys.Add(uiName);
- }
- }
-
- // 浠庡瓧鍏镐腑绉婚櫎绌哄垪琛�
- foreach (var key in emptyKeys)
- {
- closedUIDict.Remove(key);
- }
-
- // 閿�姣佹墍鏈夐渶瑕佸叧闂殑UI
- foreach (var ui in uiToClose)
- {
- // 璁板綍鏃ュ織
- Debug.Log($"閿�姣侀暱鏃堕棿鏈娇鐢ㄧ殑UI: {ui.uiName}, 绌洪棽鍥炲悎鏁�: {currentRound - ui.lastUsedRound}");
- // 閿�姣乁I瀵硅薄
- GameObject.Destroy(ui.gameObject);
- }
- }
-
- // // 鐢熸垚UI瀹炰緥鐨勫敮涓�鏍囪瘑
- // private string GenerateUIInstanceID(string uiName)
- // {
- // // 濡傛灉璁℃暟鍣ㄤ腑涓嶅瓨鍦ㄨUI绫诲瀷锛屽垵濮嬪寲涓�0
- // if (!uiInstanceCounter.ContainsKey(uiName))
- // {
- // uiInstanceCounter[uiName] = 0;
- // }
-
- // // 閫掑璁℃暟鍣�
- // uiInstanceCounter[uiName]++;
-
- // // 杩斿洖甯︽湁璁℃暟鐨勫敮涓�鏍囪瘑
- // return $"{uiName}_{uiInstanceCounter[uiName]}";
- // }
-
- #endregion
-
- #region UI璧勬簮绠$悊
-
- private UIBase LoadUIResource(string uiName)
- {
- // 浠庤祫婧愮鐞嗗櫒鍔犺浇UI棰勫埗浣�
- GameObject prefab = ResManager.Instance.LoadAsset<GameObject>("UI", uiName);
-
- // 妫�鏌ラ鍒朵綋鏄惁鍔犺浇鎴愬姛
- if (prefab == null)
- {
- // 璁板綍閿欒鏃ュ織
- Debug.LogError($"鍔犺浇UI棰勫埗浣撳け璐�: {uiName}");
- return null;
- }
-
- // 瀹炰緥鍖朥I瀵硅薄
- GameObject uiObject = GameObject.Instantiate(prefab);
- // 璁剧疆瀵硅薄鍚嶇О
- uiObject.name = uiName;
-
- // 閫氳繃uiName鏄犲皠Type
- Type uiType = Type.GetType(uiName);
- if (uiType == null)
- {
- Debug.LogError($"鎵句笉鍒癠I绫诲瀷: {uiName}");
- return null;
- }
-
- // 鑾峰彇UI鍩虹被缁勪欢
- UIBase uiBase = uiObject.GetComponent(uiType) as UIBase;
-
- // 妫�鏌I鍩虹被缁勪欢鏄惁瀛樺湪
- if (uiBase == null)
- {
- // 璁板綍閿欒鏃ュ織
- Debug.LogError($"UI棰勫埗浣� {uiName} 娌℃湁 UIBase 缁勪欢鎴栫被鍨嬩笉鍖归厤");
- return null;
- }
-
- // 璁剧疆UI鍚嶇О
- uiBase.uiName = uiName;
-
- // 璁剧疆鐖惰妭鐐逛负UI鏍硅妭鐐�
- Transform parentTrans = GetTransForLayer(uiBase.uiLayer);
-
- uiObject.transform.SetParent(parentTrans, false);
-
- // 璁剧疆鎺掑簭椤哄簭
- int baseSortingOrder = GetBaseSortingOrderForLayer(uiBase.uiLayer);
- uiBase.SetSortingOrder(baseSortingOrder);
-
- return uiBase;
- }
-
- // 鍔犺浇UI棰勫埗浣�
- private T LoadUIResource<T>(string uiName) where T : UIBase
- {
- return LoadUIResource(uiName) as T;
- }
-
- #endregion
-
- #region UI鎺掑簭绠$悊
-
- // 鏇存柊UI鎺掑簭椤哄簭
- private void UpdateUISortingOrder()
- {
- // 閲嶇疆褰撳墠鏈�楂樻帓搴忛『搴�
- currentHighestSortingOrder = 0;
-
- // 閬嶅巻UI鏍堬紝璁剧疆鎺掑簭椤哄簭
- UIBase[] uiArray = new UIBase[uiStack.Count];
- uiStack.CopyTo(uiArray, 0);
-
- // 鍏堟寜鐓ILayer杩涜鎺掑簭锛岀劧鍚庡啀鎸夌収鏍堥『搴忔帓搴�
- Array.Sort(uiArray, (a, b) => {
- // 姣旇緝UI灞傜骇
- int layerCompare = a.uiLayer.CompareTo(b.uiLayer);
- if (layerCompare != 0)
- return layerCompare;
-
- // 鍚屽眰绾у唴锛屾寜鐓ф爤涓殑椤哄簭鎺掑簭
- return Array.IndexOf(uiArray, a).CompareTo(Array.IndexOf(uiArray, b));
- });
-
- // 閬嶅巻鎺掑簭鍚庣殑UI鏁扮粍锛岃缃帓搴忛『搴�
- foreach (var ui in uiArray)
- {
- // 鑾峰彇鍩虹鎺掑簭椤哄簭
- int baseSortingOrder = GetBaseSortingOrderForLayer(ui.uiLayer);
- // 璁$畻褰撳墠UI鐨勬帓搴忛『搴�
- int sortingOrder = baseSortingOrder + currentHighestSortingOrder;
- // 璁剧疆UI鐨勬帓搴忛『搴�
- ui.SetSortingOrder(sortingOrder);
- // 鏇存柊褰撳墠鏈�楂樻帓搴忛『搴�
- currentHighestSortingOrder += 10;
- }
- }
-
- #endregion
-
- #region UI鎿嶄綔
-
-
-
- private UIBase GetLastSupportParentChildRelationUI()
- {
- List<UIBase> tempList = new List<UIBase>();
-
- UIBase target = null;
-
- while (target == null && uiStack.Count > 0)
- {
- UIBase uiBase = uiStack.Pop();
-
- if (uiBase != null && uiBase.supportParentChildRelation && !uiBase.isMainUI)
- {
- target = uiBase;
- }
-
- tempList.Add(uiBase);
- }
-
- for (int i = tempList.Count - 1; i >= 0; i--)
- {
- uiStack.Push(tempList[i]);
- }
-
- return target;
- }
-
- public UIBase OpenWindow(string uiName)
- {
- // 浼樺厛浠巆losedUIDict涓幏鍙�
- UIBase parentUI = null;
-
- UIBase returnValue = null;
-
- if (closedUIDict.TryGetValue(uiName, out List<UIBase> closedUIList) && closedUIList.Count > 0)
- {
- returnValue = closedUIList[0] as UIBase;
- closedUIList.RemoveAt(0);
-
- if (closedUIList.Count == 0)
- {
- closedUIDict.Remove(uiName);
- }
- }
- else
- {
- returnValue = LoadUIResource(uiName);
- if (returnValue == null)
- {
- // 璁板綍閿欒鏃ュ織
- Debug.LogError($"鎵撳紑UI澶辫触: {uiName}");
- return null;
- }
- }
-
- returnValue.gameObject.SetActive(true);
-
- // 鑷姩璁剧疆鐖剁骇UI锛堝鏋滄湭鎸囧畾涓旀敮鎸佺埗瀛愬叧绯伙級
- if (returnValue.supportParentChildRelation && uiStack.Count > 0)
- {
- // 鑾峰彇鏍堥《UI
- parentUI = GetLastSupportParentChildRelationUI();
- }
-
- // 璁剧疆鐖剁骇UI
- if (parentUI != null)
- {
- // 璁剧疆鐖跺瓙鍏崇郴
- returnValue.parentUI = parentUI;
- if (parentUI.childrenUI == null)
- {
- // 鍒濆鍖栫埗绾I鐨勫瓙UI鍒楄〃
- parentUI.childrenUI = new List<UIBase>();
- }
- // 娣诲姞鍒扮埗绾I鐨勫瓙UI鍒楄〃
- parentUI.childrenUI.Add(returnValue);
- }
-
- // 鏇存柊鍥炲悎鏁�
- currentRound++;
- // 璁剧疆UI鐨勬渶鍚庝娇鐢ㄥ洖鍚堟暟
- returnValue.lastUsedRound = currentRound;
- // 鏇存柊鐖剁骇UI鐨勫洖鍚堟暟
- UpdateParentUIRounds(returnValue);
-
- // 灏哢I娣诲姞鍒板瓧鍏镐腑
- if (!uiDict.ContainsKey(uiName))
- {
- // 濡傛灉瀛楀吀涓笉瀛樺湪璇ョ被鍨嬬殑UI锛屽垱寤烘柊鍒楄〃
- uiDict[uiName] = new List<UIBase>();
- }
- // 娣诲姞鍒癠I鍒楄〃
- uiDict[uiName].Add(returnValue);
-
- // 灏哢I娣诲姞鍒版爤涓�
- uiStack.Push(returnValue);
-
- // 鏇存柊UI鎺掑簭椤哄簭
- UpdateUISortingOrder();
-
- // 鎵撳紑UI
- returnValue.HandleOpen();
-
- OnOpenWindow?.Invoke(returnValue);
-
- // 妫�鏌ュ苟鍏抽棴闀挎椂闂存湭浣跨敤鐨刄I
- CheckAndCloseIdleUI();
-
- return returnValue;
- }
-
- /// <summary>
- /// 鎵撳紑UI
- /// </summary>
- public T OpenWindow<T>() where T : UIBase
- {
- // 鑾峰彇UI绫诲瀷鍚嶇О
- string uiName = typeof(T).Name;
- return OpenWindow(uiName) as T;
- }
-
- /// <summary>
- /// 鍏抽棴UI
- /// </summary>
- public void CloseWindow<T>(bool destroy = false) where T : UIBase
- {
- // 鑾峰彇UI绫诲瀷鍚嶇О
- string uiName = typeof(T).Name;
-
- CloseWindow(uiName, destroy);
-
- }
-
- public void CloseWindow(string uiName, bool destroy = false)
- {
- // 妫�鏌I鏄惁瀛樺湪
- if (!uiDict.ContainsKey(uiName) || uiDict[uiName].Count == 0)
- {
- // 璁板綍璀﹀憡鏃ュ織
- Debug.LogWarning($"灏濊瘯鍏抽棴涓嶅瓨鍦ㄧ殑UI: {uiName}");
- return;
- }
-
- // 鑾峰彇绗竴涓猆I瀹炰緥
- UIBase ui = uiDict[uiName][0];
-
- // 鍏抽棴UI
- CloseWindow(ui, destroy);
- }
-
- /// <summary>
- /// 鍏抽棴鎸囧畾鐨刄I瀹炰緥
- /// </summary>
- public void CloseWindow(UIBase ui, bool destroy = false)
- {
- // 妫�鏌I鏄惁涓虹┖
- if (ui == null)
- {
- // 璁板綍璀﹀憡鏃ュ織
- Debug.LogWarning("灏濊瘯鍏抽棴绌篣I");
- return;
- }
-
- // 鑾峰彇UI绫诲瀷鍚嶇О
- string uiName = ui.uiName;
-
- // 鏀堕泦鎵�鏈夊瓙UI
- List<UIBase> childrenUI = new List<UIBase>();
- if (ui.supportParentChildRelation)
- {
- CollectChildrenUI(ui, childrenUI);
- }
-
- // 鍏堝叧闂墍鏈夊瓙UI
- foreach (var childUI in childrenUI)
- {
- // 鍏抽棴瀛怳I
- CloseWindow(childUI, destroy);
- }
-
- // 浠庢爤涓Щ闄I
- Stack<UIBase> tempStack = new Stack<UIBase>();
- while (uiStack.Count > 0)
- {
- // 寮瑰嚭鏍堥《UI
- UIBase tempUI = uiStack.Pop();
- // 濡傛灉涓嶆槸瑕佸叧闂殑UI锛屽垯淇濆瓨鍒颁复鏃舵爤涓�
- if (tempUI != ui)
- {
- tempStack.Push(tempUI);
- }
- }
-
- // 灏嗕复鏃舵爤涓殑UI閲嶆柊鍘嬪叆鏍堜腑
- while (tempStack.Count > 0)
- {
- uiStack.Push(tempStack.Pop());
- }
-
- // 浠庡瓧鍏镐腑绉婚櫎UI
- if (uiDict.ContainsKey(uiName))
- {
- // 浠嶶I鍒楄〃涓Щ闄�
- uiDict[uiName].Remove(ui);
- // 濡傛灉鍒楄〃涓虹┖锛屼粠瀛楀吀涓Щ闄よ绫诲瀷
- if (uiDict[uiName].Count == 0)
- {
- uiDict.Remove(uiName);
- }
- }
-
- // 浠庣埗绾I鐨勫瓙UI鍒楄〃涓Щ闄�
- if (ui.supportParentChildRelation && ui.parentUI != null && ui.parentUI.childrenUI != null)
- {
- // 浠庣埗绾I鐨勫瓙UI鍒楄〃涓Щ闄�
- ui.parentUI.childrenUI.Remove(ui);
- }
-
- // 鍏抽棴UI
- ui.HandleClose();
- OnCloseWindow?.Invoke(ui);
-
- if (destroy)
- {
- // 閿�姣乁I瀵硅薄
- GameObject.Destroy(ui.gameObject);
- }
- else
- {
- // 娣诲姞鍒癱losedUIDict
- if (!closedUIDict.ContainsKey(uiName))
- {
- closedUIDict[uiName] = new List<UIBase>();
- }
- closedUIDict[uiName].Add(ui);
-
- // 闅愯棌UI
- ui.gameObject.SetActive(false);
- }
-
- // 鏇存柊UI鎺掑簭椤哄簭
- UpdateUISortingOrder();
- }
-
- /// <summary>
- /// 鍏抽棴鎸囧畾绫诲瀷鐨勬墍鏈塙I瀹炰緥
- /// </summary>
- public void CloseAllWindows<T>() where T : UIBase
- {
- // 鑾峰彇UI绫诲瀷鍚嶇О
- string uiName = typeof(T).Name;
-
- // 妫�鏌I鏄惁瀛樺湪
- if (!uiDict.ContainsKey(uiName) || uiDict[uiName].Count == 0)
- {
- // 璁板綍璀﹀憡鏃ュ織
- Debug.LogWarning($"灏濊瘯鍏抽棴涓嶅瓨鍦ㄧ殑UI: {uiName}");
- return;
- }
-
- // 鍒涘缓UI瀹炰緥鍒楄〃鐨勫壇鏈紝鍥犱负鍦ㄥ叧闂繃绋嬩腑浼氫慨鏀瑰師鍒楄〃
- List<UIBase> uiListCopy = new List<UIBase>(uiDict[uiName]);
-
- // 鍏抽棴鎵�鏈塙I瀹炰緥
- foreach (var ui in uiListCopy)
- {
- // 鍏抽棴UI瀹炰緥
- CloseWindow(ui, false);
- }
- }
-
- /// <summary>
- /// 鍏抽棴鎵�鏈塙I
- /// </summary>
- public void DestroyAllUI()
- {
- // 鍒涘缓UI鏍堢殑鍓湰锛屽洜涓哄湪鍏抽棴杩囩▼涓細淇敼鍘熸爤
- UIBase[] uiArray = new UIBase[uiStack.Count];
- uiStack.CopyTo(uiArray, 0);
-
- // 鍏抽棴鎵�鏈塙I
- foreach (var ui in uiArray)
- {
- // 鍏抽棴UI
- CloseWindow(ui, true);
- }
-
- // 娓呯┖UI瀛楀吀鍜屾爤
- uiDict.Clear();
- uiStack.Clear();
- closedUIDict.Clear();
- }
-
- /// <summary>
- /// 鍒锋柊UI
- /// </summary>
- public void RefreshUI<T>() where T : UIBase
- {
- // 鑾峰彇UI绫诲瀷鍚嶇О
- string uiName = typeof(T).Name;
-
- // 妫�鏌I鏄惁瀛樺湪
- if (!uiDict.ContainsKey(uiName) || uiDict[uiName].Count == 0)
- {
- // 璁板綍璀﹀憡鏃ュ織
- Debug.LogWarning($"灏濊瘯鍒锋柊涓嶅瓨鍦ㄧ殑UI: {uiName}");
- return;
- }
-
- // 鍒锋柊鎵�鏈夎绫诲瀷鐨刄I瀹炰緥
- foreach (var ui in uiDict[uiName])
- {
- // 鍒锋柊UI
- ui.Refresh();
- }
- }
-
- /// <summary>
- /// 鍒锋柊鎵�鏈塙I
- /// </summary>
- public void RefreshAllUI()
- {
- // 閬嶅巻鎵�鏈塙I绫诲瀷
- foreach (var uiList in uiDict.Values)
- {
- // 閬嶅巻璇ョ被鍨嬬殑鎵�鏈塙I瀹炰緥
- foreach (var ui in uiList)
- {
- // 鍒锋柊UI
- ui.Refresh();
- }
- }
- }
-
- private void Update()
- {
- // 濡傛灉璺濈涓婃妫�鏌ョ殑鏃堕棿瓒呰繃浜嗘鏌ラ棿闅�
- if (Time.time - lastCheckTime > CHECK_INTERVAL)
- {
- // 鏇存柊涓婃妫�鏌ユ椂闂�
- lastCheckTime = Time.time;
- // 妫�鏌ュ苟鍏抽棴闀挎椂闂存湭浣跨敤鐨刄I
- CheckAndCloseIdleUI();
- }
- }
-
- #endregion
-
- #region 閲婃斁璧勬簮
-
- /// <summary>
- /// 閲婃斁璧勬簮
- /// </summary>
- public override void Release()
- {
- // 鍏抽棴鎵�鏈塙I
- DestroyAllUI();
-
- // 娓呯┖缂撳瓨
- layerSortingOrderCache.Clear();
- layerTransformCache.Clear();
- uiInstanceCounter.Clear();
-
- Debug.Log("UI绠$悊鍣ㄨ祫婧愰噴鏀惧畬鎴�");
- }
-
- #endregion
-}
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using System.Linq;
+
+/// <summary>
+/// UI绠$悊鍣� - 璐熻矗绠$悊鎵�鏈塙I鐣岄潰鐨勬樉绀恒�侀殣钘忓拰灞傜骇
+/// </summary>
+public class UIManager : ManagerBase<UIManager>
+{
+ #region 甯搁噺鍜屾灇涓�
+
+ // 鍩虹鎺掑簭椤哄簭
+ private const int BASE_SORTING_ORDER = 10;
+
+ #endregion
+
+ #region 瀛楁鍜屽睘鎬�
+
+ // UI鏍硅妭鐐�
+ private Transform uiRoot;
+
+ // 鍚勫眰绾х殑Transform
+ private Transform staticTrans;
+ private Transform bottomTrans;
+ private Transform midTrans;
+ private Transform topTrans;
+ private Transform systemTrans;
+
+ // UI瀛楀吀锛屽瓨鍌ㄦ墍鏈夊凡鍔犺浇鐨刄I锛岄敭涓篣I鍚嶇О锛屽�间负UI瀹炰緥
+ private Dictionary<string, List<UIBase>> uiDict = new Dictionary<string, List<UIBase>>();
+
+ // 瀛樺偍鍏抽棴浣嗘湭閿�姣佺殑UI锛岄敭涓篣I鍚嶇О锛屽�间负UI瀹炰緥
+ private Dictionary<string, List<UIBase>> closedUIDict = new Dictionary<string, List<UIBase>>();
+
+ // UI鏍堬紝鐢ㄤ簬绠$悊UI鐨勬樉绀洪『搴�
+ private Stack<UIBase> uiStack = new Stack<UIBase>();
+
+ // 褰撳墠鏈�楂樼殑鎺掑簭椤哄簭
+ private int currentHighestSortingOrder = 0;
+
+ // 褰撳墠鍥炲悎鏁帮紝鐢ㄤ簬璁板綍UI鐨勪娇鐢ㄦ儏鍐�
+ private int currentRound = 0;
+
+ // 缂撳瓨灞傜骇瀵瑰簲鐨勬帓搴忛『搴�
+ private Dictionary<UILayer, int> layerSortingOrderCache = new Dictionary<UILayer, int>();
+
+ // 缂撳瓨灞傜骇瀵瑰簲鐨凾ransform
+ private Dictionary<UILayer, Transform> layerTransformCache = new Dictionary<UILayer, Transform>();
+
+ // UI瀹炰緥璁℃暟鍣紝鐢ㄤ簬涓哄悓绫诲瀷UI鐢熸垚鍞竴鏍囪瘑
+ private Dictionary<string, int> uiInstanceCounter = new Dictionary<string, int>();
+
+ // 涓婃妫�鏌ユ椂闂�
+ private float lastCheckTime = 0f;
+ // 妫�鏌ラ棿闅旓紙绉掞級
+ private const float CHECK_INTERVAL = 5f;
+
+ public Action<UIBase> OnOpenWindow;
+
+ public Action<UIBase> OnCloseWindow;
+
+ #endregion
+
+ #region 鍒濆鍖�
+
+ /// <summary>
+ /// 鍒濆鍖朥I绠$悊鍣�
+ /// </summary>
+ public override void Init()
+ {
+ base.Init();
+
+ // 鍒濆鍖朥I鏍硅妭鐐�
+ InitUIRoot();
+
+ // 鍒濆鍖栫紦瀛�
+ layerSortingOrderCache.Clear();
+ layerTransformCache.Clear();
+ uiInstanceCounter.Clear();
+
+ Debug.Log("UI绠$悊鍣ㄥ垵濮嬪寲瀹屾垚");
+ }
+
+ /// <summary>
+ /// 鍒濆鍖朥I鏍硅妭鐐�
+ /// </summary>
+ private void InitUIRoot()
+ {
+ // 鏌ユ壘UI鏍硅妭鐐�
+ GameObject root = GameObject.Find("UIRoot");
+
+ // 濡傛灉鍦烘櫙涓病鏈塙I鏍硅妭鐐癸紝鍒欏垱寤轰竴涓�
+ if (root == null)
+ {
+ root = GameObject.Instantiate(BuiltInLoader.LoadPrefab("UIRoot"));
+ root.name = "UIRoot";
+ if (root == null)
+ {
+ Debug.LogError("鏃犳硶鎵惧埌UI鏍硅妭鐐�");
+ return;
+ }
+
+ // 娣诲姞DontDestroyOnLoad缁勪欢锛岀‘淇漊I鏍硅妭鐐瑰湪鍦烘櫙鍒囨崲鏃朵笉琚攢姣�
+ GameObject.DontDestroyOnLoad(root);
+ }
+
+ uiRoot = root.transform;
+ uiRoot.position = Vector3.zero;
+
+ staticTrans = uiRoot.Find("Static");
+ bottomTrans = uiRoot.Find("Bottom");
+ midTrans = uiRoot.Find("Middle");
+ topTrans = uiRoot.Find("Top");
+ systemTrans = uiRoot.Find("System");
+
+ layerTransformCache.Clear();
+ layerTransformCache.Add(UILayer.Static, staticTrans);
+ layerTransformCache.Add(UILayer.Bottom, bottomTrans);
+ layerTransformCache.Add(UILayer.Mid, midTrans);
+ layerTransformCache.Add(UILayer.Top, topTrans);
+ layerTransformCache.Add(UILayer.System, systemTrans);
+ }
+
+ #endregion
+
+ #region 杈呭姪鏂规硶
+
+ // 鑾峰彇UI灞傜骇瀵瑰簲鐨勫熀纭�鎺掑簭椤哄簭
+ private int GetBaseSortingOrderForLayer(UILayer layer)
+ {
+ // 灏濊瘯浠庣紦瀛樹腑鑾峰彇鎺掑簭椤哄簭
+ if (layerSortingOrderCache.TryGetValue(layer, out int order))
+ return order;
+
+ // 濡傛灉缂撳瓨涓病鏈夛紝浣跨敤鍘熸潵鐨勬柟娉曡绠楀苟缂撳瓨缁撴灉
+ int result;
+ switch (layer)
+ {
+ case UILayer.Static:
+ result = BASE_SORTING_ORDER;
+ break;
+ case UILayer.Bottom:
+ result = BASE_SORTING_ORDER * 10;
+ break;
+ case UILayer.Mid:
+ result = BASE_SORTING_ORDER * 100;
+ break;
+ case UILayer.Top:
+ result = BASE_SORTING_ORDER * 1000;
+ break;
+ case UILayer.System:
+ result = BASE_SORTING_ORDER * 10000;
+ break;
+ default:
+ result = BASE_SORTING_ORDER * 10;
+ break;
+ }
+
+ // 灏嗙粨鏋滃瓨鍏ョ紦瀛�
+ layerSortingOrderCache[layer] = result;
+ return result;
+ }
+
+ // 鑾峰彇灞傜骇瀵瑰簲鐨凾ransform
+ private Transform GetTransForLayer(UILayer layer)
+ {
+ // 灏濊瘯浠庣紦瀛樹腑鑾峰彇Transform
+ if (layerTransformCache.TryGetValue(layer, out Transform trans))
+ return trans;
+
+ // 濡傛灉缂撳瓨涓病鏈夛紝浣跨敤鍘熸潵鐨勬柟娉曡幏鍙栧苟缂撳瓨缁撴灉
+ Transform result;
+ switch (layer)
+ {
+ case UILayer.Static:
+ result = staticTrans;
+ break;
+ case UILayer.Bottom:
+ result = bottomTrans;
+ break;
+ case UILayer.Mid:
+ result = midTrans;
+ break;
+ case UILayer.Top:
+ result = topTrans;
+ break;
+ case UILayer.System:
+ result = systemTrans;
+ break;
+ default:
+ result = bottomTrans;
+ break;
+ }
+
+ // 灏嗙粨鏋滃瓨鍏ョ紦瀛�
+ layerTransformCache[layer] = result;
+ return result;
+ }
+
+ // 鑾峰彇UI瀹炰緥锛屽鏋滀笉瀛樺湪鍒欒繑鍥瀗ull
+ public T GetUI<T>() where T : UIBase
+ {
+ // 鑾峰彇UI绫诲瀷鍚嶇О
+ string uiName = typeof(T).Name;
+ if (string.IsNullOrEmpty(uiName))
+ {
+ // 璁板綍閿欒鏃ュ織
+ Debug.LogError("UI鍚嶇О涓虹┖");
+ return null;
+ }
+
+ // 灏濊瘯浠庡瓧鍏镐腑鑾峰彇UI瀹炰緥鍒楄〃
+ if (uiDict.TryGetValue(uiName, out List<UIBase> uiList) && uiList.Count > 0)
+ {
+ // 杩斿洖绗竴涓疄渚�
+ return uiList[0] as T;
+ }
+
+ // 濡傛灉涓嶅瓨鍦紝杩斿洖null
+ return null;
+ }
+
+ public List<T> GetUIList<T>() where T : UIBase
+ {
+ List<T> uiList = new List<T>();
+
+ // 鑾峰彇UI绫诲瀷鍚嶇О
+ string uiName = typeof(T).Name;
+ if (string.IsNullOrEmpty(uiName))
+ {
+ // 璁板綍閿欒鏃ュ織
+ Debug.LogError("UI鍚嶇О涓虹┖");
+ return uiList;
+ }
+
+ // 灏濊瘯浠庡瓧鍏镐腑鑾峰彇UI瀹炰緥鍒楄〃
+ List<UIBase> tempList = null;
+ uiDict.TryGetValue(uiName, out tempList);
+
+ if (tempList != null)
+ {
+ for (int i = 0; i < tempList.Count; i++)
+ {
+ UIBase ui = tempList[i];
+ if (null != ui)
+ {
+ uiList.Add(ui as T);
+ }
+ }
+ }
+
+ return uiList;
+ }
+
+ public bool IsOpenedInList<T>() where T : UIBase
+ {
+ List<T> uiList = GetUIList<T>();
+
+ foreach (T ui in uiList)
+ {
+ if (ui.IsActive())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public bool IsOpened<T>() where T : UIBase
+ {
+ T ui = GetUI<T>();
+
+ if (null != ui)
+ {
+ return ui.IsActive();
+ }
+
+ return false;
+ }
+
+ // 鑾峰彇鎸囧畾绫诲瀷鐨勬墍鏈塙I瀹炰緥
+ public List<T> GetAllUI<T>() where T : UIBase
+ {
+ // 鑾峰彇UI绫诲瀷鍚嶇О
+ string uiName = typeof(T).Name;
+ if (string.IsNullOrEmpty(uiName))
+ {
+ // 璁板綍閿欒鏃ュ織
+ Debug.LogError("UI鍚嶇О涓虹┖");
+ return new List<T>();
+ }
+
+ // 灏濊瘯浠庡瓧鍏镐腑鑾峰彇UI瀹炰緥鍒楄〃
+ if (uiDict.TryGetValue(uiName, out List<UIBase> uiList) && uiList.Count > 0)
+ {
+ // 灏嗗垪琛ㄤ腑鐨勬墍鏈夊疄渚嬭浆鎹负鎸囧畾绫诲瀷骞惰繑鍥�
+ return uiList.Cast<T>().ToList();
+ }
+
+ // 濡傛灉涓嶅瓨鍦紝杩斿洖绌哄垪琛�
+ return new List<T>();
+ }
+
+ // 鏇存柊鐖剁骇UI鐨勫洖鍚堟暟
+ private void UpdateParentUIRounds(UIBase ui)
+ {
+ // 濡傛灉UI涓虹┖鎴栦笉鏀寔鐖跺瓙鍏崇郴锛岀洿鎺ヨ繑鍥�
+ if (ui == null || !ui.supportParentChildRelation)
+ return;
+
+ // 鑾峰彇鐖剁骇UI
+ UIBase parentUI = ui.parentUI;
+ // 閬嶅巻鎵�鏈夌埗绾I锛屾洿鏂板洖鍚堟暟
+ while (parentUI != null)
+ {
+ // 鏇存柊鐖剁骇UI鐨勬渶鍚庝娇鐢ㄥ洖鍚堟暟
+ parentUI.lastUsedRound = currentRound;
+ // 缁х画鍚戜笂鏌ユ壘鐖剁骇UI
+ parentUI = parentUI.parentUI;
+ }
+ }
+
+ // 閫掑綊鏀堕泦鎵�鏈夊瓙UI
+ private void CollectChildrenUI(UIBase ui, List<UIBase> result)
+ {
+ // 濡傛灉UI涓虹┖鎴栨病鏈夊瓙UI鎴栦笉鏀寔鐖跺瓙鍏崇郴锛岀洿鎺ヨ繑鍥�
+ if (ui == null || !ui.supportParentChildRelation || ui.childrenUI == null || ui.childrenUI.Count == 0)
+ return;
+
+ // 閬嶅巻鎵�鏈夊瓙UI
+ foreach (var childUI in ui.childrenUI)
+ {
+ // 濡傛灉缁撴灉鍒楄〃涓笉鍖呭惈褰撳墠瀛怳I锛屽垯娣诲姞
+ if (!result.Contains(childUI))
+ {
+ // 娣诲姞鍒扮粨鏋滃垪琛�
+ result.Add(childUI);
+ // 閫掑綊鏀堕泦瀛怳I鐨勫瓙UI
+ CollectChildrenUI(childUI, result);
+ }
+ }
+ }
+
+ /// <summary>
+ /// 妫�鏌ュ苟鍏抽棴闀挎椂闂存湭浣跨敤鐨刄I
+ /// </summary>
+ public void CheckAndCloseIdleUI()
+ {
+ // 濡傛灉娌℃湁UI锛岀洿鎺ヨ繑鍥�
+ if (uiDict.Count == 0 && closedUIDict.Count == 0)
+ return;
+
+ // 鍒涘缓闇�瑕佸叧闂殑UI鍒楄〃
+ List<UIBase> uiToClose = new List<UIBase>();
+
+ // 閬嶅巻鎵�鏈夋椿璺僓I
+ foreach (var uiList in uiDict.Values)
+ {
+ foreach (var ui in uiList)
+ {
+ // 濡傛灉UI鏄寔涔呭寲鐨勶紝璺宠繃
+ if (ui.isPersistent)
+ continue;
+
+ if (ui.IsActive())
+ continue;
+
+ // 璁$畻UI绌洪棽鐨勫洖鍚堟暟
+ int idleRounds = currentRound - ui.lastUsedRound;
+
+ // 濡傛灉绌洪棽鍥炲悎鏁拌秴杩囨渶澶х┖闂插洖鍚堟暟锛屾坊鍔犲埌鍏抽棴鍒楄〃
+ if (idleRounds > ui.maxIdleRounds)
+ {
+ uiToClose.Add(ui);
+ }
+ }
+ }
+
+ // 閬嶅巻鎵�鏈夊叧闂殑UI
+ List<string> emptyKeys = new List<string>();
+ foreach (var kvp in closedUIDict)
+ {
+ string uiName = kvp.Key;
+ List<UIBase> uiList = kvp.Value;
+ List<UIBase> uiToRemove = new List<UIBase>();
+
+ foreach (var ui in uiList)
+ {
+ // 璁$畻UI绌洪棽鐨勫洖鍚堟暟
+ int idleRounds = currentRound - ui.lastUsedRound;
+
+ // 濡傛灉绌洪棽鍥炲悎鏁拌秴杩囨渶澶х┖闂插洖鍚堟暟锛屾坊鍔犲埌鍏抽棴鍒楄〃
+ if (idleRounds > ui.maxIdleRounds)
+ {
+ uiToClose.Add(ui);
+ uiToRemove.Add(ui);
+ }
+ }
+
+ // 浠庡叧闂垪琛ㄤ腑绉婚櫎闇�瑕侀攢姣佺殑UI
+ foreach (var ui in uiToRemove)
+ {
+ uiList.Remove(ui);
+ }
+
+ // 濡傛灉鍒楄〃涓虹┖锛岃褰曢渶瑕佷粠瀛楀吀涓Щ闄ょ殑閿�
+ if (uiList.Count == 0)
+ {
+ emptyKeys.Add(uiName);
+ }
+ }
+
+ // 浠庡瓧鍏镐腑绉婚櫎绌哄垪琛�
+ foreach (var key in emptyKeys)
+ {
+ closedUIDict.Remove(key);
+ }
+
+ // 閿�姣佹墍鏈夐渶瑕佸叧闂殑UI
+ foreach (var ui in uiToClose)
+ {
+ // 璁板綍鏃ュ織
+ Debug.Log($"閿�姣侀暱鏃堕棿鏈娇鐢ㄧ殑UI: {ui.uiName}, 绌洪棽鍥炲悎鏁�: {currentRound - ui.lastUsedRound}");
+ // 閿�姣乁I瀵硅薄
+ GameObject.Destroy(ui.gameObject);
+ }
+ }
+
+ // // 鐢熸垚UI瀹炰緥鐨勫敮涓�鏍囪瘑
+ // private string GenerateUIInstanceID(string uiName)
+ // {
+ // // 濡傛灉璁℃暟鍣ㄤ腑涓嶅瓨鍦ㄨUI绫诲瀷锛屽垵濮嬪寲涓�0
+ // if (!uiInstanceCounter.ContainsKey(uiName))
+ // {
+ // uiInstanceCounter[uiName] = 0;
+ // }
+
+ // // 閫掑璁℃暟鍣�
+ // uiInstanceCounter[uiName]++;
+
+ // // 杩斿洖甯︽湁璁℃暟鐨勫敮涓�鏍囪瘑
+ // return $"{uiName}_{uiInstanceCounter[uiName]}";
+ // }
+
+ #endregion
+
+ #region UI璧勬簮绠$悊
+
+ private UIBase LoadUIResource(string uiName)
+ {
+ // 浠庤祫婧愮鐞嗗櫒鍔犺浇UI棰勫埗浣�
+ GameObject prefab = ResManager.Instance.LoadAsset<GameObject>("UI", uiName);
+
+ // 妫�鏌ラ鍒朵綋鏄惁鍔犺浇鎴愬姛
+ if (prefab == null)
+ {
+ // 璁板綍閿欒鏃ュ織
+ Debug.LogError($"鍔犺浇UI棰勫埗浣撳け璐�: {uiName}");
+ return null;
+ }
+
+ // 瀹炰緥鍖朥I瀵硅薄
+ GameObject uiObject = GameObject.Instantiate(prefab);
+ // 璁剧疆瀵硅薄鍚嶇О
+ uiObject.name = uiName;
+
+ // 閫氳繃uiName鏄犲皠Type
+ Type uiType = Type.GetType(uiName);
+ if (uiType == null)
+ {
+ Debug.LogError($"鎵句笉鍒癠I绫诲瀷: {uiName}");
+ return null;
+ }
+
+ // 鑾峰彇UI鍩虹被缁勪欢
+ UIBase uiBase = uiObject.GetComponent(uiType) as UIBase;
+
+ // 妫�鏌I鍩虹被缁勪欢鏄惁瀛樺湪
+ if (uiBase == null)
+ {
+ // 璁板綍閿欒鏃ュ織
+ Debug.LogError($"UI棰勫埗浣� {uiName} 娌℃湁 UIBase 缁勪欢鎴栫被鍨嬩笉鍖归厤");
+ return null;
+ }
+
+ // 璁剧疆UI鍚嶇О
+ uiBase.uiName = uiName;
+
+ // 璁剧疆鐖惰妭鐐逛负UI鏍硅妭鐐�
+ Transform parentTrans = GetTransForLayer(uiBase.uiLayer);
+
+ uiObject.transform.SetParent(parentTrans, false);
+
+ // 璁剧疆鎺掑簭椤哄簭
+ int baseSortingOrder = GetBaseSortingOrderForLayer(uiBase.uiLayer);
+ uiBase.SetSortingOrder(baseSortingOrder);
+
+ return uiBase;
+ }
+
+ // 鍔犺浇UI棰勫埗浣�
+ private T LoadUIResource<T>(string uiName) where T : UIBase
+ {
+ return LoadUIResource(uiName) as T;
+ }
+
+ #endregion
+
+ #region UI鎺掑簭绠$悊
+
+ // 鏇存柊UI鎺掑簭椤哄簭
+ private void UpdateUISortingOrder()
+ {
+ // 閲嶇疆褰撳墠鏈�楂樻帓搴忛『搴�
+ currentHighestSortingOrder = 0;
+
+ // 閬嶅巻UI鏍堬紝璁剧疆鎺掑簭椤哄簭
+ UIBase[] uiArray = new UIBase[uiStack.Count];
+ uiStack.CopyTo(uiArray, 0);
+
+ // 鍏堟寜鐓ILayer杩涜鎺掑簭锛岀劧鍚庡啀鎸夌収鏍堥『搴忔帓搴�
+ Array.Sort(uiArray, (a, b) => {
+ // 姣旇緝UI灞傜骇
+ int layerCompare = a.uiLayer.CompareTo(b.uiLayer);
+ if (layerCompare != 0)
+ return layerCompare;
+
+ // 鍚屽眰绾у唴锛屾寜鐓ф爤涓殑椤哄簭鎺掑簭
+ return Array.IndexOf(uiArray, a).CompareTo(Array.IndexOf(uiArray, b));
+ });
+
+ // 閬嶅巻鎺掑簭鍚庣殑UI鏁扮粍锛岃缃帓搴忛『搴�
+ foreach (var ui in uiArray)
+ {
+ // 鑾峰彇鍩虹鎺掑簭椤哄簭
+ int baseSortingOrder = GetBaseSortingOrderForLayer(ui.uiLayer);
+ // 璁$畻褰撳墠UI鐨勬帓搴忛『搴�
+ int sortingOrder = baseSortingOrder + currentHighestSortingOrder;
+ // 璁剧疆UI鐨勬帓搴忛『搴�
+ ui.SetSortingOrder(sortingOrder);
+ // 鏇存柊褰撳墠鏈�楂樻帓搴忛『搴�
+ currentHighestSortingOrder += 10;
+ }
+ }
+
+ #endregion
+
+ #region UI鎿嶄綔
+
+
+
+ private UIBase GetLastSupportParentChildRelationUI()
+ {
+ List<UIBase> tempList = new List<UIBase>();
+
+ UIBase target = null;
+
+ while (target == null && uiStack.Count > 0)
+ {
+ UIBase uiBase = uiStack.Pop();
+
+ if (uiBase != null && uiBase.supportParentChildRelation && !uiBase.isMainUI)
+ {
+ target = uiBase;
+ }
+
+ tempList.Add(uiBase);
+ }
+
+ for (int i = tempList.Count - 1; i >= 0; i--)
+ {
+ uiStack.Push(tempList[i]);
+ }
+
+ return target;
+ }
+
+ public UIBase OpenWindow(string uiName)
+ {
+ // 浼樺厛浠巆losedUIDict涓幏鍙�
+ UIBase parentUI = null;
+
+ UIBase returnValue = null;
+
+ if (closedUIDict.TryGetValue(uiName, out List<UIBase> closedUIList) && closedUIList.Count > 0)
+ {
+ returnValue = closedUIList[0] as UIBase;
+ closedUIList.RemoveAt(0);
+
+ if (closedUIList.Count == 0)
+ {
+ closedUIDict.Remove(uiName);
+ }
+ }
+ else
+ {
+ returnValue = LoadUIResource(uiName);
+ if (returnValue == null)
+ {
+ // 璁板綍閿欒鏃ュ織
+ Debug.LogError($"鎵撳紑UI澶辫触: {uiName}");
+ return null;
+ }
+ }
+
+ returnValue.gameObject.SetActive(true);
+
+ // 鑷姩璁剧疆鐖剁骇UI锛堝鏋滄湭鎸囧畾涓旀敮鎸佺埗瀛愬叧绯伙級
+ if (returnValue.supportParentChildRelation && uiStack.Count > 0)
+ {
+ // 鑾峰彇鏍堥《UI
+ parentUI = GetLastSupportParentChildRelationUI();
+ }
+
+ // 璁剧疆鐖剁骇UI
+ if (parentUI != null)
+ {
+ // 璁剧疆鐖跺瓙鍏崇郴
+ returnValue.parentUI = parentUI;
+ if (parentUI.childrenUI == null)
+ {
+ // 鍒濆鍖栫埗绾I鐨勫瓙UI鍒楄〃
+ parentUI.childrenUI = new List<UIBase>();
+ }
+ // 娣诲姞鍒扮埗绾I鐨勫瓙UI鍒楄〃
+ parentUI.childrenUI.Add(returnValue);
+ }
+
+ // 鏇存柊鍥炲悎鏁�
+ currentRound++;
+ // 璁剧疆UI鐨勬渶鍚庝娇鐢ㄥ洖鍚堟暟
+ returnValue.lastUsedRound = currentRound;
+ // 鏇存柊鐖剁骇UI鐨勫洖鍚堟暟
+ UpdateParentUIRounds(returnValue);
+
+ // 灏哢I娣诲姞鍒板瓧鍏镐腑
+ if (!uiDict.ContainsKey(uiName))
+ {
+ // 濡傛灉瀛楀吀涓笉瀛樺湪璇ョ被鍨嬬殑UI锛屽垱寤烘柊鍒楄〃
+ uiDict[uiName] = new List<UIBase>();
+ }
+ // 娣诲姞鍒癠I鍒楄〃
+ uiDict[uiName].Add(returnValue);
+
+ // 灏哢I娣诲姞鍒版爤涓�
+ uiStack.Push(returnValue);
+
+ // 鏇存柊UI鎺掑簭椤哄簭
+ UpdateUISortingOrder();
+
+ // 鎵撳紑UI
+ returnValue.HandleOpen();
+
+ OnOpenWindow?.Invoke(returnValue);
+
+ // 妫�鏌ュ苟鍏抽棴闀挎椂闂存湭浣跨敤鐨刄I
+ CheckAndCloseIdleUI();
+
+ return returnValue;
+ }
+
+ /// <summary>
+ /// 鎵撳紑UI
+ /// </summary>
+ public T OpenWindow<T>() where T : UIBase
+ {
+ // 鑾峰彇UI绫诲瀷鍚嶇О
+ string uiName = typeof(T).Name;
+ return OpenWindow(uiName) as T;
+ }
+
+ /// <summary>
+ /// 鍏抽棴UI
+ /// </summary>
+ public void CloseWindow<T>(bool destroy = false) where T : UIBase
+ {
+ // 鑾峰彇UI绫诲瀷鍚嶇О
+ string uiName = typeof(T).Name;
+
+ CloseWindow(uiName, destroy);
+
+ }
+
+ public void CloseWindow(string uiName, bool destroy = false)
+ {
+ // 妫�鏌I鏄惁瀛樺湪
+ if (!uiDict.ContainsKey(uiName) || uiDict[uiName].Count == 0)
+ {
+ // 璁板綍璀﹀憡鏃ュ織
+ Debug.LogWarning($"灏濊瘯鍏抽棴涓嶅瓨鍦ㄧ殑UI: {uiName}");
+ return;
+ }
+
+ // 鑾峰彇绗竴涓猆I瀹炰緥
+ UIBase ui = uiDict[uiName][0];
+
+ // 鍏抽棴UI
+ CloseWindow(ui, destroy);
+ }
+
+ /// <summary>
+ /// 鍏抽棴鎸囧畾鐨刄I瀹炰緥
+ /// </summary>
+ public void CloseWindow(UIBase ui, bool destroy = false)
+ {
+ // 妫�鏌I鏄惁涓虹┖
+ if (ui == null)
+ {
+ // 璁板綍璀﹀憡鏃ュ織
+ Debug.LogWarning("灏濊瘯鍏抽棴绌篣I");
+ return;
+ }
+
+ // 鑾峰彇UI绫诲瀷鍚嶇О
+ string uiName = ui.uiName;
+
+ // 鏀堕泦鎵�鏈夊瓙UI
+ List<UIBase> childrenUI = new List<UIBase>();
+ if (ui.supportParentChildRelation)
+ {
+ CollectChildrenUI(ui, childrenUI);
+ }
+
+ // 鍏堝叧闂墍鏈夊瓙UI
+ foreach (var childUI in childrenUI)
+ {
+ // 鍏抽棴瀛怳I
+ CloseWindow(childUI, destroy);
+ }
+
+ // 浠庢爤涓Щ闄I
+ Stack<UIBase> tempStack = new Stack<UIBase>();
+ while (uiStack.Count > 0)
+ {
+ // 寮瑰嚭鏍堥《UI
+ UIBase tempUI = uiStack.Pop();
+ // 濡傛灉涓嶆槸瑕佸叧闂殑UI锛屽垯淇濆瓨鍒颁复鏃舵爤涓�
+ if (tempUI != ui)
+ {
+ tempStack.Push(tempUI);
+ }
+ }
+
+ // 灏嗕复鏃舵爤涓殑UI閲嶆柊鍘嬪叆鏍堜腑
+ while (tempStack.Count > 0)
+ {
+ uiStack.Push(tempStack.Pop());
+ }
+
+ // 浠庡瓧鍏镐腑绉婚櫎UI
+ if (uiDict.ContainsKey(uiName))
+ {
+ // 浠嶶I鍒楄〃涓Щ闄�
+ uiDict[uiName].Remove(ui);
+ // 濡傛灉鍒楄〃涓虹┖锛屼粠瀛楀吀涓Щ闄よ绫诲瀷
+ if (uiDict[uiName].Count == 0)
+ {
+ uiDict.Remove(uiName);
+ }
+ }
+
+ // 浠庣埗绾I鐨勫瓙UI鍒楄〃涓Щ闄�
+ if (ui.supportParentChildRelation && ui.parentUI != null && ui.parentUI.childrenUI != null)
+ {
+ // 浠庣埗绾I鐨勫瓙UI鍒楄〃涓Щ闄�
+ ui.parentUI.childrenUI.Remove(ui);
+ }
+
+ // 鍏抽棴UI
+ ui.HandleClose();
+ OnCloseWindow?.Invoke(ui);
+
+ if (destroy)
+ {
+ // 閿�姣乁I瀵硅薄
+ GameObject.Destroy(ui.gameObject);
+ }
+ else
+ {
+ // 娣诲姞鍒癱losedUIDict
+ if (!closedUIDict.ContainsKey(uiName))
+ {
+ closedUIDict[uiName] = new List<UIBase>();
+ }
+ closedUIDict[uiName].Add(ui);
+
+ // 闅愯棌UI
+ ui.gameObject.SetActive(false);
+ }
+
+ // 鏇存柊UI鎺掑簭椤哄簭
+ UpdateUISortingOrder();
+ }
+
+ /// <summary>
+ /// 鍏抽棴鎸囧畾绫诲瀷鐨勬墍鏈塙I瀹炰緥
+ /// </summary>
+ public void CloseAllWindows<T>() where T : UIBase
+ {
+ // 鑾峰彇UI绫诲瀷鍚嶇О
+ string uiName = typeof(T).Name;
+
+ // 妫�鏌I鏄惁瀛樺湪
+ if (!uiDict.ContainsKey(uiName) || uiDict[uiName].Count == 0)
+ {
+ // 璁板綍璀﹀憡鏃ュ織
+ Debug.LogWarning($"灏濊瘯鍏抽棴涓嶅瓨鍦ㄧ殑UI: {uiName}");
+ return;
+ }
+
+ // 鍒涘缓UI瀹炰緥鍒楄〃鐨勫壇鏈紝鍥犱负鍦ㄥ叧闂繃绋嬩腑浼氫慨鏀瑰師鍒楄〃
+ List<UIBase> uiListCopy = new List<UIBase>(uiDict[uiName]);
+
+ // 鍏抽棴鎵�鏈塙I瀹炰緥
+ foreach (var ui in uiListCopy)
+ {
+ // 鍏抽棴UI瀹炰緥
+ CloseWindow(ui, false);
+ }
+ }
+
+ /// <summary>
+ /// 鍏抽棴鎵�鏈塙I
+ /// </summary>
+ public void DestroyAllUI()
+ {
+ // 鍒涘缓UI鏍堢殑鍓湰锛屽洜涓哄湪鍏抽棴杩囩▼涓細淇敼鍘熸爤
+ UIBase[] uiArray = new UIBase[uiStack.Count];
+ uiStack.CopyTo(uiArray, 0);
+
+ // 鍏抽棴鎵�鏈塙I
+ foreach (var ui in uiArray)
+ {
+ // 鍏抽棴UI
+ CloseWindow(ui, true);
+ }
+
+ // 娓呯┖UI瀛楀吀鍜屾爤
+ uiDict.Clear();
+ uiStack.Clear();
+ closedUIDict.Clear();
+ }
+
+ /// <summary>
+ /// 鍒锋柊UI
+ /// </summary>
+ public void RefreshUI<T>() where T : UIBase
+ {
+ // 鑾峰彇UI绫诲瀷鍚嶇О
+ string uiName = typeof(T).Name;
+
+ // 妫�鏌I鏄惁瀛樺湪
+ if (!uiDict.ContainsKey(uiName) || uiDict[uiName].Count == 0)
+ {
+ // 璁板綍璀﹀憡鏃ュ織
+ Debug.LogWarning($"灏濊瘯鍒锋柊涓嶅瓨鍦ㄧ殑UI: {uiName}");
+ return;
+ }
+
+ // 鍒锋柊鎵�鏈夎绫诲瀷鐨刄I瀹炰緥
+ foreach (var ui in uiDict[uiName])
+ {
+ // 鍒锋柊UI
+ ui.Refresh();
+ }
+ }
+
+ /// <summary>
+ /// 鍒锋柊鎵�鏈塙I
+ /// </summary>
+ public void RefreshAllUI()
+ {
+ // 閬嶅巻鎵�鏈塙I绫诲瀷
+ foreach (var uiList in uiDict.Values)
+ {
+ // 閬嶅巻璇ョ被鍨嬬殑鎵�鏈塙I瀹炰緥
+ foreach (var ui in uiList)
+ {
+ // 鍒锋柊UI
+ ui.Refresh();
+ }
+ }
+ }
+
+ private void Update()
+ {
+ // 濡傛灉璺濈涓婃妫�鏌ョ殑鏃堕棿瓒呰繃浜嗘鏌ラ棿闅�
+ if (Time.time - lastCheckTime > CHECK_INTERVAL)
+ {
+ // 鏇存柊涓婃妫�鏌ユ椂闂�
+ lastCheckTime = Time.time;
+ // 妫�鏌ュ苟鍏抽棴闀挎椂闂存湭浣跨敤鐨刄I
+ CheckAndCloseIdleUI();
+ }
+ }
+
+ #endregion
+
+ #region 閲婃斁璧勬簮
+
+ /// <summary>
+ /// 閲婃斁璧勬簮
+ /// </summary>
+ public override void Release()
+ {
+ // 鍏抽棴鎵�鏈塙I
+ DestroyAllUI();
+
+ // 娓呯┖缂撳瓨
+ layerSortingOrderCache.Clear();
+ layerTransformCache.Clear();
+ uiInstanceCounter.Clear();
+
+ Debug.Log("UI绠$悊鍣ㄨ祫婧愰噴鏀惧畬鎴�");
+ }
+
+ #endregion
+}
diff --git a/Main/UI/UIManager.cs.meta b/Main/Manager/UIManager.cs.meta
similarity index 100%
rename from Main/UI/UIManager.cs.meta
rename to Main/Manager/UIManager.cs.meta
diff --git a/Main/Manager/ResManager.cs b/Main/ResModule/ResManager.cs
similarity index 100%
rename from Main/Manager/ResManager.cs
rename to Main/ResModule/ResManager.cs
diff --git a/Main/Manager/ResManager.cs.meta b/Main/ResModule/ResManager.cs.meta
similarity index 100%
rename from Main/Manager/ResManager.cs.meta
rename to Main/ResModule/ResManager.cs.meta
diff --git a/Main/Battle.meta b/Main/System/Battle.meta
similarity index 100%
rename from Main/Battle.meta
rename to Main/System/Battle.meta
diff --git a/Main/Battle/BattleField.meta b/Main/System/Battle/BattleField.meta
similarity index 100%
rename from Main/Battle/BattleField.meta
rename to Main/System/Battle/BattleField.meta
diff --git a/Main/Battle/BattleField/BattleField.cs b/Main/System/Battle/BattleField/BattleField.cs
similarity index 100%
rename from Main/Battle/BattleField/BattleField.cs
rename to Main/System/Battle/BattleField/BattleField.cs
diff --git a/Main/Battle/BattleField/BattleField.cs.meta b/Main/System/Battle/BattleField/BattleField.cs.meta
similarity index 100%
rename from Main/Battle/BattleField/BattleField.cs.meta
rename to Main/System/Battle/BattleField/BattleField.cs.meta
diff --git a/Main/Manager/GameSystemManager/BattleManager.cs b/Main/System/Battle/BattleManager.cs
similarity index 99%
rename from Main/Manager/GameSystemManager/BattleManager.cs
rename to Main/System/Battle/BattleManager.cs
index 5d7aa58..074c581 100644
--- a/Main/Manager/GameSystemManager/BattleManager.cs
+++ b/Main/System/Battle/BattleManager.cs
@@ -1,43 +1,43 @@
-using System.Collections.Generic;
-using UnityEngine;
-
-
-
-public class BattleManager : GameSystemManager<BattleManager>
-{
- protected Dictionary<int, BattleField> battleFields = new Dictionary<int, BattleField>();
-
-
- public override void Init()
- {
- base.Init();
- EventBroadcast.Instance.AddListener<int, int>(EventName.BATTLE_ACTION_OVER, OnActionOver);
- }
-
- public override void Release()
- {
- base.Release();
- }
-
- private void OnActionOver(int battleFieldId, int attackId)
- {
- BattleField battleField = null;
- if (battleFields.TryGetValue(battleFieldId, out battleField))
- {
- battleField.OnActionOver(attackId);
- }
- else
- {
- Debug.LogError("BattleManager OnActionOver battleFieldId:" + battleFieldId + " not find");
- }
- }
-
- public void Run()
- {
- foreach (var battleField in battleFields)
- {
- battleField.Value.Run();
- }
- }
-
+using System.Collections.Generic;
+using UnityEngine;
+
+
+
+public class BattleManager : GameSystemManager<BattleManager>
+{
+ protected Dictionary<int, BattleField> battleFields = new Dictionary<int, BattleField>();
+
+
+ public override void Init()
+ {
+ base.Init();
+ EventBroadcast.Instance.AddListener<int, int>(EventName.BATTLE_ACTION_OVER, OnActionOver);
+ }
+
+ public override void Release()
+ {
+ base.Release();
+ }
+
+ private void OnActionOver(int battleFieldId, int attackId)
+ {
+ BattleField battleField = null;
+ if (battleFields.TryGetValue(battleFieldId, out battleField))
+ {
+ battleField.OnActionOver(attackId);
+ }
+ else
+ {
+ Debug.LogError("BattleManager OnActionOver battleFieldId:" + battleFieldId + " not find");
+ }
+ }
+
+ public void Run()
+ {
+ foreach (var battleField in battleFields)
+ {
+ battleField.Value.Run();
+ }
+ }
+
}
\ No newline at end of file
diff --git a/Main/Manager/GameSystemManager/BattleManager.cs.meta b/Main/System/Battle/BattleManager.cs.meta
similarity index 100%
rename from Main/Manager/GameSystemManager/BattleManager.cs.meta
rename to Main/System/Battle/BattleManager.cs.meta
diff --git a/Main/Battle/BattleMode.cs b/Main/System/Battle/BattleMode.cs
similarity index 100%
rename from Main/Battle/BattleMode.cs
rename to Main/System/Battle/BattleMode.cs
diff --git a/Main/Battle/BattleMode.cs.meta b/Main/System/Battle/BattleMode.cs.meta
similarity index 100%
rename from Main/Battle/BattleMode.cs.meta
rename to Main/System/Battle/BattleMode.cs.meta
diff --git a/Main/Battle/BattleObject.meta b/Main/System/Battle/BattleObject.meta
similarity index 100%
rename from Main/Battle/BattleObject.meta
rename to Main/System/Battle/BattleObject.meta
diff --git a/Main/Battle/BattleObject/BattleObjMgr.cs b/Main/System/Battle/BattleObject/BattleObjMgr.cs
similarity index 100%
rename from Main/Battle/BattleObject/BattleObjMgr.cs
rename to Main/System/Battle/BattleObject/BattleObjMgr.cs
diff --git a/Main/Battle/BattleObject/BattleObjMgr.cs.meta b/Main/System/Battle/BattleObject/BattleObjMgr.cs.meta
similarity index 100%
rename from Main/Battle/BattleObject/BattleObjMgr.cs.meta
rename to Main/System/Battle/BattleObject/BattleObjMgr.cs.meta
diff --git a/Main/Battle/BattleObject/BattleObject.cs b/Main/System/Battle/BattleObject/BattleObject.cs
similarity index 100%
rename from Main/Battle/BattleObject/BattleObject.cs
rename to Main/System/Battle/BattleObject/BattleObject.cs
diff --git a/Main/Battle/BattleObject/BattleObject.cs.meta b/Main/System/Battle/BattleObject/BattleObject.cs.meta
similarity index 100%
rename from Main/Battle/BattleObject/BattleObject.cs.meta
rename to Main/System/Battle/BattleObject/BattleObject.cs.meta
diff --git a/Main/Battle/BattleObject/BattleObjectFactory.cs b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
similarity index 100%
rename from Main/Battle/BattleObject/BattleObjectFactory.cs
rename to Main/System/Battle/BattleObject/BattleObjectFactory.cs
diff --git a/Main/Battle/BattleObject/BattleObjectFactory.cs.meta b/Main/System/Battle/BattleObject/BattleObjectFactory.cs.meta
similarity index 100%
rename from Main/Battle/BattleObject/BattleObjectFactory.cs.meta
rename to Main/System/Battle/BattleObject/BattleObjectFactory.cs.meta
diff --git a/Main/Battle/BattleObject/CardObject.cs b/Main/System/Battle/BattleObject/CardObject.cs
similarity index 100%
rename from Main/Battle/BattleObject/CardObject.cs
rename to Main/System/Battle/BattleObject/CardObject.cs
diff --git a/Main/Battle/BattleObject/CardObject.cs.meta b/Main/System/Battle/BattleObject/CardObject.cs.meta
similarity index 100%
rename from Main/Battle/BattleObject/CardObject.cs.meta
rename to Main/System/Battle/BattleObject/CardObject.cs.meta
diff --git a/Main/Battle/Motion.meta b/Main/System/Battle/Motion.meta
similarity index 100%
rename from Main/Battle/Motion.meta
rename to Main/System/Battle/Motion.meta
diff --git a/Main/Battle/Motion/MotionBase.cs b/Main/System/Battle/Motion/MotionBase.cs
similarity index 100%
rename from Main/Battle/Motion/MotionBase.cs
rename to Main/System/Battle/Motion/MotionBase.cs
diff --git a/Main/Battle/Motion/MotionBase.cs.meta b/Main/System/Battle/Motion/MotionBase.cs.meta
similarity index 100%
rename from Main/Battle/Motion/MotionBase.cs.meta
rename to Main/System/Battle/Motion/MotionBase.cs.meta
diff --git a/Main/Battle/Motion/MotionName.cs b/Main/System/Battle/Motion/MotionName.cs
similarity index 100%
rename from Main/Battle/Motion/MotionName.cs
rename to Main/System/Battle/Motion/MotionName.cs
diff --git a/Main/Battle/Motion/MotionName.cs.meta b/Main/System/Battle/Motion/MotionName.cs.meta
similarity index 100%
rename from Main/Battle/Motion/MotionName.cs.meta
rename to Main/System/Battle/Motion/MotionName.cs.meta
diff --git a/Main/Battle/RecordPlayer.meta b/Main/System/Battle/RecordPlayer.meta
similarity index 100%
rename from Main/Battle/RecordPlayer.meta
rename to Main/System/Battle/RecordPlayer.meta
diff --git a/Main/Battle/RecordPlayer/RecordAction.cs b/Main/System/Battle/RecordPlayer/RecordAction.cs
similarity index 100%
rename from Main/Battle/RecordPlayer/RecordAction.cs
rename to Main/System/Battle/RecordPlayer/RecordAction.cs
diff --git a/Main/Battle/RecordPlayer/RecordAction.cs.meta b/Main/System/Battle/RecordPlayer/RecordAction.cs.meta
similarity index 100%
rename from Main/Battle/RecordPlayer/RecordAction.cs.meta
rename to Main/System/Battle/RecordPlayer/RecordAction.cs.meta
diff --git a/Main/Battle/RecordPlayer/RecordActionType.cs b/Main/System/Battle/RecordPlayer/RecordActionType.cs
similarity index 100%
rename from Main/Battle/RecordPlayer/RecordActionType.cs
rename to Main/System/Battle/RecordPlayer/RecordActionType.cs
diff --git a/Main/Battle/RecordPlayer/RecordActionType.cs.meta b/Main/System/Battle/RecordPlayer/RecordActionType.cs.meta
similarity index 100%
rename from Main/Battle/RecordPlayer/RecordActionType.cs.meta
rename to Main/System/Battle/RecordPlayer/RecordActionType.cs.meta
diff --git a/Main/Battle/RecordPlayer/RecordPlayer.cs b/Main/System/Battle/RecordPlayer/RecordPlayer.cs
similarity index 100%
rename from Main/Battle/RecordPlayer/RecordPlayer.cs
rename to Main/System/Battle/RecordPlayer/RecordPlayer.cs
diff --git a/Main/Battle/RecordPlayer/RecordPlayer.cs.meta b/Main/System/Battle/RecordPlayer/RecordPlayer.cs.meta
similarity index 100%
rename from Main/Battle/RecordPlayer/RecordPlayer.cs.meta
rename to Main/System/Battle/RecordPlayer/RecordPlayer.cs.meta
diff --git a/Main/Card.meta b/Main/System/Card.meta
similarity index 100%
rename from Main/Card.meta
rename to Main/System/Card.meta
diff --git a/Main/Card/CardInfo.Properties.cs b/Main/System/Card/CardInfo.Properties.cs
similarity index 100%
rename from Main/Card/CardInfo.Properties.cs
rename to Main/System/Card/CardInfo.Properties.cs
diff --git a/Main/Card/CardInfo.Properties.cs.meta b/Main/System/Card/CardInfo.Properties.cs.meta
similarity index 100%
rename from Main/Card/CardInfo.Properties.cs.meta
rename to Main/System/Card/CardInfo.Properties.cs.meta
diff --git a/Main/Card/CardInfo.cs b/Main/System/Card/CardInfo.cs
similarity index 100%
rename from Main/Card/CardInfo.cs
rename to Main/System/Card/CardInfo.cs
diff --git a/Main/Card/CardInfo.cs.meta b/Main/System/Card/CardInfo.cs.meta
similarity index 100%
rename from Main/Card/CardInfo.cs.meta
rename to Main/System/Card/CardInfo.cs.meta
diff --git a/Main/Card/CardSkillMgr.cs b/Main/System/Card/CardSkillMgr.cs
similarity index 100%
rename from Main/Card/CardSkillMgr.cs
rename to Main/System/Card/CardSkillMgr.cs
diff --git a/Main/Card/CardSkillMgr.cs.meta b/Main/System/Card/CardSkillMgr.cs.meta
similarity index 100%
rename from Main/Card/CardSkillMgr.cs.meta
rename to Main/System/Card/CardSkillMgr.cs.meta
diff --git a/Main/Card/CardType.cs b/Main/System/Card/CardType.cs
similarity index 100%
rename from Main/Card/CardType.cs
rename to Main/System/Card/CardType.cs
diff --git a/Main/Card/CardType.cs.meta b/Main/System/Card/CardType.cs.meta
similarity index 100%
rename from Main/Card/CardType.cs.meta
rename to Main/System/Card/CardType.cs.meta
diff --git a/Main/Manager/GameSystemManager/ChatBubbleManager.cs b/Main/System/Chat/ChatBubbleManager.cs
similarity index 100%
rename from Main/Manager/GameSystemManager/ChatBubbleManager.cs
rename to Main/System/Chat/ChatBubbleManager.cs
diff --git a/Main/Manager/GameSystemManager/ChatBubbleManager.cs.meta b/Main/System/Chat/ChatBubbleManager.cs.meta
similarity index 100%
rename from Main/Manager/GameSystemManager/ChatBubbleManager.cs.meta
rename to Main/System/Chat/ChatBubbleManager.cs.meta
diff --git a/Main/Manager/GameSystemManager/ChatCenter.cs b/Main/System/Chat/ChatCenter.cs
similarity index 100%
rename from Main/Manager/GameSystemManager/ChatCenter.cs
rename to Main/System/Chat/ChatCenter.cs
diff --git a/Main/Manager/GameSystemManager/ChatCenter.cs.meta b/Main/System/Chat/ChatCenter.cs.meta
similarity index 100%
rename from Main/Manager/GameSystemManager/ChatCenter.cs.meta
rename to Main/System/Chat/ChatCenter.cs.meta
diff --git a/Main/Manager/GameSystemManager/ChatManager.cs b/Main/System/Chat/ChatManager.cs
similarity index 100%
rename from Main/Manager/GameSystemManager/ChatManager.cs
rename to Main/System/Chat/ChatManager.cs
diff --git a/Main/Manager/GameSystemManager/ChatManager.cs.meta b/Main/System/Chat/ChatManager.cs.meta
similarity index 100%
rename from Main/Manager/GameSystemManager/ChatManager.cs.meta
rename to Main/System/Chat/ChatManager.cs.meta
diff --git a/Main/Login/ClientVersion/VersionConfig.cs b/Main/System/ClientVersion/VersionConfig.cs
similarity index 100%
rename from Main/Login/ClientVersion/VersionConfig.cs
rename to Main/System/ClientVersion/VersionConfig.cs
diff --git a/Main/Login/ClientVersion/VersionConfig.cs.meta b/Main/System/ClientVersion/VersionConfig.cs.meta
similarity index 100%
rename from Main/Login/ClientVersion/VersionConfig.cs.meta
rename to Main/System/ClientVersion/VersionConfig.cs.meta
diff --git a/Main/Login/ClientVersion/VersionUtility.cs b/Main/System/ClientVersion/VersionUtility.cs
similarity index 100%
rename from Main/Login/ClientVersion/VersionUtility.cs
rename to Main/System/ClientVersion/VersionUtility.cs
diff --git a/Main/Login/ClientVersion/VersionUtility.cs.meta b/Main/System/ClientVersion/VersionUtility.cs.meta
similarity index 100%
rename from Main/Login/ClientVersion/VersionUtility.cs.meta
rename to Main/System/ClientVersion/VersionUtility.cs.meta
diff --git a/Main/Manager/GameSystemManager/GMCmdManager.cs b/Main/System/GMCommand/GMCmdManager.cs
similarity index 100%
rename from Main/Manager/GameSystemManager/GMCmdManager.cs
rename to Main/System/GMCommand/GMCmdManager.cs
diff --git a/Main/Manager/GameSystemManager/GMCmdManager.cs.meta b/Main/System/GMCommand/GMCmdManager.cs.meta
similarity index 100%
rename from Main/Manager/GameSystemManager/GMCmdManager.cs.meta
rename to Main/System/GMCommand/GMCmdManager.cs.meta
diff --git a/Main/Manager/GameSystemManager/PackManager.cs b/Main/System/KnapSack/PackManager.cs
similarity index 99%
rename from Main/Manager/GameSystemManager/PackManager.cs
rename to Main/System/KnapSack/PackManager.cs
index 4a60b9b..5b5648b 100644
--- a/Main/Manager/GameSystemManager/PackManager.cs
+++ b/Main/System/KnapSack/PackManager.cs
@@ -1,1902 +1,1902 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using UnityEngine;
-using LitJson;
-using System.Text.RegularExpressions;
-using System.Collections;
-
- public class PackManager : GameSystemManager<PackManager>
- //public class PackModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
- {
- public static string StrengthAttrShift_RecordKey = "";
- public const string RecordKnapsackTitle = "RecordKnapsackTitle";
-
- Dictionary<int, int> DrugToDungeonDict { get; set; } //key 涓硅嵂ID,value鍓湰ID
- Dictionary<int, int[]> DungeonToDrugDict { get; set; } //key 鍓湰ID,value涓硅嵂ID鍒楄〃
- //public List<AttrFruitConfig> makeDruglist { get; private set; }
- Dictionary<int, Dictionary<int, int>> decomposeAttrDict = new Dictionary<int, Dictionary<int, int>>();
- string RoleEquipLocalSave = "";
- List<int> LocalSavePlaceArray { get; set; }
- Dictionary<int, List<int>> sharedUseCountItemDict { get; set; }
- bool isUpdatePlayerLv = false;
-
- //AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
- //ItemTipsModel itemTipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
-
- public int lsItemID = 150; //鍙厬鎹㈢殑鐏电煶鐗╁搧ID
- int lsItemCnt = 0;
- List<string> commonShowAwardEvents = new List<string>();
-
- public int[] autoUseItemIDs;
- UIEffect lingshiEffect; //鐏电煶鐗规晥
- public override void Init()
- {
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
- DTC0102_tagCDBPlayer.afterPlayerDataInitializeEvent += OnAfterPlayerDataInitialize;
- DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
- ParseConfig();
- //SysNotifyMgr.Instance.sysNotifyEvent += RefreshSysInfo;
- // List<DungeonOpenTimeConfig> dungeonlist = DungeonOpenTimeConfig.GetValues();
- // if (dungeonlist != null)
- // {
- // //DrugToDungeonDict = new Dictionary<int, int>();
- // DungeonToDrugDict = new Dictionary<int, int[]>();
-
- // for (int i = 0; i < dungeonlist.Count; i++)
- // {
- // int[] drugIdlist = dungeonlist[i].ElixirHint;
- // if (drugIdlist != null && drugIdlist.Length > 0)
- // {
- // DungeonToDrugDict.Add(dungeonlist[i].DataMapID, drugIdlist);
- // //for (int j = 0; j < drugIdlist.Length; j++)
- // //{
- // // DrugToDungeonDict.Add(drugIdlist[j], dungeonlist[i].DataMapID);
- // //}
- // }
- // }
- // }
-
- // makeDruglist = new List<AttrFruitConfig>();
- // List<AttrFruitConfig> fruitlist = AttrFruitConfig.GetValues();
- // for (int i = 0; i < fruitlist.Count; i++)
- // {
- // if (fruitlist[i].FuncID == 2)
- // {
- // makeDruglist.Add(fruitlist[i]);
- // }
- // }
- // StageLoad.Instance.onStageLoadFinish += OnStageLoadFinish;
-
- SetDevourEquipPlace();
-
- // decomposeAttrDict.Clear();
- // List<EquipDeComposeConfig> decomlist = EquipDeComposeConfig.GetValues();
- // for (int i = 0; i < decomlist.Count; i++)
- // {
- // JsonData attrData = JsonMapper.ToObject(decomlist[i].Attr);
- // Dictionary<int, int> attrDict = new Dictionary<int, int>();
- // decomposeAttrDict.Add(decomlist[i].LV, attrDict);
- // foreach (var id in attrData.Keys)
- // {
- // attrDict.Add(int.Parse(id), int.Parse(attrData[id].ToString()));
- // }
- // }
-
- FuncConfigConfig equipDecompose = FuncConfigConfig.Get("EquipDevourCount");
- minDecomposeNum = int.Parse(equipDecompose.Numerical1);
- defaultUnSelectlist = ConfigParse.GetMultipleStr<int>(equipDecompose.Numerical2);
-
- FuncConfigConfig ShareUseCntItem = FuncConfigConfig.Get("ShareUseCntItem");
- sharedUseCountItemDict = new Dictionary<int, List<int>>();
- JsonData shareUseJson = JsonMapper.ToObject(ShareUseCntItem.Numerical1);
- if (shareUseJson.IsArray)
- {
- for (int i = 0; i < shareUseJson.Count; i++)
- {
- var idListJson = shareUseJson[i];
- var idlist = new List<int>();
- sharedUseCountItemDict.Add(i, idlist);
- foreach (var id in idListJson)
- {
- idlist.Add(int.Parse(id.ToString()));
- }
- }
- }
-
- ParseItemCount();
-
- autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("ItemTipsNum").Numerical2);
- }
-
-
- public override void Release()
- {
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
- DTC0102_tagCDBPlayer.afterPlayerDataInitializeEvent -= OnAfterPlayerDataInitialize;
- DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
-FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
- // SysNotifyMgr.Instance.sysNotifyEvent -= RefreshSysInfo;
- }
-
- public Dictionary<int, string> textCountShow = new Dictionary<int, string>();
- public int[] textCountShow2;
- public List<int> gameCashShow = new List<int>();
-
- public void ParseItemCount()
- {
- var textConfig = FuncConfigConfig.Get("ItemCountShow");
- var json = JsonMapper.ToObject(textConfig.Numerical1);
- foreach (var key in json.Keys)
- {
- var itemID = int.Parse(key);
- textCountShow[itemID] = json[key].ToString();
- }
-
- textCountShow2 = JsonMapper.ToObject<int[]>(textConfig.Numerical2);
- gameCashShow = JsonMapper.ToObject<List<int>>(textConfig.Numerical3);
- }
-
-
- private void OnFuncStateChangeEvent(int id)
- {
- if (id == (int)FuncOpenEnum.EquipDecompose)
- {
- EquipDecomRedCtrl();
- }
- }
- public void OnBeforePlayerDataInitialize()
- {
- GlobalTimeEvent.Instance.secondEvent -= UpdateSecond;
- PlayerDatas.Instance.playerDataRefreshEvent -= UpdatePlayerLv;
- LocalSave.DeleteKey(RecordKnapsackTitle);
- cacheMapId = 0;
- playerPackDict.Clear();
- itemDayUseCntDict.Clear();
- itemSumUseCntDict.Clear();
- itemGUIDDict.Clear();
- isPlayBetterEquipEffect = false;
- colorType = EquipColorType.Orange;
- decomposeLv = 1;
- decomposeExp = 0;
- decomposeProgress = 0;
- isAutoDecompose = false;
- }
-
- public void OnAfterPlayerDataInitialize()
- {
-
- }
-
- public void OnPlayerLoginOk()
- {
- //ItemOperateUtility.Instance.RequestWarehouseData();
- EquipDecomRedCtrl();
- RoleEquipLocalSave = StringUtility.Contact("RoleEquipLocalSave", PlayerDatas.Instance.baseData.PlayerID);
- StrengthAttrShift_RecordKey = StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID, "StrengthAttrShift");
- if (LocalSave.GetIntArray(RoleEquipLocalSave) != null)
- {
- LocalSavePlaceArray = LocalSave.GetIntArray(RoleEquipLocalSave).ToList();
- }
- else
- {
- LocalSavePlaceArray = null;
- }
- GlobalTimeEvent.Instance.secondEvent += UpdateSecond;
- PlayerDatas.Instance.playerDataRefreshEvent += UpdatePlayerLv;
- isUpdatePlayerLv = true;
- FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
- }
-
- private void RefreshSysInfo(string key, ArrayList infolist)
- {
- // if (key != "GetMoney") return;
- // if (ItemLogicUtility.Instance.hidePickItem)
- // return;
-
- // if (PlayerDatas.Instance.baseData.LV < 3)
- // return;
-
- // var type = 0;
- // int.TryParse(infolist[0].ToString(), out type);
- // if (type == 1)
- // {
- // Vector3 pos = new Vector3(-100, 0, 0);
- // Vector3 rot = new Vector3(0, 0, 0);
- // if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
- // {
- // pos = new Vector3(0, 50, 0);
- // rot = new Vector3(180, 180, 0);
- // }
- // EffectMgr.Instance.PlayUIEffect(1204, 3000, WindowCenter.Instance.uiRoot.tipsCanvas, pos, rot, false);
- // }
- // else if (type == 2)
- // {
- // Vector3 pos = new Vector3(-100, 0, 0);
- // Vector3 rot = new Vector3(0, 0, 0);
- // if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
- // {
- // pos = new Vector3(150, 50, 0);
- // rot = new Vector3(180, 180, 0);
- // }
- // lingshiEffect = EffectMgr.Instance.PlayUIEffect(1158, 3000, WindowCenter.Instance.uiRoot.tipsCanvas, pos, rot, false);
- // }
- }
-
- public event Action<PackType> refrechPackEvent; //鍒锋柊鏁翠釜鑳屽寘鏁版嵁
- public event Action<PackType, int, int> refreshItemCountEvent; // 鎱庣敤浼氬崱锛堝崟涓級鏈�鏂扮墿鍝佹暟閲忓埛鏂�(鏃х殑寮冪敤)鍦ㄥ緱鍒版柊鐗╁搧銆佺墿鍝佹暟閲忕殑鏀瑰彉锛屾竻鐞嗚鐗╁搧鏃跺潎浼氳Е鍙� int 浣嶇疆绱㈠紩 int鐗╁搧id
- public event Action<PackType> gridRefreshEvent; //鑳屽寘绌烘牸鍒锋柊
- public event Action<PackType, int, int> itemCntAddEvent; //鐗╁搧鏁伴噺澧炲姞 int 浣嶇疆绱㈠紩 int鐗╁搧id
- public event Action<PackType, int, int> itemCntReduceEvent; //鐗╁搧鏁伴噺鍑忓皯鐨勬敼鍙� int 浣嶇疆绱㈠紩 int鐗╁搧id
- public event Action<int, int> useItemSuccessEvent; //鐗╁搧浣跨敤鎴愬姛 int 浣嶇疆绱㈠紩 int鐗╁搧id
-
- public event Action<int> refreshItemDayUseCountEvent; //鍒锋柊鐗╁搧姣忔棩浣跨敤鏁伴噺
- public event Action<int> refreshItemSumUseCountEvent; //鍒锋柊鐗╁搧鎬讳娇鐢ㄦ暟閲�
-
- public bool isPlayBetterEquipEffect { get; set; } //鏁寸悊鑳屽寘鏃舵槸鍚︽挱鏀剧壒鏁�
-
- #region 鎺ユ敹鏈嶅姟绔暟鎹�
- private Dictionary<PackType, SinglePack> playerPackDict = new Dictionary<PackType, SinglePack>();
- private Dictionary<string, ItemModel> itemGUIDDict = new Dictionary<string, ItemModel>();
-
- public void UpdatePack(H0725_tagRolePackRefreshEx packInfo)
- {
- SetLookIndex(null);
- var packType = (PackType)packInfo.PackType;
- if (!playerPackDict.ContainsKey(packType))
- {
- playerPackDict.Add(packType, new SinglePack(packType));
- }
-
- if (isPlayBetterEquipEffect)
- {
- ItemLogicUtility.Instance.ClearSortedBetterEquip();
- }
-
- for (int i = 0; i < packInfo.ItemCount; i++)
- {
- var itemInfo = new ItemInfo(packInfo.ItemInfo[i]);
- var item = playerPackDict[packType].UpdateItem(itemInfo);
- AddItemGUIDDict(item, false);
-
- if (isPlayBetterEquipEffect)
- {
- ItemLogicUtility.Instance.SetBagSortBetterEquipList(GetItemByGuid(itemInfo.guid));
- }
- }
-
- if (refrechPackEvent != null)
- {
- refrechPackEvent(packType);
- }
-
- UpdatePackRedpoint(packType);
- }
-
- public void UpdateItem(H0704_tagRolePackRefresh serverItem)
- {
- isPlayBetterEquipEffect = false;
- SetLookIndex(null);
- PackType type = (PackType)serverItem.PackType;
- if (!playerPackDict.ContainsKey(type))
- {
- playerPackDict.Add(type, new SinglePack(type));
- }
-
- var showNewItem = false;
- if (itemGUIDDict.ContainsKey(serverItem.ItemGUID))
- {
- var prePack = itemGUIDDict[serverItem.ItemGUID].packType;
- var preAuction = itemGUIDDict[serverItem.ItemGUID].isAuction;
- var nowPackType = type;
- var nowAcution = serverItem.IsBind == 1;
- showNewItem = preAuction != nowAcution || prePack != nowPackType;
- }
- else
- {
- showNewItem = true;
- }
-
- var itemInfo = new ItemInfo(serverItem);
- var item = playerPackDict[type].UpdateItem(itemInfo);
- AddItemGUIDDict(item, showNewItem);
-
- if (refreshItemCountEvent != null)
- {
- refreshItemCountEvent(type, itemInfo.index, itemInfo.itemId);
- }
-
- if (itemCntAddEvent != null)
- {
- itemCntAddEvent(type, itemInfo.index, itemInfo.itemId);
- }
-
- // if (type == PackType.Equip)
- // {
- // if (ItemLogicUtility.Instance.IsRealmEquip(itemInfo.itemId))
- // {
- // ItemOperateUtility.Instance.ShowPutOnNewEquipRemind(itemInfo.itemId);
- // }
- // }
-
- UpdatePackRedpoint(type);
- //EquipDecomRedCtrl();
- m_CheckEquipDecomRedCtrl = true;
- AutoUseItem(itemInfo.itemId, serverItem.ItemGUID);
- }
-
-
- bool m_CheckEquipDecomRedCtrl = false;
- void CheckEquipDecomRedCtrl()
- {
- if (m_CheckEquipDecomRedCtrl)
- {
- EquipDecomRedCtrl();
- m_CheckEquipDecomRedCtrl = false;
- }
- }
-
-
- public void UpdateUnlockedGridCount(H0724_tagRolePackCanUseCount useCount)
- {
- PackType type = (PackType)useCount.PackType;
- if (!playerPackDict.ContainsKey(type))
- {
- playerPackDict.Add(type, new SinglePack(type));
- }
-
- playerPackDict[type].SetOpenGridCount(useCount.CanUseCount);
-
- if (gridRefreshEvent != null)
- {
- gridRefreshEvent(type);
- }
-
- UpdatePackRedpoint(type);
- }
-
- public void RefreshItemCount(H0707_tagItemCountRefresh refresh)
- {
- SetLookIndex(null);
- isPlayBetterEquipEffect = false;
- PackType type = (PackType)refresh.PackType;
- SinglePack singlePack = null;
- playerPackDict.TryGetValue(type, out singlePack);
-
- if (singlePack != null)
- {
- ItemModel itemModel = singlePack.GetItemByIndex(refresh.ItemIndex);
- if (itemModel != null)
- {
- bool isAddItemCount = false;
- if (refresh.ItemCount > itemModel.count)
- {
- isAddItemCount = true;
- }
- itemModel.RefreshCount(refresh.ItemCount);
-
- if (isAddItemCount)
- {
- if (itemCntAddEvent != null)
- {
- itemCntAddEvent(type, itemModel.gridIndex, itemModel.itemId);
- }
- ItemLogicUtility.Instance.RecommendItem(itemModel);
- ItemLogicUtility.Instance.RefreshPickItem(type, itemModel.itemId.ToString());
- }
- else
- {
- if (itemCntReduceEvent != null)
- {
- itemCntReduceEvent(type, itemModel.gridIndex, itemModel.itemId);
- }
- }
-
- if (refreshItemCountEvent != null)
- {
- refreshItemCountEvent(type, itemModel.gridIndex, itemModel.itemId);
- }
-
- UpdateLSRedpoint(type, itemModel.itemId);
- }
- }
-
- }
-
- public void ClearPack(H0711_tagClearItemPack clearPack)
- {
- PackType type = (PackType)clearPack.PackIndex;
- SinglePack singlePack = null;
- playerPackDict.TryGetValue(type, out singlePack);
- if (singlePack != null)
- {
- singlePack.Clear();
- }
- }
-
- public void RemoveItem(H0709_tagClearItem clearItem)
- {
- isPlayBetterEquipEffect = false;
- SetLookIndex(null);
- PackType type = (PackType)clearItem.PackType;
-
- SinglePack singlePack = null;
- playerPackDict.TryGetValue(type, out singlePack);
- string guid = "";
- if (singlePack != null)
- {
- ItemModel itemModel = singlePack.GetItemByIndex(clearItem.ItemIndex);
- guid = itemModel.guid;
- int itemId = itemModel.itemId;
-
- DeleteItemDictByGUID(type, itemModel.guid);
-
- singlePack.RemoveItem(clearItem.ItemIndex);
- if (refreshItemCountEvent != null)
- {
- refreshItemCountEvent(type, clearItem.ItemIndex, itemId);
- }
-
- if (itemCntReduceEvent != null)
- {
- itemCntReduceEvent(type, clearItem.ItemIndex, itemId);
- }
- }
-
- UpdatePackRedpoint(type);
- m_CheckEquipDecomRedCtrl = true;
- //EquipDecomRedCtrl();
-
- if (GetItemByGuid(guid) == null)
- {
- KnapsackTimeCDMgr.Instance.UnRegister(guid);
- }
-
- }
-
- public void PackResetOk(H0316_tagPackResetOK packreset)
- {
- ItemLogicUtility.Instance.isPackResetOk = true;
- }
-
- public void UseItemSuccess(H0706_tagUseItemSuccess success)
- {
- isPlayBetterEquipEffect = false;
- SetLookIndex(null);
- if (success.PlayerID != PlayerDatas.Instance.baseData.PlayerID)
- {
- return;
- }
-
- MakeUseItemSuccess(success.ItemIndex, (int)success.ItemID);
- switch (success.ItemID)
- {
- // case 221:
- // if (WindowCenter.Instance.IsOpen<KnapSackWin>())
- // {
- // WindowCenter.Instance.Close<KnapSackWin>();
- // }
- // break;
- }
-
- if (useItemSuccessEvent != null)
- {
- useItemSuccessEvent(success.ItemIndex, (int)success.ItemID);
- }
- }
-
- void AutoUseItem(int itemID, string guid)
- {
- // if (autoUseItemIDs.Contains(itemID))
- // {
- // ItemOperateUtility.Instance.GotoUseItem(guid);
- // }
- }
-
- private void MakeUseItemSuccess(int index, int id)
- {
- ItemConfig itemConfig = ItemConfig.Get(id);
- if (itemConfig.CDType != 0)
- {
- var items = GetItems(PackType.Item, new SinglePack.FilterParams()
- {
- itemTypes = new List<int>() { (int)ItemType.Buff }
- });
-
- for (int i = 0; i < items.Count; i++)
- {
- if (ItemLogicUtility.Instance.drugIDs.Contains(items[i].itemId))
- {
- itemConfig = ItemConfig.Get(items[i].itemId);
- float configCdTime = (float)Math.Round((double)itemConfig.CDTime / 1000, 1);
- KnapsackTimeCDMgr.Instance.Register(items[i].guid, items[i].itemId, configCdTime);
- }
- }
-
- }
- }
-
- void AddItemGUIDDict(ItemModel itemModel, bool showNewItem)
- {
- itemGUIDDict[itemModel.guid] = itemModel;
- GetItemEventCtrl(itemModel, showNewItem);
- }
-
- void DeleteItemDictByGUID(PackType type, string guid)
- {
- if (itemGUIDDict.ContainsKey(guid))
- {
- if (itemGUIDDict[guid].packType == type)
- {
- itemGUIDDict.Remove(guid);
- }
- }
- }
-
- /// <summary>
- /// 鐗╁搧姣忔棩浣跨敤鐨勬鏁�
- /// </summary>
- private Dictionary<int, int> itemDayUseCntDict = new Dictionary<int, int>();
- public void UpdateItemUseCnt(HA809_tagMCItemDayUseCntInfo useCntInfo)
- {
- for (int i = 0; i < useCntInfo.Count; i++)
- {
- int itemId = (int)useCntInfo.ItemUseCntList[i].ItemID;
- int cnt = useCntInfo.ItemUseCntList[i].UseCnt;
- if (!itemDayUseCntDict.ContainsKey(itemId))
- {
- itemDayUseCntDict.Add(itemId, cnt);
- }
- else
- {
- itemDayUseCntDict[itemId] = cnt;
- }
-
- if (refreshItemDayUseCountEvent != null)
- {
- refreshItemDayUseCountEvent(itemId);
- }
-
- }
- }
-
- private Dictionary<int, int> itemSumUseCntDict = new Dictionary<int, int>();
- // public void UpdateItemSumUseCnt(HA339_tagMCAttrFruitEatCntList useCntInfo)
- // {
- // for (int i = 0; i < useCntInfo.count; i++)
- // {
- // int itemId = (int)useCntInfo.EatCntList[i].ItemID;
- // int cnt = (int)useCntInfo.EatCntList[i].EatCnt;
- // if (!itemSumUseCntDict.ContainsKey(itemId))
- // {
- // itemSumUseCntDict.Add(itemId, cnt);
- // }
- // else
- // {
- // itemSumUseCntDict[itemId] = cnt;
- // }
-
- // if (refreshItemSumUseCountEvent != null)
- // {
- // refreshItemSumUseCountEvent(itemId);
- // }
- // }
- // }
-
- #endregion
-
- #region 鐜╁瑁呭鐗规畩閫昏緫
- public Dictionary<int, Dictionary<int, int>> spiritWeaponPathIds { get; private set; }
- public Dictionary<int, int> wingsGetPathIdDict { get; private set; }
- public Dictionary<int, List<int>> dungeonUseDict { get; private set; }
- void ParseConfig()
- {
- FuncConfigConfig funcConfig = FuncConfigConfig.Get("WingYuPeiHQTJ");
- spiritWeaponPathIds = new Dictionary<int, Dictionary<int, int>>();
- var splits = funcConfig.Numerical3.Split('|');
- for (int i = 0; i < splits.Length; i++)
- {
- var tempString = splits[i];
- var matches = Regex.Matches(tempString.Trim(), "\\d+");
- var equipPlace = int.Parse(matches[0].Value);
- var job = int.Parse(matches[1].Value);
- var itemId = int.Parse(matches[2].Value);
-
- if (!spiritWeaponPathIds.ContainsKey(equipPlace))
- {
- spiritWeaponPathIds[equipPlace] = new Dictionary<int, int>();
- }
-
- spiritWeaponPathIds[equipPlace][job] = itemId;
- }
-
- FuncConfigConfig copyItemBulletWindow = FuncConfigConfig.Get("CopyItemBulletWindow");
- JsonData copyWinData = JsonMapper.ToObject(copyItemBulletWindow.Numerical1);
- dungeonUseDict = new Dictionary<int, List<int>>();
- foreach (var dungeonId in copyWinData.Keys)
- {
- List<int> idlist = new List<int>();
- dungeonUseDict.Add(int.Parse(dungeonId), idlist);
- if (copyWinData[dungeonId].IsArray)
- {
- JsonData useData = copyWinData[dungeonId];
- for (int i = 0; i < useData.Count; i++)
- {
- idlist.Add(int.Parse(useData[i].ToString()));
- }
- }
- }
-
- lsItemCnt = int.Parse(FuncConfigConfig.Get("LingshiShowCount").Numerical1);
- var config = FuncConfigConfig.Get("CommonShowAwards");
- commonShowAwardEvents = JsonMapper.ToObject<List<string>>(config.Numerical1);
-
- }
-
- public int GetRoleEquipPathId(int equipPlace)
- {
- int playerJob = PlayerDatas.Instance.baseData.Job;
- switch ((RoleEquipType)equipPlace)
- {
- case RoleEquipType.Guard:
- case RoleEquipType.PeerlessWeapon1:
- case RoleEquipType.PeerlessWeapon2:
- case RoleEquipType.Wing:
- return spiritWeaponPathIds[equipPlace][playerJob];
- default:
- return 0;
- }
- }
-
- private void UpdateSecond()
- {
- if (isUpdatePlayerLv)
- {
- isUpdatePlayerLv = false;
- }
- CheckEquipDecomRedCtrl();
- }
-
- private void UpdatePlayerLv(PlayerDataType type)
- {
- if (type != PlayerDataType.LV) return;
-
- isUpdatePlayerLv = true;
- }
-
- #endregion
-
-
- private void GetItemEventCtrl(ItemModel itemModel, bool showNewItem)
- {
- // if (showNewItem)
- // {
- // bool isOverdue = false;
- // if (itemModel.config.ExpireTime > 0)
- // {
- // ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(itemModel.guid);
- // switch ((ItemTimeType)itemModel.config.EndureReduceType)
- // {
- // case ItemTimeType.EquipedTime:
- // List<int> itemEffectTime = itemModel.GetUseData((int)ItemUseDataKey.createTime);
- // if (itemEffectTime != null && itemEffectTime[0] != 0)
- // {
- // if (cool == null || cool.GetRemainTime() <= 0)
- // {
- // isOverdue = true;
- // }
- // }
- // break;
-
- // case ItemTimeType.RealityTime:
- // if (cool == null || cool.GetRemainTime() <= 0)
- // {
- // isOverdue = true;
- // }
- // break;
-
- // }
- // }
-
- // if (!isOverdue)
- // {
- // ItemLogicUtility.Instance.RecommendItem(itemModel);
- // ItemLogicUtility.Instance.OnGetEquip(itemModel);
- // ItemLogicUtility.Instance.RefreshPickItem(itemModel.packType, itemModel.itemId.ToString());
- // }
- // }
-
- }
-
- /// <summary>
- /// 寰楀埌鏌愪釜鍖呰9鐨勬墍鏈夋暟鎹�
- /// </summary>
- /// <param name="type"></param>
- /// <returns></returns>
- public SinglePack GetSinglePack(PackType type)
- {
- SinglePack singlePack = null;
- playerPackDict.TryGetValue(type, out singlePack);
- return singlePack;
- }
-
- public void UnLockPackGrid(int chooseGridCount, PackType type)
- {
- // var singlePack = GetSinglePack(type);
- // int openCount = chooseGridCount - singlePack.unlockedGridCount;
- // int index = 0;
- // switch (type)
- // {
- // case PackType.Item:
- // index = chooseGridCount - GeneralDefine.initBagGridCount;
- // break;
- // case PackType.Warehouse:
- // index = chooseGridCount - GeneralDefine.initDepotGridCount;
- // break;
- // }
-
- // itemTipsModel.SetExtendGirdModel(openCount, index, type);
- // WindowCenter.Instance.Open<ExtendWin>();
- }
-
- public ItemModel GetItemByGuid(string guid)
- {
- if (string.IsNullOrEmpty(guid))
- {
- return null;
- }
-
- ItemModel itemModel = null;
- itemGUIDDict.TryGetValue(guid, out itemModel);
- return itemModel;
- }
-
- public ItemModel GetItemByIndex(PackType type, int index)
- {
- ItemModel itemModel = null;
- if (playerPackDict.ContainsKey(type))
- {
- itemModel = playerPackDict[type].GetItemByIndex(index);
- }
- return itemModel;
- }
-
- /// <summary>
- /// 鑾峰彇鎸囧畾鑳屽寘鍐� 鎸囧畾ID鐨勬墍鏈夌墿鍝�
- /// </summary>
- /// <param name="type"></param>
- /// <param name="id"></param>
- /// <param name="includeAuction"></param>
- /// <returns></returns>
- public List<ItemModel> GetItemsById(PackType type, int id, bool includeAuction = true)
- {
- if (playerPackDict.ContainsKey(type))
- {
- var singlePack = playerPackDict[type];
- return singlePack.GetItemsById(id, includeAuction);
- }
- else
- {
- return null;
- }
- }
-
- /// <summary>
- /// 鑾峰彇鎸囧畾鑳屽寘鍐呮寚瀹欼D鐨勪竴涓墿鍝�
- /// </summary>
- /// <param name="type"></param>
- /// <param name="id"></param>
- /// <param name="includeAuction"></param>
- /// <returns></returns>
- public ItemModel GetItemByID(PackType type, int id, bool includeAuction = true)
- {
- if (playerPackDict.ContainsKey(type))
- {
- var singlePack = playerPackDict[type];
- return singlePack.GetItemByID(id, includeAuction);
- }
- else
- {
- return null;
- }
- }
-
- public List<ItemModel> GetItems(PackType packType, SinglePack.FilterParams param)
- {
- if (playerPackDict.ContainsKey(packType))
- {
- return playerPackDict[packType].GetItems(param);
- }
- else
- {
- return null;
- }
- }
-
- //閫氳繃id鎵剧墿鍝侊紝娉ㄦ剰妫�鏌ユ槸鍚︽寚瀹氳儗鍖�
- public string GetItemGUIDByID(int itemId, bool includeAuction = true, PackType packType = PackType.Item)
- {
- string guid = string.Empty;
- foreach (var key in itemGUIDDict.Keys)
- {
- if (!includeAuction && itemGUIDDict[key].isAuction)
- {
- continue;
- }
-
- if (itemGUIDDict[key].itemId == itemId && packType == itemGUIDDict[key].packType)
- {
- guid = key;
- return guid;
- }
- }
-
- return guid;
- }
-
- /// <summary>
- /// 寰楀埌ID鐩稿悓鐨勭墿鍝佹暟閲�
- /// </summary>
- /// <param name="type"></param>
- /// <param name="id"></param>
- /// <returns></returns>
- public int GetItemCountByID(PackType type, int id, bool includeAuction = true)
- {
- int count = 0;
- var singlePack = GetSinglePack(type);
- if (singlePack != null)
- {
- count = singlePack.GetCountById(id, includeAuction);
- }
-
- return count;
- }
-
- public int GetEmptyGridCount(PackType type)
- {
- int count = 0;
- SinglePack singlePack = GetSinglePack(type);
- if (singlePack != null)
- {
- count = singlePack.GetEmptyGridCount();
- }
-
- return count;
- }
-
- public bool TryGetShareNumItem(int itemId, out List<int> idlist)
- {
- idlist = new List<int>();
- foreach (var list in sharedUseCountItemDict.Values)
- {
- if (list.Contains(itemId))
- {
- idlist = list;
- return true;
- }
- }
- return false;
- }
-
- /// <summary>
- /// 寰楀埌鐗╁搧浠婃棩浣跨敤娆℃暟
- /// </summary>
- /// <param name="itemId"></param>
- /// <returns></returns>
- public int GetItemUsedTimesToday(int itemId)
- {
- int useCnt = 0;
- List<int> shareIdlist = null;
- bool isShare = TryGetShareNumItem(itemId, out shareIdlist);
- if (isShare)
- {
- foreach (var id in shareIdlist)
- {
- int singleUseCnt = 0;
- itemDayUseCntDict.TryGetValue(id, out singleUseCnt);
- useCnt += singleUseCnt;
- }
- }
- else
- {
- itemDayUseCntDict.TryGetValue(itemId, out useCnt);
- }
- return useCnt;
- }
-
- /// <summary>
- /// 寰楀埌鐗╁搧鎬讳娇鐢ㄦ鏁�
- /// </summary>
- /// <param name="itemId"></param>
- /// <returns></returns>
- public int GetItemTotalUsedTimes(int itemId)
- {
- int useCnt = 0;
- List<int> shareIdlist = null;
- bool isShare = TryGetShareNumItem(itemId, out shareIdlist);
- if (isShare)
- {
- foreach (var id in shareIdlist)
- {
- int singleUseCnt = 0;
- itemDayUseCntDict.TryGetValue(id, out singleUseCnt);
- useCnt += singleUseCnt;
- }
- }
- else
- {
- itemSumUseCntDict.TryGetValue(itemId, out useCnt);
- }
- return useCnt;
- }
-
- public void GotoWashAttributePoint(string guid)
- {
- // ItemModel itemModel = GetItemByGuid(guid);
- // if (itemModel == null) return;
-
- // WashAttrPointWin.itemModel = itemModel;
- // WindowCenter.Instance.Open<WashAttrPointWin>();
- }
-
- #region 绾㈢偣閫昏緫鍒ゆ柇
-
- const int ITEMPACK_REDKEY = 102011003;
- Redpoint redpointItemPack = new Redpoint(MainRedDot.RedPoint_BagFuncKey, ITEMPACK_REDKEY);
-
- const int LS_REDKEY = 102011015;
- Redpoint redpointLS = new Redpoint(MainRedDot.RedPoint_BagFuncKey, LS_REDKEY);
-
- private void UpdateLSRedpoint(PackType type, int itemID)
- {
- var singlePack = GetSinglePack(type);
- if (singlePack == null)
- {
- return;
- }
- if (type != PackType.Item) return;
- if (itemID != lsItemID) return;
-
-
- if (GetItemCountByID(PackType.Item, lsItemID) < lsItemCnt)
- {
- redpointLS.state = RedPointState.None;
- }
- else
- {
- redpointLS.state = RedPointState.Simple;
- }
-
- }
-
- private void UpdatePackRedpoint(PackType type)
- {
- var singlePack = GetSinglePack(type);
- if (singlePack == null)
- {
- return;
- }
-
- switch (type)
- {
- case PackType.Item:
- if (singlePack.GetEmptyGridCount() <= 0)
- {
- redpointItemPack.state = RedPointState.Full;
- //SysNotifyMgr.Instance.ShowTip("BagFull");
- }
- else
- {
- redpointItemPack.state = RedPointState.None;
- }
- if (GetItemCountByID(PackType.Item, lsItemID) < lsItemCnt)
- {
- redpointLS.state = RedPointState.None;
- }
- else
- {
- redpointLS.state = RedPointState.Simple;
- }
- break;
- case PackType.Warehouse:
- if (singlePack.GetEmptyGridCount() <= 0)
- {
- MainRedDot.Instance.redPointDepotFunc.state = RedPointState.Full;
- }
- else
- {
- MainRedDot.Instance.redPointDepotFunc.state = RedPointState.None;
- }
- break;
- }
- }
-
- const int PLAYERSUMSTAR_REDKEY = 102011002;
- Redpoint redpointSTAR = new Redpoint(MainRedDot.RedPoint_BagFuncKey, PLAYERSUMSTAR_REDKEY);
-
- public const int EquipDecompose_RedKey = 10205;
- public Redpoint redpointEquipDecom = new Redpoint(MainRedDot.RedPoint_MainPackKey, EquipDecompose_RedKey);
- public void EquipDecomRedCtrl()
- {
- if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.EquipDecompose))
- {
- return;
- }
-
- if (PlayerDatas.Instance.baseData.LV < devourRedpointLevel)
- {
- redpointEquipDecom.state = RedPointState.None;
- return;
- }
-
- var canDevourItems = GetCanDevourModellist();
- if (canDevourItems != null && canDevourItems.Count >= minDevourEquipNum)
- {
- redpointEquipDecom.state = RedPointState.Simple;
- }
- else
- {
- redpointEquipDecom.state = RedPointState.None;
- }
- }
- #endregion
-
- #region 鏌ョ湅鏌愪釜浣嶇疆鐨勭墿鍝�
- public event Action lookEquipEvent;
- private int _lookLineIndex = -1;
- public int lookLineIndex { get { return _lookLineIndex; } private set { _lookLineIndex = value; } }
-
- public string lookItemGUID { get; private set; }
-
- public void SetLookIndex(string guid, int singleRowCount = 5)
- {
- if (string.IsNullOrEmpty(guid) || guid == "")
- {
- lookLineIndex = -1;
- lookItemGUID = "";
- }
- else
- {
- int index = GetItemByGuid(guid).gridIndex;
- lookLineIndex = index / singleRowCount;
- lookItemGUID = guid;
- }
-
- if (lookEquipEvent != null)
- {
- lookEquipEvent();
- }
- }
-
- public event Action RefreshBagEvent;
- public void RefreshBagInfo()
- {
- if (RefreshBagEvent != null)
- {
- RefreshBagEvent();
- }
- }
- #endregion
-
- public void SetJumpToOneKeySell(Transform parent)
- {
- // var goEffect = AchievementGuideEffectPool.Require(1);
- // goEffect.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one);
- // AchievementGoto.guideAchievementId = 0;
- }
-
- #region 鐗╁搧浣跨敤蹇嵎鎻愮ず
-
- private int cacheMapId = 0;
- public event Action<PackType, string> itemUseAct;
- private Dictionary<int, int> itemUseTypeDict = new Dictionary<int, int>(); //key SkillTypeID,value 浣跨敤鐗╁搧鐨処D
- private void OnStageLoadFinish()
- {
- // itemUseTypeDict.Clear();
- // if (PlayerDatas.Instance.baseData.MapID == cacheMapId)
- // {
- // return;
- // }
-
- // cacheMapId = PlayerDatas.Instance.baseData.MapID;
- // UpdateDungeonDanUse();
- // UpdateDungeonUse();
- // SinglePack singlePack = GetSinglePack(PackType.Item);
- // foreach (int itemId in itemUseTypeDict.Values)
- // {
- // var modellist = singlePack.GetItemsById(itemId);
- // if (modellist.Count > 0)
- // {
- // ItemModel itemModel = modellist[0];
- // bool isExist = StatusMgr.Instance.IsExist(PlayerDatas.Instance.hero.ServerInstID, itemModel.config.AddSkill1);
- // Debug.Log("Buff鏄惁瀛樺湪" + isExist);
- // if (itemUseAct != null && !isExist)
- // {
- // itemUseAct(PackType.Item, itemModel.guid);
- // }
- // }
- // }
- }
-
- private void AddItemUseTypeDict(int id)
- {
- SkillConfig skillConfig = GetSkillConfig(id);
- int itemCount = GetItemCountByID(PackType.Item, id);
- if (skillConfig != null && itemCount > 0)
- {
- if (!itemUseTypeDict.ContainsKey(skillConfig.SkillTypeID))
- {
- itemUseTypeDict.Add(skillConfig.SkillTypeID, id);
- }
- else
- {
- SkillConfig preSkillConfig = GetSkillConfig(itemUseTypeDict[skillConfig.SkillTypeID]);
- if (skillConfig.SkillLV > preSkillConfig.SkillLV)
- {
- itemUseTypeDict[skillConfig.SkillTypeID] = id;
- }
- }
- }
- }
-
- private void UpdateDungeonDanUse()
- {
- int mapId = PlayerDatas.Instance.baseData.MapID;
- int[] useDrugs = GetDrugIDListByDungeonID(mapId);
- if (useDrugs == null) return;
-
- for (int i = 0; i < useDrugs.Length; i++)
- {
- int id = useDrugs[i];
- AddItemUseTypeDict(id);
- }
- }
-
- private void UpdateDungeonUse()
- {
- int mapId = PlayerDatas.Instance.baseData.MapID;
- if (!dungeonUseDict.ContainsKey(mapId)) return;
-
- List<int> useIdlist = dungeonUseDict[mapId];
- for (int i = 0; i < useIdlist.Count; i++)
- {
- int id = useIdlist[i];
- AddItemUseTypeDict(id);
- }
- }
-
- public SkillConfig GetSkillConfig(int itemId)
- {
- ItemConfig itemConfig = ItemConfig.Get(itemId);
- SkillConfig skillConfig = SkillConfig.Get(itemConfig.AddSkill1);
- return skillConfig;
- }
-
- public int GetDungeonIDByDrugID(int drugID)
- {
- int dungeonID = 0;
- //DrugToDungeonDict.TryGetValue(drugID, out dungeonID);
- return dungeonID;
- }
-
- public int[] GetDrugIDListByDungeonID(int dungeonID)
- {
- int[] drugIDlist = null;
- DungeonToDrugDict.TryGetValue(dungeonID, out drugIDlist);
- return drugIDlist;
- }
- #endregion
-
- #region 鍒ゆ柇鐗╁搧鏄惁杈惧埌浣跨敤涓婇檺
- // public bool IsReachUseLimit(string guid, out ulong count)
- // {
- // count = 0;
- // ItemModel itemModel = GetItemByGuid(guid);
- // if (itemModel == null) return false;
-
- // AttrFruitConfig fruitConfig = AttrFruitConfig.Get(itemModel.itemId);
- // int haveUseCnt = GetItemUsedTimesToday(itemModel.itemId);
- // int sumHaveUseCnt = GetItemTotalUsedTimes(itemModel.itemId);
- // count = (ulong)itemModel.count;
- // bool isReach = false;
- // int remainDayCnt = 0;
- // if (itemModel.config.MaxSkillCnt > 0)
- // {
- // remainDayCnt = itemModel.config.MaxSkillCnt - haveUseCnt;
- // if (itemModel.count > remainDayCnt)
- // {
- // count = (ulong)remainDayCnt;
- // }
- // }
-
- // int remainSumCnt = 0;
- // if (fruitConfig != null)
- // {
- // remainSumCnt = fruitConfig.basicUseLimit - sumHaveUseCnt;
- // if (remainSumCnt <= remainDayCnt && itemModel.count > remainSumCnt)
- // {
- // count = (ulong)remainSumCnt;
- // }
- // }
-
- // if (count < (ulong)itemModel.count)
- // {
- // isReach = true;
- // }
-
- // return isReach;
- // }
- #endregion
-
- #region 鐗╁搧鍚炲櫖閫昏緫澶勭悊
- public EquipColorType colorType { get; private set; }
- public event Action<EquipColorType> RefreshColorSelectAct;
- public event Action RefreshEquipDecomNumAct;
- public int[] defaultUnSelectlist { get; private set; }
-
- public int GetBetterEquipCount(List<ItemModel> itemModels)
- {
- if (itemModels.IsNullOrEmpty())
- {
- return 0;
- }
-
- var count = 0;
- foreach (var item in itemModels)
- {
- if (ItemLogicUtility.Instance.IsFightUp(item.itemId, item.score) == 1)
- {
- count += item.count;
- }
- }
- return count;
- }
-
- public void SetColorSelect(EquipColorType type)
- {
- colorType = type;
-
- if (RefreshColorSelectAct != null)
- {
- RefreshColorSelectAct(type);
- }
- SendEquipDevourRecordQuest();
- EquipDecomRedCtrl();
- }
-
- public List<int> devourPlacelist { get; private set; }
- public int devourRedpointLevel { get; private set; }
- public int minDevourEquipNum { get; private set; }
- public void SetDevourEquipPlace()
- {
- devourPlacelist = new List<int>();
- FuncConfigConfig funcConfig = FuncConfigConfig.Get("PetAbsorbType");
- int[] placeArray = ConfigParse.GetMultipleStr<int>(funcConfig.Numerical1);
- for (int i = 0; i < placeArray.Length; i++)
- {
- devourPlacelist.Add(placeArray[i]);
- }
- devourRedpointLevel = int.Parse(funcConfig.Numerical2);
- minDevourEquipNum = int.Parse(funcConfig.Numerical3);
- }
-
- List<ItemModel> devourModellist = new List<ItemModel>();
- List<ItemModel> orderDevourModellist = new List<ItemModel>();
- public List<ItemModel> GetDevourModellist()
- {
- SinglePack singlePack = GetSinglePack(PackType.Item);
- if (singlePack == null) return null;
-
- devourModellist.Clear();
- orderDevourModellist.Clear();
- foreach (var model in singlePack.GetAllItems().Values)
- {
- if (model.config.Type == 29)
- {
- devourModellist.Add(model);
- }
- else
- {
- if (devourPlacelist.Contains(model.config.EquipPlace))
- {
- if (GeneralDefine.equipDecomposeScreen.Contains(model.config.ItemColor))
- {
- devourModellist.Add(model);
- }
- }
- }
-
- }
- orderDevourModellist.AddRange(devourModellist);
- orderDevourModellist.Sort(CompareByColor);
- return orderDevourModellist;
- }
-
- public int CompareByColor(ItemModel start, ItemModel next)
- {
- bool typeX = start.config.Type == 29 ? true : false;
- bool typeY = next.config.Type == 29 ? true : false;
-
- if (typeX.CompareTo(typeY) != 0) return -typeX.CompareTo(typeY);
-
- int colorX = start.config.ItemColor;
- int colorY = next.config.ItemColor;
- if (colorX.CompareTo(colorY) != 0) return colorX.CompareTo(colorY);
-
- int startIndex = devourModellist.IndexOf(start);
- int nextIndex = devourModellist.IndexOf(next);
- if (startIndex.CompareTo(nextIndex) != 0) return startIndex.CompareTo(nextIndex);
-
- return 0;
- }
-
- public List<ItemModel> GetCanDevourModellist()
- {
- List<ItemModel> canDevourModellist = new List<ItemModel>();
- SinglePack singlePack = GetSinglePack(PackType.Item);
- if (singlePack == null || colorType == EquipColorType.None)
- {
- if (RefreshEquipDecomNumAct != null)
- {
- RefreshEquipDecomNumAct();
- }
- return null;
- }
-
- foreach (var model in singlePack.GetAllItems().Values)
- {
- if (model.config.Type == 29)
- {
- if (!defaultUnSelectlist.Contains(model.itemId))
- {
- canDevourModellist.Add(model);
- }
- }
- else
- {
- if (IsCanDevour(model))
- {
- canDevourModellist.Add(model);
- }
- }
- }
-
- if (RefreshEquipDecomNumAct != null)
- {
- RefreshEquipDecomNumAct();
- }
-
- return canDevourModellist;
- }
-
- public bool IsCanDevour(ItemModel model)
- {
- // if (devourPlacelist.Contains(model.config.EquipPlace))
- // {
- // if (GeneralDefine.equipDecomposeScreen.Contains(model.config.ItemColor))
- // {
- // var eatEquipConfig = PetEatEquipConfig.GetEquipColorAndEquipClass(model.config.ItemColor, model.config.LV);
- // if (eatEquipConfig == null) return false;
-
- // if (EquipControlConfig.Get(model.config.LV, 1).realm > PlayerDatas.Instance.baseData.realmLevel)
- // {
- // //bug锛氱帺瀹舵寕鏈轰細鎵撻珮澧冪晫鎬紝瀵艰嚧瑁呭鏃犳硶鍒嗚В鑳屽寘澶弧鐨勬儏鍐�
- // //澧冪晫澶т簬鐜╁澧冪晫锛屼笖鍦ㄦ寚瀹氶鑹插搧璐ㄤ笅鐨勭洿鎺ュ垎瑙g传鑹蹭互涓嬭澶�
- // if (model.config.ItemColor <= (int)colorType && model.config.ItemColor <= 3)
- // {
- // return true;
- // }
- // }
-
- // //1. 闈炴媿鍗栬澶�
- // //2. 瑁呭鍝佽川灏忎簬绛変簬褰撳墠閫夋嫨鐨勫搧璐�
- // //3. 闈炴湰鑱屼笟鐨勫瑁呰澶�
- // //4. 闈炴垬鏂楀姏鎻愬崌鐨勮澶�
- // if (!model.isAuction && model.config.ItemColor <= (int)colorType
- // && !(ItemLogicUtility.Instance.IsJobCompatibleItem(model.itemId)
- // && model.config.ItemColor == 4 && model.config.SuiteiD != 0)
- // && ItemLogicUtility.Instance.IsFightUp(model.itemId, model.score) != 1)
- // {
- // return true;
- // }
- // }
- // }
-
- return false;
- }
-
- public bool IsMaxDecomLv(int decomLv, out int realLv)
- {
- realLv = decomLv;
- // var decomlist = EquipDeComposeConfig.GetValues();
- // if (decomLv > decomlist[decomlist.Count - 1].LV)
- // {
- // realLv = decomlist[decomlist.Count - 1].LV;
- // return true;
- // }
-
- return false;
- }
-
- public List<ItemModel> selectDevourlist = new List<ItemModel>();
- public void GetSelectDevourList()
- {
- selectDevourlist.Clear();
- List<ItemModel> itemModels = GetCanDevourModellist();
- if (itemModels != null)
- {
- selectDevourlist.AddRange(itemModels);
- }
- }
-
- public void RefreshGetNewItem(ItemModel model)
- {
- if (model == null) return;
-
- if (CheckIsReachDevourCondi(model))
- {
- selectDevourlist.Add(model);
- if (RefreshEquipDecomNumAct != null)
- {
- RefreshEquipDecomNumAct();
- }
- }
- }
-
- public void AddSelectDevourModellist(ItemModel model)
- {
- selectDevourlist.Add(model);
- if (RefreshEquipDecomNumAct != null)
- {
- RefreshEquipDecomNumAct();
- }
- }
-
- public bool CheckIsReachDevourCondi(ItemModel model)
- {
- if (model.config.Type == 29)
- {
- if (!defaultUnSelectlist.Contains(model.itemId))
- {
- return true;
- }
- return false;
- }
- else
- {
- if (IsCanDevour(model))
- {
- return true;
- }
-
- }
- return false;
- }
-
- public void RemoveSelectDevourModellist(ItemModel model)
- {
- if (selectDevourlist.Contains(model))
- {
- selectDevourlist.Remove(model);
- }
- if (RefreshEquipDecomNumAct != null)
- {
- RefreshEquipDecomNumAct();
- }
- }
-
- public Dictionary<int, int> GetDecomAttrDictByLv(int decomLv)
- {
- if (decomposeAttrDict.ContainsKey(decomLv))
- {
- return decomposeAttrDict[decomLv];
- }
-
- return null;
- }
-
- public bool IsReachMinDecomposeNum()
- {
- List<ItemModel> itemModels = GetCanDevourModellist();
- if (itemModels != null && itemModels.Count >= minDecomposeNum)
- {
- return true;
- }
- return false;
- }
-
- public void SendEquipdevourQuest(bool auto)
- {
- List<ItemModel> items = null;
- if (auto)
- {
- items = GetCanDevourModellist();
- }
- else
- {
- items = selectDevourlist;
- }
-
- // if (items == null || items.Count < minDecomposeNum || !ItemLogicUtility.Instance.isPackResetOk || SettingEffectMgr.Instance.isStartDecompose) return;
-
- // SettingEffectMgr.Instance.isStartDecompose = true;
- // isAutoDecompose = auto;
- // recordAutoDecomNum = Math.Min(items.Count, 100); //鍗曟鏈�澶�100浠跺垎瑙�
- // var package = new CA32C_tagCMEquipDecompose();
- // var indexLists = new ushort[recordAutoDecomNum];
- // var idlist = new uint[recordAutoDecomNum];
- // for (int i = 0; i < recordAutoDecomNum; i++)
- // {
- // indexLists[i] = (ushort)items[i].gridIndex;
- // idlist[i] = (uint)items[i].itemId;
- // if ((items[i].config.EquipPlace == 0 && items[i].config.Type != 29))
- // {
- // return;
- // }
- // }
- // package.Count = (byte)indexLists.Length;
- // package.IndexList = indexLists;
- // package.ItemIDList = idlist;
- // package.IsAuto = (byte)(auto ? 1 : 0);
- // GameNetSystem.Instance.SendInfo(package);
- }
-
- public void SendEquipDevourRecordQuest()
- {
- var record = StringUtility.Contact((int)colorType + 1, 1, 1);
- var decomSet = new CA32D_tagCMDecomposeSeting();
- decomSet.Seting = uint.Parse(record);
- GameNetSystem.Instance.SendInfo(decomSet);
- }
-
- public int decomposeLv { get; private set; }
- public int decomposeExp { get; private set; }
- public int decomposeProgress { get; private set; }
- public int addDecomposeExp { get; private set; }
- public int minDecomposeNum { get; private set; }
- public bool isAutoDecompose { get; set; }
- public int recordAutoDecomNum { get; private set; }
- public DecomposeGetMatInfo[] getItems { get; private set; }
-
- public event Action RefreshDecomAttrAct;
- // public void GetServerDecomposeSet(HA31C_tagMCEquipDecomposeInfo info)
- // {
- // addDecomposeExp = 0;
- // int realLv = info.LV + 1;
- // bool isMax = IsMaxDecomLv(realLv, out realLv);
- // if (realLv == decomposeLv)
- // {
- // addDecomposeExp = (int)info.Exp - decomposeExp;
- // }
- // else
- // {
- // for (int i = decomposeLv; i <= realLv; i++)
- // {
- // var deComposeConfig = EquipDeComposeConfig.Get(i);
- // if (i == decomposeLv)
- // {
- // addDecomposeExp = deComposeConfig.UpNeedExp - decomposeExp;
- // }
- // else if (i == realLv)
- // {
- // addDecomposeExp += (int)info.Exp;
- // }
- // else
- // {
- // addDecomposeExp += deComposeConfig.UpNeedExp;
- // }
- // }
- // }
-
- // decomposeLv = realLv;
- // decomposeExp = (int)info.Exp;
- // decomposeProgress = info.DecomposeCnt;
- // getItems = JsonMapper.ToObject<DecomposeGetMatInfo[]>(info.GetItemData);
-
- // if (info.Seting != 0)
- // {
- // string decomSetStr = info.Seting.ToString();
- // string colorStr = decomSetStr.Substring(0, 1);
- // colorType = (EquipColorType)(int.Parse(colorStr) - 1);
- // string lvStr = decomSetStr.Substring(1, decomSetStr.Length - 2);
- // }
- // if (RefreshDecomAttrAct != null)
- // {
- // RefreshDecomAttrAct();
- // }
- // }
- /// <summary>
- /// 璁剧疆鑾峰緱鐐间腹鏉愭枡鐨勫睍绀烘暟鎹�
- /// </summary>
- /// <param name="getMatInfos"></param>
- /// <returns></returns>
- private List<DecomposeGetMatInfo> getMatInfos = new List<DecomposeGetMatInfo>();
- public List<DecomposeGetMatInfo> SetShowMatInfo()
- {
- getMatInfos.Clear();
- int sumMatCnt = 0;
- if (getItems != null)
- {
- for (int i = 0; i < getItems.Length; i++)
- {
- if (getItems[i].Count > 0)
- {
- sumMatCnt += getItems[i].Count;
- }
- else
- {
- sumMatCnt += 1;
- }
- }
- }
-
- if (sumMatCnt > 5)
- {
- for (int i = 0; i < getItems.Length; i++)
- {
- getMatInfos.Add(getItems[i]);
- }
- }
- else
- {
- if (getItems != null)
- {
- for (int i = 0; i < getItems.Length; i++)
- {
- //if (getItems[i].Count > 0)
- //{
- // for (int j = 0; j < getItems[i].Count; j++)
- // {
- // DecomposeGetMatInfo matInfo = new DecomposeGetMatInfo();
- // matInfo.ItemID = getItems[i].ItemID;
- // matInfo.Count = 1;
- // matInfo.IsSuite = getItems[i].IsSuite;
- // matInfo.UserData = getItems[i].UserData;
- // getMatInfos.Add(matInfo);
- // }
- //}
- //else
- {
- getMatInfos.Add(getItems[i]);
- }
- }
- }
- }
- return getMatInfos;
- }
-
- public enum EquipColorType
- {
- None = 0,
- White = 1,
- Blue = 2,
- Purple = 3,
- Orange = 4,
- Red = 5,
- //鍚庣画IL寮�鍙戞坊鍔犻璁�
- default1,
- default2,
- default3,
- default4,
- All = 10,
- }
-
- public class DecomposeGetMatInfo
- {
- public int ItemID;
- public int Count;
- public int IsSuite;
- public string UserData;
- }
- #endregion
-
- #region 涓硅嵂閫昏緫澶勭悊
-
- // private int CompareMakeDrug(AttrFruitConfig start, AttrFruitConfig end)
- // {
- // ItemConfig configS = ItemConfig.Get(start.ID);
- // ItemConfig configE = ItemConfig.Get(end.ID);
- // if (configS.RealmLimit.CompareTo(configE.RealmLimit) != 0)
- // {
- // return configS.RealmLimit.CompareTo(configE.RealmLimit);
- // }
- // if (configS.LV.CompareTo(configE.LV) != 0)
- // {
- // return configS.LV.CompareTo(configE.LV);
- // }
-
- // int x = makeDruglist.IndexOf(start);
- // int y = makeDruglist.IndexOf(end);
- // if (x.CompareTo(y) != 0) x.CompareTo(y);
-
- // return 0;
- // }
-
- // List<AttrFruitConfig> drugOrderlist = new List<AttrFruitConfig>();
- // List<AttrFruitConfig> haveDruglist = new List<AttrFruitConfig>();
- // public List<AttrFruitConfig> GetDrugOrderByCnt()
- // {
- // drugOrderlist.Clear();
- // haveDruglist.Clear();
- // drugOrderlist.AddRange(makeDruglist);
- // drugOrderlist.Sort(CompareByIsHave);
- // for (int i = 0; i < drugOrderlist.Count; i++)
- // {
- // if (IsHaveDrugUse(drugOrderlist[i]))
- // {
- // haveDruglist.Add(drugOrderlist[i]);
- // }
- // }
- // haveDruglist.Sort(CompareMakeDrug);
- // for (int i = 0; i < haveDruglist.Count; i++)
- // {
- // drugOrderlist[i] = haveDruglist[i];
- // }
-
- // return drugOrderlist;
- // }
-
- public bool CheckIsDrugById(int itemId)
- {
- // for (int i = 0; i < makeDruglist.Count; i++)
- // {
- // if (makeDruglist[i].ID == itemId)
- // {
- // return true;
- // }
- // }
- return false;
- }
-
- // public int CompareByIsHave(AttrFruitConfig start, AttrFruitConfig end)
- // {
- // bool isHaveStart = IsHaveDrugUse(start);
- // bool isHaveEnd = IsHaveDrugUse(end);
- // if (isHaveStart.CompareTo(isHaveEnd) != 0) return -isHaveStart.CompareTo(isHaveEnd);
-
- // //isHaveStart = IsHaveDrugRecycle(start);
- // //isHaveEnd = IsHaveDrugRecycle(end);
- // //if (isHaveStart.CompareTo(isHaveEnd) != 0) return -isHaveStart.CompareTo(isHaveEnd);
-
- // isHaveStart = GetItemCountByID(PackType.Item, start.ID) > 0 ? true : false;
- // isHaveEnd = GetItemCountByID(PackType.Item, end.ID) > 0 ? true : false;
- // if (isHaveStart.CompareTo(isHaveEnd) != 0) return isHaveStart.CompareTo(isHaveEnd);
-
- // isHaveStart = IsReachMaxUseDrug(start);
- // isHaveEnd = IsReachMaxUseDrug(end);
- // if (isHaveStart.CompareTo(isHaveEnd) != 0) return isHaveStart.CompareTo(isHaveEnd);
-
- // int x = makeDruglist.IndexOf(start);
- // int y = makeDruglist.IndexOf(end);
- // if (x.CompareTo(y) != 0) return x.CompareTo(y);
- // return 0;
- // }
-
- // public bool IsHaveDrugUse(AttrFruitConfig fruitConfig)
- // {
- // if (!IsReachMaxUseDrug(fruitConfig))
- // {
- // return GetItemCountByID(PackType.Item, fruitConfig.ID) > 0 ? true : false;
- // }
-
- // return false;
- // }
-
- // public bool IsHaveDrugRecycle(AttrFruitConfig fruitConfig)
- // {
- // if (IsReachMaxUseDrug(fruitConfig))
- // {
- // return GetItemCountByID(PackType.Item, fruitConfig.ID) > 0 ? true : false;
- // }
- // return false;
- // }
-
- // public bool IsReachMaxUseDrug(AttrFruitConfig fruitConfig)
- // {
- // if (fruitConfig == null)
- // {
- // return false;
- // }
-
- // if (fruitConfig.FuncID == 2)
- // {
- // AlchemyDrugUseLimit drugUseLimit;
- // if (alchemyModel.TryGetAlchemyUseLimit(fruitConfig.ID, out drugUseLimit))
- // {
- // return drugUseLimit.IsReachLimit();
- // }
- // }
-
- // int useNum = GetItemTotalUsedTimes(fruitConfig.ID);
- // if (useNum >= fruitConfig.basicUseLimit)
- // {
- // return true;
- // }
- // return false;
- // }
- #endregion
-
- //鑾峰彇鑳屽寘涓殑涓�浠跺彲鎷嶅崠鐗╁搧 浼樺厛鍏朵粬鑱屼笟
- public string GetAuctionEquip()
- {
- var itemPackage = GetSinglePack(PackType.Item);
- var allItems = itemPackage.GetAllItems();
-
- var guid = string.Empty;
- List<string> guidList = new List<string>();
- foreach (var item in allItems.Values)
- {
- var isAuction = item.isAuction;
- if (isAuction && ItemLogicUtility.Instance.IsRealmEquip(item.itemId))
- {
- if (!ItemLogicUtility.Instance.IsJobCompatibleItem(item.itemId))
- {
- return item.guid;
- }
- else
- {
- if (guid != string.Empty)
- continue;
- guid = item.guid;
- }
- }
- }
- return guid;
- }
-
-
- public void ReceiveAwardNotify(HA801_tagMCGiveAwardInfo netPack)
- {
- var eventName = UIHelper.ServerStringTrim(netPack.EventName);
- if (eventName == "BuyItem")
- return;
-
- // 浠欑洘鏀诲煄鎴�
- // if (eventName == "FamilyGCZSQGrid" || eventName == "FamilyGCZSQPass" || eventName == "FamilyGCZSQPassAll" ||
- // eventName == "FamilyGCZContiribution" || eventName == "FamilyGCZAtk")
- // {
- // ModelCenter.Instance.GetModel<FairySiegeActModel>()?.OnUpdateAwardInfoAction(netPack);
- // return;
- // }
- if (!commonShowAwardEvents.Contains(eventName))
- return;
-
- List<Item> showItems = new List<Item>();
-
- if (netPack.Exp != 0 || netPack.ExpPoint != 0)
- {
- ulong expValue = netPack.Exp + netPack.ExpPoint * (ulong)Constants.ExpPointValue;
- showItems.Add(new Item(GeneralDefine.expDisplayId, expValue));
- }
- if (netPack.MoneyList.Length != 0)
- {
- for (int i = 0; i < netPack.MoneyLen; i++)
- {
- var moneyType = netPack.MoneyList[i].MoneyType;
- if (GeneralDefine.moneyDisplayIds.ContainsKey(moneyType) && netPack.MoneyList[i].MoneyValue != 0)
- {
- showItems.Add(new Item(GeneralDefine.moneyDisplayIds[moneyType], netPack.MoneyList[i].MoneyValue));
- }
-
- }
- }
-
- if (netPack.ItemList.Length != 0)
- {
- for (int i = 0; i < netPack.ItemLen; i++)
- {
- showItems.Add(new Item((int)netPack.ItemList[i].ItemID, netPack.ItemList[i].Count, netPack.ItemList[i].IsBind));
- }
- }
-
-
- string info = string.Empty;
- if (LanguageConfig.HasKey("commonShowAwardEvents_" + eventName))
- info = Language.Get("commonShowAwardEvents_" + eventName);
-
- if (showItems.Count == 0)
- return;
-
- ItemLogicUtility.Instance.ShowGetItem(showItems, info, 0, eventName: eventName);
- }
- }
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using LitJson;
+using System.Text.RegularExpressions;
+using System.Collections;
+
+ public class PackManager : GameSystemManager<PackManager>
+ //public class PackModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
+ {
+ public static string StrengthAttrShift_RecordKey = "";
+ public const string RecordKnapsackTitle = "RecordKnapsackTitle";
+
+ Dictionary<int, int> DrugToDungeonDict { get; set; } //key 涓硅嵂ID,value鍓湰ID
+ Dictionary<int, int[]> DungeonToDrugDict { get; set; } //key 鍓湰ID,value涓硅嵂ID鍒楄〃
+ //public List<AttrFruitConfig> makeDruglist { get; private set; }
+ Dictionary<int, Dictionary<int, int>> decomposeAttrDict = new Dictionary<int, Dictionary<int, int>>();
+ string RoleEquipLocalSave = "";
+ List<int> LocalSavePlaceArray { get; set; }
+ Dictionary<int, List<int>> sharedUseCountItemDict { get; set; }
+ bool isUpdatePlayerLv = false;
+
+ //AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
+ //ItemTipsModel itemTipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
+
+ public int lsItemID = 150; //鍙厬鎹㈢殑鐏电煶鐗╁搧ID
+ int lsItemCnt = 0;
+ List<string> commonShowAwardEvents = new List<string>();
+
+ public int[] autoUseItemIDs;
+ UIEffect lingshiEffect; //鐏电煶鐗规晥
+ public override void Init()
+ {
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
+ DTC0102_tagCDBPlayer.afterPlayerDataInitializeEvent += OnAfterPlayerDataInitialize;
+ DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
+ ParseConfig();
+ //SysNotifyMgr.Instance.sysNotifyEvent += RefreshSysInfo;
+ // List<DungeonOpenTimeConfig> dungeonlist = DungeonOpenTimeConfig.GetValues();
+ // if (dungeonlist != null)
+ // {
+ // //DrugToDungeonDict = new Dictionary<int, int>();
+ // DungeonToDrugDict = new Dictionary<int, int[]>();
+
+ // for (int i = 0; i < dungeonlist.Count; i++)
+ // {
+ // int[] drugIdlist = dungeonlist[i].ElixirHint;
+ // if (drugIdlist != null && drugIdlist.Length > 0)
+ // {
+ // DungeonToDrugDict.Add(dungeonlist[i].DataMapID, drugIdlist);
+ // //for (int j = 0; j < drugIdlist.Length; j++)
+ // //{
+ // // DrugToDungeonDict.Add(drugIdlist[j], dungeonlist[i].DataMapID);
+ // //}
+ // }
+ // }
+ // }
+
+ // makeDruglist = new List<AttrFruitConfig>();
+ // List<AttrFruitConfig> fruitlist = AttrFruitConfig.GetValues();
+ // for (int i = 0; i < fruitlist.Count; i++)
+ // {
+ // if (fruitlist[i].FuncID == 2)
+ // {
+ // makeDruglist.Add(fruitlist[i]);
+ // }
+ // }
+ // StageLoad.Instance.onStageLoadFinish += OnStageLoadFinish;
+
+ SetDevourEquipPlace();
+
+ // decomposeAttrDict.Clear();
+ // List<EquipDeComposeConfig> decomlist = EquipDeComposeConfig.GetValues();
+ // for (int i = 0; i < decomlist.Count; i++)
+ // {
+ // JsonData attrData = JsonMapper.ToObject(decomlist[i].Attr);
+ // Dictionary<int, int> attrDict = new Dictionary<int, int>();
+ // decomposeAttrDict.Add(decomlist[i].LV, attrDict);
+ // foreach (var id in attrData.Keys)
+ // {
+ // attrDict.Add(int.Parse(id), int.Parse(attrData[id].ToString()));
+ // }
+ // }
+
+ FuncConfigConfig equipDecompose = FuncConfigConfig.Get("EquipDevourCount");
+ minDecomposeNum = int.Parse(equipDecompose.Numerical1);
+ defaultUnSelectlist = ConfigParse.GetMultipleStr<int>(equipDecompose.Numerical2);
+
+ FuncConfigConfig ShareUseCntItem = FuncConfigConfig.Get("ShareUseCntItem");
+ sharedUseCountItemDict = new Dictionary<int, List<int>>();
+ JsonData shareUseJson = JsonMapper.ToObject(ShareUseCntItem.Numerical1);
+ if (shareUseJson.IsArray)
+ {
+ for (int i = 0; i < shareUseJson.Count; i++)
+ {
+ var idListJson = shareUseJson[i];
+ var idlist = new List<int>();
+ sharedUseCountItemDict.Add(i, idlist);
+ foreach (var id in idListJson)
+ {
+ idlist.Add(int.Parse(id.ToString()));
+ }
+ }
+ }
+
+ ParseItemCount();
+
+ autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("ItemTipsNum").Numerical2);
+ }
+
+
+ public override void Release()
+ {
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
+ DTC0102_tagCDBPlayer.afterPlayerDataInitializeEvent -= OnAfterPlayerDataInitialize;
+ DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
+FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
+ // SysNotifyMgr.Instance.sysNotifyEvent -= RefreshSysInfo;
+ }
+
+ public Dictionary<int, string> textCountShow = new Dictionary<int, string>();
+ public int[] textCountShow2;
+ public List<int> gameCashShow = new List<int>();
+
+ public void ParseItemCount()
+ {
+ var textConfig = FuncConfigConfig.Get("ItemCountShow");
+ var json = JsonMapper.ToObject(textConfig.Numerical1);
+ foreach (var key in json.Keys)
+ {
+ var itemID = int.Parse(key);
+ textCountShow[itemID] = json[key].ToString();
+ }
+
+ textCountShow2 = JsonMapper.ToObject<int[]>(textConfig.Numerical2);
+ gameCashShow = JsonMapper.ToObject<List<int>>(textConfig.Numerical3);
+ }
+
+
+ private void OnFuncStateChangeEvent(int id)
+ {
+ if (id == (int)FuncOpenEnum.EquipDecompose)
+ {
+ EquipDecomRedCtrl();
+ }
+ }
+ public void OnBeforePlayerDataInitialize()
+ {
+ GlobalTimeEvent.Instance.secondEvent -= UpdateSecond;
+ PlayerDatas.Instance.playerDataRefreshEvent -= UpdatePlayerLv;
+ LocalSave.DeleteKey(RecordKnapsackTitle);
+ cacheMapId = 0;
+ playerPackDict.Clear();
+ itemDayUseCntDict.Clear();
+ itemSumUseCntDict.Clear();
+ itemGUIDDict.Clear();
+ isPlayBetterEquipEffect = false;
+ colorType = EquipColorType.Orange;
+ decomposeLv = 1;
+ decomposeExp = 0;
+ decomposeProgress = 0;
+ isAutoDecompose = false;
+ }
+
+ public void OnAfterPlayerDataInitialize()
+ {
+
+ }
+
+ public void OnPlayerLoginOk()
+ {
+ //ItemOperateUtility.Instance.RequestWarehouseData();
+ EquipDecomRedCtrl();
+ RoleEquipLocalSave = StringUtility.Contact("RoleEquipLocalSave", PlayerDatas.Instance.baseData.PlayerID);
+ StrengthAttrShift_RecordKey = StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID, "StrengthAttrShift");
+ if (LocalSave.GetIntArray(RoleEquipLocalSave) != null)
+ {
+ LocalSavePlaceArray = LocalSave.GetIntArray(RoleEquipLocalSave).ToList();
+ }
+ else
+ {
+ LocalSavePlaceArray = null;
+ }
+ GlobalTimeEvent.Instance.secondEvent += UpdateSecond;
+ PlayerDatas.Instance.playerDataRefreshEvent += UpdatePlayerLv;
+ isUpdatePlayerLv = true;
+ FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
+ }
+
+ private void RefreshSysInfo(string key, ArrayList infolist)
+ {
+ // if (key != "GetMoney") return;
+ // if (ItemLogicUtility.Instance.hidePickItem)
+ // return;
+
+ // if (PlayerDatas.Instance.baseData.LV < 3)
+ // return;
+
+ // var type = 0;
+ // int.TryParse(infolist[0].ToString(), out type);
+ // if (type == 1)
+ // {
+ // Vector3 pos = new Vector3(-100, 0, 0);
+ // Vector3 rot = new Vector3(0, 0, 0);
+ // if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
+ // {
+ // pos = new Vector3(0, 50, 0);
+ // rot = new Vector3(180, 180, 0);
+ // }
+ // EffectMgr.Instance.PlayUIEffect(1204, 3000, WindowCenter.Instance.uiRoot.tipsCanvas, pos, rot, false);
+ // }
+ // else if (type == 2)
+ // {
+ // Vector3 pos = new Vector3(-100, 0, 0);
+ // Vector3 rot = new Vector3(0, 0, 0);
+ // if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
+ // {
+ // pos = new Vector3(150, 50, 0);
+ // rot = new Vector3(180, 180, 0);
+ // }
+ // lingshiEffect = EffectMgr.Instance.PlayUIEffect(1158, 3000, WindowCenter.Instance.uiRoot.tipsCanvas, pos, rot, false);
+ // }
+ }
+
+ public event Action<PackType> refrechPackEvent; //鍒锋柊鏁翠釜鑳屽寘鏁版嵁
+ public event Action<PackType, int, int> refreshItemCountEvent; // 鎱庣敤浼氬崱锛堝崟涓級鏈�鏂扮墿鍝佹暟閲忓埛鏂�(鏃х殑寮冪敤)鍦ㄥ緱鍒版柊鐗╁搧銆佺墿鍝佹暟閲忕殑鏀瑰彉锛屾竻鐞嗚鐗╁搧鏃跺潎浼氳Е鍙� int 浣嶇疆绱㈠紩 int鐗╁搧id
+ public event Action<PackType> gridRefreshEvent; //鑳屽寘绌烘牸鍒锋柊
+ public event Action<PackType, int, int> itemCntAddEvent; //鐗╁搧鏁伴噺澧炲姞 int 浣嶇疆绱㈠紩 int鐗╁搧id
+ public event Action<PackType, int, int> itemCntReduceEvent; //鐗╁搧鏁伴噺鍑忓皯鐨勬敼鍙� int 浣嶇疆绱㈠紩 int鐗╁搧id
+ public event Action<int, int> useItemSuccessEvent; //鐗╁搧浣跨敤鎴愬姛 int 浣嶇疆绱㈠紩 int鐗╁搧id
+
+ public event Action<int> refreshItemDayUseCountEvent; //鍒锋柊鐗╁搧姣忔棩浣跨敤鏁伴噺
+ public event Action<int> refreshItemSumUseCountEvent; //鍒锋柊鐗╁搧鎬讳娇鐢ㄦ暟閲�
+
+ public bool isPlayBetterEquipEffect { get; set; } //鏁寸悊鑳屽寘鏃舵槸鍚︽挱鏀剧壒鏁�
+
+ #region 鎺ユ敹鏈嶅姟绔暟鎹�
+ private Dictionary<PackType, SinglePack> playerPackDict = new Dictionary<PackType, SinglePack>();
+ private Dictionary<string, ItemModel> itemGUIDDict = new Dictionary<string, ItemModel>();
+
+ public void UpdatePack(H0725_tagRolePackRefreshEx packInfo)
+ {
+ SetLookIndex(null);
+ var packType = (PackType)packInfo.PackType;
+ if (!playerPackDict.ContainsKey(packType))
+ {
+ playerPackDict.Add(packType, new SinglePack(packType));
+ }
+
+ if (isPlayBetterEquipEffect)
+ {
+ ItemLogicUtility.Instance.ClearSortedBetterEquip();
+ }
+
+ for (int i = 0; i < packInfo.ItemCount; i++)
+ {
+ var itemInfo = new ItemInfo(packInfo.ItemInfo[i]);
+ var item = playerPackDict[packType].UpdateItem(itemInfo);
+ AddItemGUIDDict(item, false);
+
+ if (isPlayBetterEquipEffect)
+ {
+ ItemLogicUtility.Instance.SetBagSortBetterEquipList(GetItemByGuid(itemInfo.guid));
+ }
+ }
+
+ if (refrechPackEvent != null)
+ {
+ refrechPackEvent(packType);
+ }
+
+ UpdatePackRedpoint(packType);
+ }
+
+ public void UpdateItem(H0704_tagRolePackRefresh serverItem)
+ {
+ isPlayBetterEquipEffect = false;
+ SetLookIndex(null);
+ PackType type = (PackType)serverItem.PackType;
+ if (!playerPackDict.ContainsKey(type))
+ {
+ playerPackDict.Add(type, new SinglePack(type));
+ }
+
+ var showNewItem = false;
+ if (itemGUIDDict.ContainsKey(serverItem.ItemGUID))
+ {
+ var prePack = itemGUIDDict[serverItem.ItemGUID].packType;
+ var preAuction = itemGUIDDict[serverItem.ItemGUID].isAuction;
+ var nowPackType = type;
+ var nowAcution = serverItem.IsBind == 1;
+ showNewItem = preAuction != nowAcution || prePack != nowPackType;
+ }
+ else
+ {
+ showNewItem = true;
+ }
+
+ var itemInfo = new ItemInfo(serverItem);
+ var item = playerPackDict[type].UpdateItem(itemInfo);
+ AddItemGUIDDict(item, showNewItem);
+
+ if (refreshItemCountEvent != null)
+ {
+ refreshItemCountEvent(type, itemInfo.index, itemInfo.itemId);
+ }
+
+ if (itemCntAddEvent != null)
+ {
+ itemCntAddEvent(type, itemInfo.index, itemInfo.itemId);
+ }
+
+ // if (type == PackType.Equip)
+ // {
+ // if (ItemLogicUtility.Instance.IsRealmEquip(itemInfo.itemId))
+ // {
+ // ItemOperateUtility.Instance.ShowPutOnNewEquipRemind(itemInfo.itemId);
+ // }
+ // }
+
+ UpdatePackRedpoint(type);
+ //EquipDecomRedCtrl();
+ m_CheckEquipDecomRedCtrl = true;
+ AutoUseItem(itemInfo.itemId, serverItem.ItemGUID);
+ }
+
+
+ bool m_CheckEquipDecomRedCtrl = false;
+ void CheckEquipDecomRedCtrl()
+ {
+ if (m_CheckEquipDecomRedCtrl)
+ {
+ EquipDecomRedCtrl();
+ m_CheckEquipDecomRedCtrl = false;
+ }
+ }
+
+
+ public void UpdateUnlockedGridCount(H0724_tagRolePackCanUseCount useCount)
+ {
+ PackType type = (PackType)useCount.PackType;
+ if (!playerPackDict.ContainsKey(type))
+ {
+ playerPackDict.Add(type, new SinglePack(type));
+ }
+
+ playerPackDict[type].SetOpenGridCount(useCount.CanUseCount);
+
+ if (gridRefreshEvent != null)
+ {
+ gridRefreshEvent(type);
+ }
+
+ UpdatePackRedpoint(type);
+ }
+
+ public void RefreshItemCount(H0707_tagItemCountRefresh refresh)
+ {
+ SetLookIndex(null);
+ isPlayBetterEquipEffect = false;
+ PackType type = (PackType)refresh.PackType;
+ SinglePack singlePack = null;
+ playerPackDict.TryGetValue(type, out singlePack);
+
+ if (singlePack != null)
+ {
+ ItemModel itemModel = singlePack.GetItemByIndex(refresh.ItemIndex);
+ if (itemModel != null)
+ {
+ bool isAddItemCount = false;
+ if (refresh.ItemCount > itemModel.count)
+ {
+ isAddItemCount = true;
+ }
+ itemModel.RefreshCount(refresh.ItemCount);
+
+ if (isAddItemCount)
+ {
+ if (itemCntAddEvent != null)
+ {
+ itemCntAddEvent(type, itemModel.gridIndex, itemModel.itemId);
+ }
+ ItemLogicUtility.Instance.RecommendItem(itemModel);
+ ItemLogicUtility.Instance.RefreshPickItem(type, itemModel.itemId.ToString());
+ }
+ else
+ {
+ if (itemCntReduceEvent != null)
+ {
+ itemCntReduceEvent(type, itemModel.gridIndex, itemModel.itemId);
+ }
+ }
+
+ if (refreshItemCountEvent != null)
+ {
+ refreshItemCountEvent(type, itemModel.gridIndex, itemModel.itemId);
+ }
+
+ UpdateLSRedpoint(type, itemModel.itemId);
+ }
+ }
+
+ }
+
+ public void ClearPack(H0711_tagClearItemPack clearPack)
+ {
+ PackType type = (PackType)clearPack.PackIndex;
+ SinglePack singlePack = null;
+ playerPackDict.TryGetValue(type, out singlePack);
+ if (singlePack != null)
+ {
+ singlePack.Clear();
+ }
+ }
+
+ public void RemoveItem(H0709_tagClearItem clearItem)
+ {
+ isPlayBetterEquipEffect = false;
+ SetLookIndex(null);
+ PackType type = (PackType)clearItem.PackType;
+
+ SinglePack singlePack = null;
+ playerPackDict.TryGetValue(type, out singlePack);
+ string guid = "";
+ if (singlePack != null)
+ {
+ ItemModel itemModel = singlePack.GetItemByIndex(clearItem.ItemIndex);
+ guid = itemModel.guid;
+ int itemId = itemModel.itemId;
+
+ DeleteItemDictByGUID(type, itemModel.guid);
+
+ singlePack.RemoveItem(clearItem.ItemIndex);
+ if (refreshItemCountEvent != null)
+ {
+ refreshItemCountEvent(type, clearItem.ItemIndex, itemId);
+ }
+
+ if (itemCntReduceEvent != null)
+ {
+ itemCntReduceEvent(type, clearItem.ItemIndex, itemId);
+ }
+ }
+
+ UpdatePackRedpoint(type);
+ m_CheckEquipDecomRedCtrl = true;
+ //EquipDecomRedCtrl();
+
+ if (GetItemByGuid(guid) == null)
+ {
+ KnapsackTimeCDMgr.Instance.UnRegister(guid);
+ }
+
+ }
+
+ public void PackResetOk(H0316_tagPackResetOK packreset)
+ {
+ ItemLogicUtility.Instance.isPackResetOk = true;
+ }
+
+ public void UseItemSuccess(H0706_tagUseItemSuccess success)
+ {
+ isPlayBetterEquipEffect = false;
+ SetLookIndex(null);
+ if (success.PlayerID != PlayerDatas.Instance.baseData.PlayerID)
+ {
+ return;
+ }
+
+ MakeUseItemSuccess(success.ItemIndex, (int)success.ItemID);
+ switch (success.ItemID)
+ {
+ // case 221:
+ // if (WindowCenter.Instance.IsOpen<KnapSackWin>())
+ // {
+ // WindowCenter.Instance.Close<KnapSackWin>();
+ // }
+ // break;
+ }
+
+ if (useItemSuccessEvent != null)
+ {
+ useItemSuccessEvent(success.ItemIndex, (int)success.ItemID);
+ }
+ }
+
+ void AutoUseItem(int itemID, string guid)
+ {
+ // if (autoUseItemIDs.Contains(itemID))
+ // {
+ // ItemOperateUtility.Instance.GotoUseItem(guid);
+ // }
+ }
+
+ private void MakeUseItemSuccess(int index, int id)
+ {
+ ItemConfig itemConfig = ItemConfig.Get(id);
+ if (itemConfig.CDType != 0)
+ {
+ var items = GetItems(PackType.Item, new SinglePack.FilterParams()
+ {
+ itemTypes = new List<int>() { (int)ItemType.Buff }
+ });
+
+ for (int i = 0; i < items.Count; i++)
+ {
+ if (ItemLogicUtility.Instance.drugIDs.Contains(items[i].itemId))
+ {
+ itemConfig = ItemConfig.Get(items[i].itemId);
+ float configCdTime = (float)Math.Round((double)itemConfig.CDTime / 1000, 1);
+ KnapsackTimeCDMgr.Instance.Register(items[i].guid, items[i].itemId, configCdTime);
+ }
+ }
+
+ }
+ }
+
+ void AddItemGUIDDict(ItemModel itemModel, bool showNewItem)
+ {
+ itemGUIDDict[itemModel.guid] = itemModel;
+ GetItemEventCtrl(itemModel, showNewItem);
+ }
+
+ void DeleteItemDictByGUID(PackType type, string guid)
+ {
+ if (itemGUIDDict.ContainsKey(guid))
+ {
+ if (itemGUIDDict[guid].packType == type)
+ {
+ itemGUIDDict.Remove(guid);
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鐗╁搧姣忔棩浣跨敤鐨勬鏁�
+ /// </summary>
+ private Dictionary<int, int> itemDayUseCntDict = new Dictionary<int, int>();
+ public void UpdateItemUseCnt(HA809_tagMCItemDayUseCntInfo useCntInfo)
+ {
+ for (int i = 0; i < useCntInfo.Count; i++)
+ {
+ int itemId = (int)useCntInfo.ItemUseCntList[i].ItemID;
+ int cnt = useCntInfo.ItemUseCntList[i].UseCnt;
+ if (!itemDayUseCntDict.ContainsKey(itemId))
+ {
+ itemDayUseCntDict.Add(itemId, cnt);
+ }
+ else
+ {
+ itemDayUseCntDict[itemId] = cnt;
+ }
+
+ if (refreshItemDayUseCountEvent != null)
+ {
+ refreshItemDayUseCountEvent(itemId);
+ }
+
+ }
+ }
+
+ private Dictionary<int, int> itemSumUseCntDict = new Dictionary<int, int>();
+ // public void UpdateItemSumUseCnt(HA339_tagMCAttrFruitEatCntList useCntInfo)
+ // {
+ // for (int i = 0; i < useCntInfo.count; i++)
+ // {
+ // int itemId = (int)useCntInfo.EatCntList[i].ItemID;
+ // int cnt = (int)useCntInfo.EatCntList[i].EatCnt;
+ // if (!itemSumUseCntDict.ContainsKey(itemId))
+ // {
+ // itemSumUseCntDict.Add(itemId, cnt);
+ // }
+ // else
+ // {
+ // itemSumUseCntDict[itemId] = cnt;
+ // }
+
+ // if (refreshItemSumUseCountEvent != null)
+ // {
+ // refreshItemSumUseCountEvent(itemId);
+ // }
+ // }
+ // }
+
+ #endregion
+
+ #region 鐜╁瑁呭鐗规畩閫昏緫
+ public Dictionary<int, Dictionary<int, int>> spiritWeaponPathIds { get; private set; }
+ public Dictionary<int, int> wingsGetPathIdDict { get; private set; }
+ public Dictionary<int, List<int>> dungeonUseDict { get; private set; }
+ void ParseConfig()
+ {
+ FuncConfigConfig funcConfig = FuncConfigConfig.Get("WingYuPeiHQTJ");
+ spiritWeaponPathIds = new Dictionary<int, Dictionary<int, int>>();
+ var splits = funcConfig.Numerical3.Split('|');
+ for (int i = 0; i < splits.Length; i++)
+ {
+ var tempString = splits[i];
+ var matches = Regex.Matches(tempString.Trim(), "\\d+");
+ var equipPlace = int.Parse(matches[0].Value);
+ var job = int.Parse(matches[1].Value);
+ var itemId = int.Parse(matches[2].Value);
+
+ if (!spiritWeaponPathIds.ContainsKey(equipPlace))
+ {
+ spiritWeaponPathIds[equipPlace] = new Dictionary<int, int>();
+ }
+
+ spiritWeaponPathIds[equipPlace][job] = itemId;
+ }
+
+ FuncConfigConfig copyItemBulletWindow = FuncConfigConfig.Get("CopyItemBulletWindow");
+ JsonData copyWinData = JsonMapper.ToObject(copyItemBulletWindow.Numerical1);
+ dungeonUseDict = new Dictionary<int, List<int>>();
+ foreach (var dungeonId in copyWinData.Keys)
+ {
+ List<int> idlist = new List<int>();
+ dungeonUseDict.Add(int.Parse(dungeonId), idlist);
+ if (copyWinData[dungeonId].IsArray)
+ {
+ JsonData useData = copyWinData[dungeonId];
+ for (int i = 0; i < useData.Count; i++)
+ {
+ idlist.Add(int.Parse(useData[i].ToString()));
+ }
+ }
+ }
+
+ lsItemCnt = int.Parse(FuncConfigConfig.Get("LingshiShowCount").Numerical1);
+ var config = FuncConfigConfig.Get("CommonShowAwards");
+ commonShowAwardEvents = JsonMapper.ToObject<List<string>>(config.Numerical1);
+
+ }
+
+ public int GetRoleEquipPathId(int equipPlace)
+ {
+ int playerJob = PlayerDatas.Instance.baseData.Job;
+ switch ((RoleEquipType)equipPlace)
+ {
+ case RoleEquipType.Guard:
+ case RoleEquipType.PeerlessWeapon1:
+ case RoleEquipType.PeerlessWeapon2:
+ case RoleEquipType.Wing:
+ return spiritWeaponPathIds[equipPlace][playerJob];
+ default:
+ return 0;
+ }
+ }
+
+ private void UpdateSecond()
+ {
+ if (isUpdatePlayerLv)
+ {
+ isUpdatePlayerLv = false;
+ }
+ CheckEquipDecomRedCtrl();
+ }
+
+ private void UpdatePlayerLv(PlayerDataType type)
+ {
+ if (type != PlayerDataType.LV) return;
+
+ isUpdatePlayerLv = true;
+ }
+
+ #endregion
+
+
+ private void GetItemEventCtrl(ItemModel itemModel, bool showNewItem)
+ {
+ // if (showNewItem)
+ // {
+ // bool isOverdue = false;
+ // if (itemModel.config.ExpireTime > 0)
+ // {
+ // ItemCDCool cool = KnapsackTimeCDMgr.Instance.GetItemCoolById(itemModel.guid);
+ // switch ((ItemTimeType)itemModel.config.EndureReduceType)
+ // {
+ // case ItemTimeType.EquipedTime:
+ // List<int> itemEffectTime = itemModel.GetUseData((int)ItemUseDataKey.createTime);
+ // if (itemEffectTime != null && itemEffectTime[0] != 0)
+ // {
+ // if (cool == null || cool.GetRemainTime() <= 0)
+ // {
+ // isOverdue = true;
+ // }
+ // }
+ // break;
+
+ // case ItemTimeType.RealityTime:
+ // if (cool == null || cool.GetRemainTime() <= 0)
+ // {
+ // isOverdue = true;
+ // }
+ // break;
+
+ // }
+ // }
+
+ // if (!isOverdue)
+ // {
+ // ItemLogicUtility.Instance.RecommendItem(itemModel);
+ // ItemLogicUtility.Instance.OnGetEquip(itemModel);
+ // ItemLogicUtility.Instance.RefreshPickItem(itemModel.packType, itemModel.itemId.ToString());
+ // }
+ // }
+
+ }
+
+ /// <summary>
+ /// 寰楀埌鏌愪釜鍖呰9鐨勬墍鏈夋暟鎹�
+ /// </summary>
+ /// <param name="type"></param>
+ /// <returns></returns>
+ public SinglePack GetSinglePack(PackType type)
+ {
+ SinglePack singlePack = null;
+ playerPackDict.TryGetValue(type, out singlePack);
+ return singlePack;
+ }
+
+ public void UnLockPackGrid(int chooseGridCount, PackType type)
+ {
+ // var singlePack = GetSinglePack(type);
+ // int openCount = chooseGridCount - singlePack.unlockedGridCount;
+ // int index = 0;
+ // switch (type)
+ // {
+ // case PackType.Item:
+ // index = chooseGridCount - GeneralDefine.initBagGridCount;
+ // break;
+ // case PackType.Warehouse:
+ // index = chooseGridCount - GeneralDefine.initDepotGridCount;
+ // break;
+ // }
+
+ // itemTipsModel.SetExtendGirdModel(openCount, index, type);
+ // WindowCenter.Instance.Open<ExtendWin>();
+ }
+
+ public ItemModel GetItemByGuid(string guid)
+ {
+ if (string.IsNullOrEmpty(guid))
+ {
+ return null;
+ }
+
+ ItemModel itemModel = null;
+ itemGUIDDict.TryGetValue(guid, out itemModel);
+ return itemModel;
+ }
+
+ public ItemModel GetItemByIndex(PackType type, int index)
+ {
+ ItemModel itemModel = null;
+ if (playerPackDict.ContainsKey(type))
+ {
+ itemModel = playerPackDict[type].GetItemByIndex(index);
+ }
+ return itemModel;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎸囧畾鑳屽寘鍐� 鎸囧畾ID鐨勬墍鏈夌墿鍝�
+ /// </summary>
+ /// <param name="type"></param>
+ /// <param name="id"></param>
+ /// <param name="includeAuction"></param>
+ /// <returns></returns>
+ public List<ItemModel> GetItemsById(PackType type, int id, bool includeAuction = true)
+ {
+ if (playerPackDict.ContainsKey(type))
+ {
+ var singlePack = playerPackDict[type];
+ return singlePack.GetItemsById(id, includeAuction);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎸囧畾鑳屽寘鍐呮寚瀹欼D鐨勪竴涓墿鍝�
+ /// </summary>
+ /// <param name="type"></param>
+ /// <param name="id"></param>
+ /// <param name="includeAuction"></param>
+ /// <returns></returns>
+ public ItemModel GetItemByID(PackType type, int id, bool includeAuction = true)
+ {
+ if (playerPackDict.ContainsKey(type))
+ {
+ var singlePack = playerPackDict[type];
+ return singlePack.GetItemByID(id, includeAuction);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public List<ItemModel> GetItems(PackType packType, SinglePack.FilterParams param)
+ {
+ if (playerPackDict.ContainsKey(packType))
+ {
+ return playerPackDict[packType].GetItems(param);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ //閫氳繃id鎵剧墿鍝侊紝娉ㄦ剰妫�鏌ユ槸鍚︽寚瀹氳儗鍖�
+ public string GetItemGUIDByID(int itemId, bool includeAuction = true, PackType packType = PackType.Item)
+ {
+ string guid = string.Empty;
+ foreach (var key in itemGUIDDict.Keys)
+ {
+ if (!includeAuction && itemGUIDDict[key].isAuction)
+ {
+ continue;
+ }
+
+ if (itemGUIDDict[key].itemId == itemId && packType == itemGUIDDict[key].packType)
+ {
+ guid = key;
+ return guid;
+ }
+ }
+
+ return guid;
+ }
+
+ /// <summary>
+ /// 寰楀埌ID鐩稿悓鐨勭墿鍝佹暟閲�
+ /// </summary>
+ /// <param name="type"></param>
+ /// <param name="id"></param>
+ /// <returns></returns>
+ public int GetItemCountByID(PackType type, int id, bool includeAuction = true)
+ {
+ int count = 0;
+ var singlePack = GetSinglePack(type);
+ if (singlePack != null)
+ {
+ count = singlePack.GetCountById(id, includeAuction);
+ }
+
+ return count;
+ }
+
+ public int GetEmptyGridCount(PackType type)
+ {
+ int count = 0;
+ SinglePack singlePack = GetSinglePack(type);
+ if (singlePack != null)
+ {
+ count = singlePack.GetEmptyGridCount();
+ }
+
+ return count;
+ }
+
+ public bool TryGetShareNumItem(int itemId, out List<int> idlist)
+ {
+ idlist = new List<int>();
+ foreach (var list in sharedUseCountItemDict.Values)
+ {
+ if (list.Contains(itemId))
+ {
+ idlist = list;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// 寰楀埌鐗╁搧浠婃棩浣跨敤娆℃暟
+ /// </summary>
+ /// <param name="itemId"></param>
+ /// <returns></returns>
+ public int GetItemUsedTimesToday(int itemId)
+ {
+ int useCnt = 0;
+ List<int> shareIdlist = null;
+ bool isShare = TryGetShareNumItem(itemId, out shareIdlist);
+ if (isShare)
+ {
+ foreach (var id in shareIdlist)
+ {
+ int singleUseCnt = 0;
+ itemDayUseCntDict.TryGetValue(id, out singleUseCnt);
+ useCnt += singleUseCnt;
+ }
+ }
+ else
+ {
+ itemDayUseCntDict.TryGetValue(itemId, out useCnt);
+ }
+ return useCnt;
+ }
+
+ /// <summary>
+ /// 寰楀埌鐗╁搧鎬讳娇鐢ㄦ鏁�
+ /// </summary>
+ /// <param name="itemId"></param>
+ /// <returns></returns>
+ public int GetItemTotalUsedTimes(int itemId)
+ {
+ int useCnt = 0;
+ List<int> shareIdlist = null;
+ bool isShare = TryGetShareNumItem(itemId, out shareIdlist);
+ if (isShare)
+ {
+ foreach (var id in shareIdlist)
+ {
+ int singleUseCnt = 0;
+ itemDayUseCntDict.TryGetValue(id, out singleUseCnt);
+ useCnt += singleUseCnt;
+ }
+ }
+ else
+ {
+ itemSumUseCntDict.TryGetValue(itemId, out useCnt);
+ }
+ return useCnt;
+ }
+
+ public void GotoWashAttributePoint(string guid)
+ {
+ // ItemModel itemModel = GetItemByGuid(guid);
+ // if (itemModel == null) return;
+
+ // WashAttrPointWin.itemModel = itemModel;
+ // WindowCenter.Instance.Open<WashAttrPointWin>();
+ }
+
+ #region 绾㈢偣閫昏緫鍒ゆ柇
+
+ const int ITEMPACK_REDKEY = 102011003;
+ Redpoint redpointItemPack = new Redpoint(MainRedDot.RedPoint_BagFuncKey, ITEMPACK_REDKEY);
+
+ const int LS_REDKEY = 102011015;
+ Redpoint redpointLS = new Redpoint(MainRedDot.RedPoint_BagFuncKey, LS_REDKEY);
+
+ private void UpdateLSRedpoint(PackType type, int itemID)
+ {
+ var singlePack = GetSinglePack(type);
+ if (singlePack == null)
+ {
+ return;
+ }
+ if (type != PackType.Item) return;
+ if (itemID != lsItemID) return;
+
+
+ if (GetItemCountByID(PackType.Item, lsItemID) < lsItemCnt)
+ {
+ redpointLS.state = RedPointState.None;
+ }
+ else
+ {
+ redpointLS.state = RedPointState.Simple;
+ }
+
+ }
+
+ private void UpdatePackRedpoint(PackType type)
+ {
+ var singlePack = GetSinglePack(type);
+ if (singlePack == null)
+ {
+ return;
+ }
+
+ switch (type)
+ {
+ case PackType.Item:
+ if (singlePack.GetEmptyGridCount() <= 0)
+ {
+ redpointItemPack.state = RedPointState.Full;
+ //SysNotifyMgr.Instance.ShowTip("BagFull");
+ }
+ else
+ {
+ redpointItemPack.state = RedPointState.None;
+ }
+ if (GetItemCountByID(PackType.Item, lsItemID) < lsItemCnt)
+ {
+ redpointLS.state = RedPointState.None;
+ }
+ else
+ {
+ redpointLS.state = RedPointState.Simple;
+ }
+ break;
+ case PackType.Warehouse:
+ if (singlePack.GetEmptyGridCount() <= 0)
+ {
+ MainRedDot.Instance.redPointDepotFunc.state = RedPointState.Full;
+ }
+ else
+ {
+ MainRedDot.Instance.redPointDepotFunc.state = RedPointState.None;
+ }
+ break;
+ }
+ }
+
+ const int PLAYERSUMSTAR_REDKEY = 102011002;
+ Redpoint redpointSTAR = new Redpoint(MainRedDot.RedPoint_BagFuncKey, PLAYERSUMSTAR_REDKEY);
+
+ public const int EquipDecompose_RedKey = 10205;
+ public Redpoint redpointEquipDecom = new Redpoint(MainRedDot.RedPoint_MainPackKey, EquipDecompose_RedKey);
+ public void EquipDecomRedCtrl()
+ {
+ if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.EquipDecompose))
+ {
+ return;
+ }
+
+ if (PlayerDatas.Instance.baseData.LV < devourRedpointLevel)
+ {
+ redpointEquipDecom.state = RedPointState.None;
+ return;
+ }
+
+ var canDevourItems = GetCanDevourModellist();
+ if (canDevourItems != null && canDevourItems.Count >= minDevourEquipNum)
+ {
+ redpointEquipDecom.state = RedPointState.Simple;
+ }
+ else
+ {
+ redpointEquipDecom.state = RedPointState.None;
+ }
+ }
+ #endregion
+
+ #region 鏌ョ湅鏌愪釜浣嶇疆鐨勭墿鍝�
+ public event Action lookEquipEvent;
+ private int _lookLineIndex = -1;
+ public int lookLineIndex { get { return _lookLineIndex; } private set { _lookLineIndex = value; } }
+
+ public string lookItemGUID { get; private set; }
+
+ public void SetLookIndex(string guid, int singleRowCount = 5)
+ {
+ if (string.IsNullOrEmpty(guid) || guid == "")
+ {
+ lookLineIndex = -1;
+ lookItemGUID = "";
+ }
+ else
+ {
+ int index = GetItemByGuid(guid).gridIndex;
+ lookLineIndex = index / singleRowCount;
+ lookItemGUID = guid;
+ }
+
+ if (lookEquipEvent != null)
+ {
+ lookEquipEvent();
+ }
+ }
+
+ public event Action RefreshBagEvent;
+ public void RefreshBagInfo()
+ {
+ if (RefreshBagEvent != null)
+ {
+ RefreshBagEvent();
+ }
+ }
+ #endregion
+
+ public void SetJumpToOneKeySell(Transform parent)
+ {
+ // var goEffect = AchievementGuideEffectPool.Require(1);
+ // goEffect.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one);
+ // AchievementGoto.guideAchievementId = 0;
+ }
+
+ #region 鐗╁搧浣跨敤蹇嵎鎻愮ず
+
+ private int cacheMapId = 0;
+ public event Action<PackType, string> itemUseAct;
+ private Dictionary<int, int> itemUseTypeDict = new Dictionary<int, int>(); //key SkillTypeID,value 浣跨敤鐗╁搧鐨処D
+ private void OnStageLoadFinish()
+ {
+ // itemUseTypeDict.Clear();
+ // if (PlayerDatas.Instance.baseData.MapID == cacheMapId)
+ // {
+ // return;
+ // }
+
+ // cacheMapId = PlayerDatas.Instance.baseData.MapID;
+ // UpdateDungeonDanUse();
+ // UpdateDungeonUse();
+ // SinglePack singlePack = GetSinglePack(PackType.Item);
+ // foreach (int itemId in itemUseTypeDict.Values)
+ // {
+ // var modellist = singlePack.GetItemsById(itemId);
+ // if (modellist.Count > 0)
+ // {
+ // ItemModel itemModel = modellist[0];
+ // bool isExist = StatusMgr.Instance.IsExist(PlayerDatas.Instance.hero.ServerInstID, itemModel.config.AddSkill1);
+ // Debug.Log("Buff鏄惁瀛樺湪" + isExist);
+ // if (itemUseAct != null && !isExist)
+ // {
+ // itemUseAct(PackType.Item, itemModel.guid);
+ // }
+ // }
+ // }
+ }
+
+ private void AddItemUseTypeDict(int id)
+ {
+ SkillConfig skillConfig = GetSkillConfig(id);
+ int itemCount = GetItemCountByID(PackType.Item, id);
+ if (skillConfig != null && itemCount > 0)
+ {
+ if (!itemUseTypeDict.ContainsKey(skillConfig.SkillTypeID))
+ {
+ itemUseTypeDict.Add(skillConfig.SkillTypeID, id);
+ }
+ else
+ {
+ SkillConfig preSkillConfig = GetSkillConfig(itemUseTypeDict[skillConfig.SkillTypeID]);
+ if (skillConfig.SkillLV > preSkillConfig.SkillLV)
+ {
+ itemUseTypeDict[skillConfig.SkillTypeID] = id;
+ }
+ }
+ }
+ }
+
+ private void UpdateDungeonDanUse()
+ {
+ int mapId = PlayerDatas.Instance.baseData.MapID;
+ int[] useDrugs = GetDrugIDListByDungeonID(mapId);
+ if (useDrugs == null) return;
+
+ for (int i = 0; i < useDrugs.Length; i++)
+ {
+ int id = useDrugs[i];
+ AddItemUseTypeDict(id);
+ }
+ }
+
+ private void UpdateDungeonUse()
+ {
+ int mapId = PlayerDatas.Instance.baseData.MapID;
+ if (!dungeonUseDict.ContainsKey(mapId)) return;
+
+ List<int> useIdlist = dungeonUseDict[mapId];
+ for (int i = 0; i < useIdlist.Count; i++)
+ {
+ int id = useIdlist[i];
+ AddItemUseTypeDict(id);
+ }
+ }
+
+ public SkillConfig GetSkillConfig(int itemId)
+ {
+ ItemConfig itemConfig = ItemConfig.Get(itemId);
+ SkillConfig skillConfig = SkillConfig.Get(itemConfig.AddSkill1);
+ return skillConfig;
+ }
+
+ public int GetDungeonIDByDrugID(int drugID)
+ {
+ int dungeonID = 0;
+ //DrugToDungeonDict.TryGetValue(drugID, out dungeonID);
+ return dungeonID;
+ }
+
+ public int[] GetDrugIDListByDungeonID(int dungeonID)
+ {
+ int[] drugIDlist = null;
+ DungeonToDrugDict.TryGetValue(dungeonID, out drugIDlist);
+ return drugIDlist;
+ }
+ #endregion
+
+ #region 鍒ゆ柇鐗╁搧鏄惁杈惧埌浣跨敤涓婇檺
+ // public bool IsReachUseLimit(string guid, out ulong count)
+ // {
+ // count = 0;
+ // ItemModel itemModel = GetItemByGuid(guid);
+ // if (itemModel == null) return false;
+
+ // AttrFruitConfig fruitConfig = AttrFruitConfig.Get(itemModel.itemId);
+ // int haveUseCnt = GetItemUsedTimesToday(itemModel.itemId);
+ // int sumHaveUseCnt = GetItemTotalUsedTimes(itemModel.itemId);
+ // count = (ulong)itemModel.count;
+ // bool isReach = false;
+ // int remainDayCnt = 0;
+ // if (itemModel.config.MaxSkillCnt > 0)
+ // {
+ // remainDayCnt = itemModel.config.MaxSkillCnt - haveUseCnt;
+ // if (itemModel.count > remainDayCnt)
+ // {
+ // count = (ulong)remainDayCnt;
+ // }
+ // }
+
+ // int remainSumCnt = 0;
+ // if (fruitConfig != null)
+ // {
+ // remainSumCnt = fruitConfig.basicUseLimit - sumHaveUseCnt;
+ // if (remainSumCnt <= remainDayCnt && itemModel.count > remainSumCnt)
+ // {
+ // count = (ulong)remainSumCnt;
+ // }
+ // }
+
+ // if (count < (ulong)itemModel.count)
+ // {
+ // isReach = true;
+ // }
+
+ // return isReach;
+ // }
+ #endregion
+
+ #region 鐗╁搧鍚炲櫖閫昏緫澶勭悊
+ public EquipColorType colorType { get; private set; }
+ public event Action<EquipColorType> RefreshColorSelectAct;
+ public event Action RefreshEquipDecomNumAct;
+ public int[] defaultUnSelectlist { get; private set; }
+
+ public int GetBetterEquipCount(List<ItemModel> itemModels)
+ {
+ if (itemModels.IsNullOrEmpty())
+ {
+ return 0;
+ }
+
+ var count = 0;
+ foreach (var item in itemModels)
+ {
+ if (ItemLogicUtility.Instance.IsFightUp(item.itemId, item.score) == 1)
+ {
+ count += item.count;
+ }
+ }
+ return count;
+ }
+
+ public void SetColorSelect(EquipColorType type)
+ {
+ colorType = type;
+
+ if (RefreshColorSelectAct != null)
+ {
+ RefreshColorSelectAct(type);
+ }
+ SendEquipDevourRecordQuest();
+ EquipDecomRedCtrl();
+ }
+
+ public List<int> devourPlacelist { get; private set; }
+ public int devourRedpointLevel { get; private set; }
+ public int minDevourEquipNum { get; private set; }
+ public void SetDevourEquipPlace()
+ {
+ devourPlacelist = new List<int>();
+ FuncConfigConfig funcConfig = FuncConfigConfig.Get("PetAbsorbType");
+ int[] placeArray = ConfigParse.GetMultipleStr<int>(funcConfig.Numerical1);
+ for (int i = 0; i < placeArray.Length; i++)
+ {
+ devourPlacelist.Add(placeArray[i]);
+ }
+ devourRedpointLevel = int.Parse(funcConfig.Numerical2);
+ minDevourEquipNum = int.Parse(funcConfig.Numerical3);
+ }
+
+ List<ItemModel> devourModellist = new List<ItemModel>();
+ List<ItemModel> orderDevourModellist = new List<ItemModel>();
+ public List<ItemModel> GetDevourModellist()
+ {
+ SinglePack singlePack = GetSinglePack(PackType.Item);
+ if (singlePack == null) return null;
+
+ devourModellist.Clear();
+ orderDevourModellist.Clear();
+ foreach (var model in singlePack.GetAllItems().Values)
+ {
+ if (model.config.Type == 29)
+ {
+ devourModellist.Add(model);
+ }
+ else
+ {
+ if (devourPlacelist.Contains(model.config.EquipPlace))
+ {
+ if (GeneralDefine.equipDecomposeScreen.Contains(model.config.ItemColor))
+ {
+ devourModellist.Add(model);
+ }
+ }
+ }
+
+ }
+ orderDevourModellist.AddRange(devourModellist);
+ orderDevourModellist.Sort(CompareByColor);
+ return orderDevourModellist;
+ }
+
+ public int CompareByColor(ItemModel start, ItemModel next)
+ {
+ bool typeX = start.config.Type == 29 ? true : false;
+ bool typeY = next.config.Type == 29 ? true : false;
+
+ if (typeX.CompareTo(typeY) != 0) return -typeX.CompareTo(typeY);
+
+ int colorX = start.config.ItemColor;
+ int colorY = next.config.ItemColor;
+ if (colorX.CompareTo(colorY) != 0) return colorX.CompareTo(colorY);
+
+ int startIndex = devourModellist.IndexOf(start);
+ int nextIndex = devourModellist.IndexOf(next);
+ if (startIndex.CompareTo(nextIndex) != 0) return startIndex.CompareTo(nextIndex);
+
+ return 0;
+ }
+
+ public List<ItemModel> GetCanDevourModellist()
+ {
+ List<ItemModel> canDevourModellist = new List<ItemModel>();
+ SinglePack singlePack = GetSinglePack(PackType.Item);
+ if (singlePack == null || colorType == EquipColorType.None)
+ {
+ if (RefreshEquipDecomNumAct != null)
+ {
+ RefreshEquipDecomNumAct();
+ }
+ return null;
+ }
+
+ foreach (var model in singlePack.GetAllItems().Values)
+ {
+ if (model.config.Type == 29)
+ {
+ if (!defaultUnSelectlist.Contains(model.itemId))
+ {
+ canDevourModellist.Add(model);
+ }
+ }
+ else
+ {
+ if (IsCanDevour(model))
+ {
+ canDevourModellist.Add(model);
+ }
+ }
+ }
+
+ if (RefreshEquipDecomNumAct != null)
+ {
+ RefreshEquipDecomNumAct();
+ }
+
+ return canDevourModellist;
+ }
+
+ public bool IsCanDevour(ItemModel model)
+ {
+ // if (devourPlacelist.Contains(model.config.EquipPlace))
+ // {
+ // if (GeneralDefine.equipDecomposeScreen.Contains(model.config.ItemColor))
+ // {
+ // var eatEquipConfig = PetEatEquipConfig.GetEquipColorAndEquipClass(model.config.ItemColor, model.config.LV);
+ // if (eatEquipConfig == null) return false;
+
+ // if (EquipControlConfig.Get(model.config.LV, 1).realm > PlayerDatas.Instance.baseData.realmLevel)
+ // {
+ // //bug锛氱帺瀹舵寕鏈轰細鎵撻珮澧冪晫鎬紝瀵艰嚧瑁呭鏃犳硶鍒嗚В鑳屽寘澶弧鐨勬儏鍐�
+ // //澧冪晫澶т簬鐜╁澧冪晫锛屼笖鍦ㄦ寚瀹氶鑹插搧璐ㄤ笅鐨勭洿鎺ュ垎瑙g传鑹蹭互涓嬭澶�
+ // if (model.config.ItemColor <= (int)colorType && model.config.ItemColor <= 3)
+ // {
+ // return true;
+ // }
+ // }
+
+ // //1. 闈炴媿鍗栬澶�
+ // //2. 瑁呭鍝佽川灏忎簬绛変簬褰撳墠閫夋嫨鐨勫搧璐�
+ // //3. 闈炴湰鑱屼笟鐨勫瑁呰澶�
+ // //4. 闈炴垬鏂楀姏鎻愬崌鐨勮澶�
+ // if (!model.isAuction && model.config.ItemColor <= (int)colorType
+ // && !(ItemLogicUtility.Instance.IsJobCompatibleItem(model.itemId)
+ // && model.config.ItemColor == 4 && model.config.SuiteiD != 0)
+ // && ItemLogicUtility.Instance.IsFightUp(model.itemId, model.score) != 1)
+ // {
+ // return true;
+ // }
+ // }
+ // }
+
+ return false;
+ }
+
+ public bool IsMaxDecomLv(int decomLv, out int realLv)
+ {
+ realLv = decomLv;
+ // var decomlist = EquipDeComposeConfig.GetValues();
+ // if (decomLv > decomlist[decomlist.Count - 1].LV)
+ // {
+ // realLv = decomlist[decomlist.Count - 1].LV;
+ // return true;
+ // }
+
+ return false;
+ }
+
+ public List<ItemModel> selectDevourlist = new List<ItemModel>();
+ public void GetSelectDevourList()
+ {
+ selectDevourlist.Clear();
+ List<ItemModel> itemModels = GetCanDevourModellist();
+ if (itemModels != null)
+ {
+ selectDevourlist.AddRange(itemModels);
+ }
+ }
+
+ public void RefreshGetNewItem(ItemModel model)
+ {
+ if (model == null) return;
+
+ if (CheckIsReachDevourCondi(model))
+ {
+ selectDevourlist.Add(model);
+ if (RefreshEquipDecomNumAct != null)
+ {
+ RefreshEquipDecomNumAct();
+ }
+ }
+ }
+
+ public void AddSelectDevourModellist(ItemModel model)
+ {
+ selectDevourlist.Add(model);
+ if (RefreshEquipDecomNumAct != null)
+ {
+ RefreshEquipDecomNumAct();
+ }
+ }
+
+ public bool CheckIsReachDevourCondi(ItemModel model)
+ {
+ if (model.config.Type == 29)
+ {
+ if (!defaultUnSelectlist.Contains(model.itemId))
+ {
+ return true;
+ }
+ return false;
+ }
+ else
+ {
+ if (IsCanDevour(model))
+ {
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+ public void RemoveSelectDevourModellist(ItemModel model)
+ {
+ if (selectDevourlist.Contains(model))
+ {
+ selectDevourlist.Remove(model);
+ }
+ if (RefreshEquipDecomNumAct != null)
+ {
+ RefreshEquipDecomNumAct();
+ }
+ }
+
+ public Dictionary<int, int> GetDecomAttrDictByLv(int decomLv)
+ {
+ if (decomposeAttrDict.ContainsKey(decomLv))
+ {
+ return decomposeAttrDict[decomLv];
+ }
+
+ return null;
+ }
+
+ public bool IsReachMinDecomposeNum()
+ {
+ List<ItemModel> itemModels = GetCanDevourModellist();
+ if (itemModels != null && itemModels.Count >= minDecomposeNum)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public void SendEquipdevourQuest(bool auto)
+ {
+ List<ItemModel> items = null;
+ if (auto)
+ {
+ items = GetCanDevourModellist();
+ }
+ else
+ {
+ items = selectDevourlist;
+ }
+
+ // if (items == null || items.Count < minDecomposeNum || !ItemLogicUtility.Instance.isPackResetOk || SettingEffectMgr.Instance.isStartDecompose) return;
+
+ // SettingEffectMgr.Instance.isStartDecompose = true;
+ // isAutoDecompose = auto;
+ // recordAutoDecomNum = Math.Min(items.Count, 100); //鍗曟鏈�澶�100浠跺垎瑙�
+ // var package = new CA32C_tagCMEquipDecompose();
+ // var indexLists = new ushort[recordAutoDecomNum];
+ // var idlist = new uint[recordAutoDecomNum];
+ // for (int i = 0; i < recordAutoDecomNum; i++)
+ // {
+ // indexLists[i] = (ushort)items[i].gridIndex;
+ // idlist[i] = (uint)items[i].itemId;
+ // if ((items[i].config.EquipPlace == 0 && items[i].config.Type != 29))
+ // {
+ // return;
+ // }
+ // }
+ // package.Count = (byte)indexLists.Length;
+ // package.IndexList = indexLists;
+ // package.ItemIDList = idlist;
+ // package.IsAuto = (byte)(auto ? 1 : 0);
+ // GameNetSystem.Instance.SendInfo(package);
+ }
+
+ public void SendEquipDevourRecordQuest()
+ {
+ var record = StringUtility.Contact((int)colorType + 1, 1, 1);
+ var decomSet = new CA32D_tagCMDecomposeSeting();
+ decomSet.Seting = uint.Parse(record);
+ GameNetSystem.Instance.SendInfo(decomSet);
+ }
+
+ public int decomposeLv { get; private set; }
+ public int decomposeExp { get; private set; }
+ public int decomposeProgress { get; private set; }
+ public int addDecomposeExp { get; private set; }
+ public int minDecomposeNum { get; private set; }
+ public bool isAutoDecompose { get; set; }
+ public int recordAutoDecomNum { get; private set; }
+ public DecomposeGetMatInfo[] getItems { get; private set; }
+
+ public event Action RefreshDecomAttrAct;
+ // public void GetServerDecomposeSet(HA31C_tagMCEquipDecomposeInfo info)
+ // {
+ // addDecomposeExp = 0;
+ // int realLv = info.LV + 1;
+ // bool isMax = IsMaxDecomLv(realLv, out realLv);
+ // if (realLv == decomposeLv)
+ // {
+ // addDecomposeExp = (int)info.Exp - decomposeExp;
+ // }
+ // else
+ // {
+ // for (int i = decomposeLv; i <= realLv; i++)
+ // {
+ // var deComposeConfig = EquipDeComposeConfig.Get(i);
+ // if (i == decomposeLv)
+ // {
+ // addDecomposeExp = deComposeConfig.UpNeedExp - decomposeExp;
+ // }
+ // else if (i == realLv)
+ // {
+ // addDecomposeExp += (int)info.Exp;
+ // }
+ // else
+ // {
+ // addDecomposeExp += deComposeConfig.UpNeedExp;
+ // }
+ // }
+ // }
+
+ // decomposeLv = realLv;
+ // decomposeExp = (int)info.Exp;
+ // decomposeProgress = info.DecomposeCnt;
+ // getItems = JsonMapper.ToObject<DecomposeGetMatInfo[]>(info.GetItemData);
+
+ // if (info.Seting != 0)
+ // {
+ // string decomSetStr = info.Seting.ToString();
+ // string colorStr = decomSetStr.Substring(0, 1);
+ // colorType = (EquipColorType)(int.Parse(colorStr) - 1);
+ // string lvStr = decomSetStr.Substring(1, decomSetStr.Length - 2);
+ // }
+ // if (RefreshDecomAttrAct != null)
+ // {
+ // RefreshDecomAttrAct();
+ // }
+ // }
+ /// <summary>
+ /// 璁剧疆鑾峰緱鐐间腹鏉愭枡鐨勫睍绀烘暟鎹�
+ /// </summary>
+ /// <param name="getMatInfos"></param>
+ /// <returns></returns>
+ private List<DecomposeGetMatInfo> getMatInfos = new List<DecomposeGetMatInfo>();
+ public List<DecomposeGetMatInfo> SetShowMatInfo()
+ {
+ getMatInfos.Clear();
+ int sumMatCnt = 0;
+ if (getItems != null)
+ {
+ for (int i = 0; i < getItems.Length; i++)
+ {
+ if (getItems[i].Count > 0)
+ {
+ sumMatCnt += getItems[i].Count;
+ }
+ else
+ {
+ sumMatCnt += 1;
+ }
+ }
+ }
+
+ if (sumMatCnt > 5)
+ {
+ for (int i = 0; i < getItems.Length; i++)
+ {
+ getMatInfos.Add(getItems[i]);
+ }
+ }
+ else
+ {
+ if (getItems != null)
+ {
+ for (int i = 0; i < getItems.Length; i++)
+ {
+ //if (getItems[i].Count > 0)
+ //{
+ // for (int j = 0; j < getItems[i].Count; j++)
+ // {
+ // DecomposeGetMatInfo matInfo = new DecomposeGetMatInfo();
+ // matInfo.ItemID = getItems[i].ItemID;
+ // matInfo.Count = 1;
+ // matInfo.IsSuite = getItems[i].IsSuite;
+ // matInfo.UserData = getItems[i].UserData;
+ // getMatInfos.Add(matInfo);
+ // }
+ //}
+ //else
+ {
+ getMatInfos.Add(getItems[i]);
+ }
+ }
+ }
+ }
+ return getMatInfos;
+ }
+
+ public enum EquipColorType
+ {
+ None = 0,
+ White = 1,
+ Blue = 2,
+ Purple = 3,
+ Orange = 4,
+ Red = 5,
+ //鍚庣画IL寮�鍙戞坊鍔犻璁�
+ default1,
+ default2,
+ default3,
+ default4,
+ All = 10,
+ }
+
+ public class DecomposeGetMatInfo
+ {
+ public int ItemID;
+ public int Count;
+ public int IsSuite;
+ public string UserData;
+ }
+ #endregion
+
+ #region 涓硅嵂閫昏緫澶勭悊
+
+ // private int CompareMakeDrug(AttrFruitConfig start, AttrFruitConfig end)
+ // {
+ // ItemConfig configS = ItemConfig.Get(start.ID);
+ // ItemConfig configE = ItemConfig.Get(end.ID);
+ // if (configS.RealmLimit.CompareTo(configE.RealmLimit) != 0)
+ // {
+ // return configS.RealmLimit.CompareTo(configE.RealmLimit);
+ // }
+ // if (configS.LV.CompareTo(configE.LV) != 0)
+ // {
+ // return configS.LV.CompareTo(configE.LV);
+ // }
+
+ // int x = makeDruglist.IndexOf(start);
+ // int y = makeDruglist.IndexOf(end);
+ // if (x.CompareTo(y) != 0) x.CompareTo(y);
+
+ // return 0;
+ // }
+
+ // List<AttrFruitConfig> drugOrderlist = new List<AttrFruitConfig>();
+ // List<AttrFruitConfig> haveDruglist = new List<AttrFruitConfig>();
+ // public List<AttrFruitConfig> GetDrugOrderByCnt()
+ // {
+ // drugOrderlist.Clear();
+ // haveDruglist.Clear();
+ // drugOrderlist.AddRange(makeDruglist);
+ // drugOrderlist.Sort(CompareByIsHave);
+ // for (int i = 0; i < drugOrderlist.Count; i++)
+ // {
+ // if (IsHaveDrugUse(drugOrderlist[i]))
+ // {
+ // haveDruglist.Add(drugOrderlist[i]);
+ // }
+ // }
+ // haveDruglist.Sort(CompareMakeDrug);
+ // for (int i = 0; i < haveDruglist.Count; i++)
+ // {
+ // drugOrderlist[i] = haveDruglist[i];
+ // }
+
+ // return drugOrderlist;
+ // }
+
+ public bool CheckIsDrugById(int itemId)
+ {
+ // for (int i = 0; i < makeDruglist.Count; i++)
+ // {
+ // if (makeDruglist[i].ID == itemId)
+ // {
+ // return true;
+ // }
+ // }
+ return false;
+ }
+
+ // public int CompareByIsHave(AttrFruitConfig start, AttrFruitConfig end)
+ // {
+ // bool isHaveStart = IsHaveDrugUse(start);
+ // bool isHaveEnd = IsHaveDrugUse(end);
+ // if (isHaveStart.CompareTo(isHaveEnd) != 0) return -isHaveStart.CompareTo(isHaveEnd);
+
+ // //isHaveStart = IsHaveDrugRecycle(start);
+ // //isHaveEnd = IsHaveDrugRecycle(end);
+ // //if (isHaveStart.CompareTo(isHaveEnd) != 0) return -isHaveStart.CompareTo(isHaveEnd);
+
+ // isHaveStart = GetItemCountByID(PackType.Item, start.ID) > 0 ? true : false;
+ // isHaveEnd = GetItemCountByID(PackType.Item, end.ID) > 0 ? true : false;
+ // if (isHaveStart.CompareTo(isHaveEnd) != 0) return isHaveStart.CompareTo(isHaveEnd);
+
+ // isHaveStart = IsReachMaxUseDrug(start);
+ // isHaveEnd = IsReachMaxUseDrug(end);
+ // if (isHaveStart.CompareTo(isHaveEnd) != 0) return isHaveStart.CompareTo(isHaveEnd);
+
+ // int x = makeDruglist.IndexOf(start);
+ // int y = makeDruglist.IndexOf(end);
+ // if (x.CompareTo(y) != 0) return x.CompareTo(y);
+ // return 0;
+ // }
+
+ // public bool IsHaveDrugUse(AttrFruitConfig fruitConfig)
+ // {
+ // if (!IsReachMaxUseDrug(fruitConfig))
+ // {
+ // return GetItemCountByID(PackType.Item, fruitConfig.ID) > 0 ? true : false;
+ // }
+
+ // return false;
+ // }
+
+ // public bool IsHaveDrugRecycle(AttrFruitConfig fruitConfig)
+ // {
+ // if (IsReachMaxUseDrug(fruitConfig))
+ // {
+ // return GetItemCountByID(PackType.Item, fruitConfig.ID) > 0 ? true : false;
+ // }
+ // return false;
+ // }
+
+ // public bool IsReachMaxUseDrug(AttrFruitConfig fruitConfig)
+ // {
+ // if (fruitConfig == null)
+ // {
+ // return false;
+ // }
+
+ // if (fruitConfig.FuncID == 2)
+ // {
+ // AlchemyDrugUseLimit drugUseLimit;
+ // if (alchemyModel.TryGetAlchemyUseLimit(fruitConfig.ID, out drugUseLimit))
+ // {
+ // return drugUseLimit.IsReachLimit();
+ // }
+ // }
+
+ // int useNum = GetItemTotalUsedTimes(fruitConfig.ID);
+ // if (useNum >= fruitConfig.basicUseLimit)
+ // {
+ // return true;
+ // }
+ // return false;
+ // }
+ #endregion
+
+ //鑾峰彇鑳屽寘涓殑涓�浠跺彲鎷嶅崠鐗╁搧 浼樺厛鍏朵粬鑱屼笟
+ public string GetAuctionEquip()
+ {
+ var itemPackage = GetSinglePack(PackType.Item);
+ var allItems = itemPackage.GetAllItems();
+
+ var guid = string.Empty;
+ List<string> guidList = new List<string>();
+ foreach (var item in allItems.Values)
+ {
+ var isAuction = item.isAuction;
+ if (isAuction && ItemLogicUtility.Instance.IsRealmEquip(item.itemId))
+ {
+ if (!ItemLogicUtility.Instance.IsJobCompatibleItem(item.itemId))
+ {
+ return item.guid;
+ }
+ else
+ {
+ if (guid != string.Empty)
+ continue;
+ guid = item.guid;
+ }
+ }
+ }
+ return guid;
+ }
+
+
+ public void ReceiveAwardNotify(HA801_tagMCGiveAwardInfo netPack)
+ {
+ var eventName = UIHelper.ServerStringTrim(netPack.EventName);
+ if (eventName == "BuyItem")
+ return;
+
+ // 浠欑洘鏀诲煄鎴�
+ // if (eventName == "FamilyGCZSQGrid" || eventName == "FamilyGCZSQPass" || eventName == "FamilyGCZSQPassAll" ||
+ // eventName == "FamilyGCZContiribution" || eventName == "FamilyGCZAtk")
+ // {
+ // ModelCenter.Instance.GetModel<FairySiegeActModel>()?.OnUpdateAwardInfoAction(netPack);
+ // return;
+ // }
+ if (!commonShowAwardEvents.Contains(eventName))
+ return;
+
+ List<Item> showItems = new List<Item>();
+
+ if (netPack.Exp != 0 || netPack.ExpPoint != 0)
+ {
+ ulong expValue = netPack.Exp + netPack.ExpPoint * (ulong)Constants.ExpPointValue;
+ showItems.Add(new Item(GeneralDefine.expDisplayId, expValue));
+ }
+ if (netPack.MoneyList.Length != 0)
+ {
+ for (int i = 0; i < netPack.MoneyLen; i++)
+ {
+ var moneyType = netPack.MoneyList[i].MoneyType;
+ if (GeneralDefine.moneyDisplayIds.ContainsKey(moneyType) && netPack.MoneyList[i].MoneyValue != 0)
+ {
+ showItems.Add(new Item(GeneralDefine.moneyDisplayIds[moneyType], netPack.MoneyList[i].MoneyValue));
+ }
+
+ }
+ }
+
+ if (netPack.ItemList.Length != 0)
+ {
+ for (int i = 0; i < netPack.ItemLen; i++)
+ {
+ showItems.Add(new Item((int)netPack.ItemList[i].ItemID, netPack.ItemList[i].Count, netPack.ItemList[i].IsBind));
+ }
+ }
+
+
+ string info = string.Empty;
+ if (LanguageConfig.HasKey("commonShowAwardEvents_" + eventName))
+ info = Language.Get("commonShowAwardEvents_" + eventName);
+
+ if (showItems.Count == 0)
+ return;
+
+ ItemLogicUtility.Instance.ShowGetItem(showItems, info, 0, eventName: eventName);
+ }
+ }
diff --git a/Main/Manager/GameSystemManager/PackManager.cs.meta b/Main/System/KnapSack/PackManager.cs.meta
similarity index 100%
rename from Main/Manager/GameSystemManager/PackManager.cs.meta
rename to Main/System/KnapSack/PackManager.cs.meta
diff --git a/Main/Manager/GameSystemManager/VirtualPackManager.cs b/Main/System/KnapSack/VirtualPackManager.cs
similarity index 99%
rename from Main/Manager/GameSystemManager/VirtualPackManager.cs
rename to Main/System/KnapSack/VirtualPackManager.cs
index 8e17701..70e23e9 100644
--- a/Main/Manager/GameSystemManager/VirtualPackManager.cs
+++ b/Main/System/KnapSack/VirtualPackManager.cs
@@ -1,363 +1,363 @@
-锘縰sing System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-using UnityEngine;
-namespace vnxbqy.UI
-{
-
- public class VirtualPackManager : GameSystemManager<VirtualPackManager>
- {
- Dictionary<PackType, List<VirtualPackItem>> virtualPackItems
- = new Dictionary<PackType, List<VirtualPackItem>>();
- Dictionary<PackType, ObjectPool<VirtualPackItem>> m_VirtualItemPool
- = new Dictionary<PackType, ObjectPool<VirtualPackItem>>();
- Dictionary<PackType, int> virtualPackCapacityDict = new Dictionary<PackType, int>();
-
- public event Action<PackType> virtualPackRefresh;
- int getA206Count = 0; //鏀跺埌浜嗗嚑娆206鍖�
- bool isFrist = false; //鏄笉鏄涓�娆¤幏寰楄仛榄傜鐗�
- Dictionary<int, int> noPackItemCountDict = new Dictionary<int, int>(); //鏃犻渶鑳屽寘鐨勭墿鍝佹暟閲忓埛鏂帮紝鑷姩杞寲涓烘暟鍊�
- public event Action OnNoPackItemCountRefresh;
-
- public void OnBeforePlayerDataInitialize()
- {
- foreach (var packType in virtualPackItems.Keys)
- {
- var pool = m_VirtualItemPool[packType];
- var items = virtualPackItems[packType];
- foreach (var item in items)
- {
- pool.Release(item);
- }
- }
- virtualPackItems.Clear();
- noPackItemCountDict.Clear();
- getA206Count = 0;
- isFrist = false;
- }
-
- public void OnPlayerLoginOk()
- {
- isFrist = noPackItemCountDict.Count == 0;
- }
-
- public override void Init()
- {
- base.Init();
- ParseConfig();
- m_VirtualItemPool.Add(PackType.GatherSoul, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem));
- m_VirtualItemPool.Add(PackType.RunePack, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem));
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
- DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
- }
-
- public override void Release()
- {
- base.Release();
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
- DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
- }
-
- void ParseConfig()
- {
- var funcConfig = FuncConfigConfig.Get("RunePackageNum");
- virtualPackCapacityDict.Add(PackType.RunePack, int.Parse(funcConfig.Numerical1));
- }
-
- public bool IsVirtualPack(PackType packType)
- {
- switch (packType)
- {
- case PackType.GatherSoul:
- case PackType.RunePack:
- return true;
- }
- return false;
- }
-
- public int GetPackCapacity(PackType packType)
- {
- if (virtualPackCapacityDict.ContainsKey(packType))
- {
- return virtualPackCapacityDict[packType];
- }
- return 0;
- }
-
- public int GetPackRemainCount(PackType packType)
- {
- var capacity = GetPackCapacity(packType);
- return capacity - GetPackItemCount(packType);
- }
-
- public int GetPackItemCount(PackType packType)
- {
- if (virtualPackItems.ContainsKey(packType))
- {
- return virtualPackItems[packType].Count;
- }
- return 0;
- }
-
- public int GetItemCountById(PackType packType, int id)
- {
- var count = 0;
- List<int> list;
- if (TryGetItems(packType, out list))
- {
- for (int i = 0; i < list.Count; i++)
- {
- VirtualPackItem item;
- if (TryGetItem(packType, list[i], out item)
- && item.id == id)
- {
- count++;
- }
- }
- }
- return count;
- }
-
- public void GetItemIndexs(PackType packType, ref List<int> list)
- {
- list.Clear();
- List<VirtualPackItem> _list;
- if (virtualPackItems.TryGetValue(packType, out _list))
- {
- for (int i = 0; i < _list.Count; i++)
- {
- list.Add(_list[i].index);
- }
- }
- }
-
- public bool TryGetItems(PackType packType, out List<int> list)
- {
- list = new List<int>();
- List<VirtualPackItem> _list;
- if (virtualPackItems.TryGetValue(packType, out _list))
- {
- for (int i = 0; i < _list.Count; i++)
- {
- list.Add(_list[i].index);
- }
- return true;
- }
- return false;
- }
-
- public bool TryGetItem<T>(PackType packType, int packIndex, out T item) where T : VirtualPackItem
- {
- item = default(T);
- if (virtualPackItems.ContainsKey(packType))
- {
- var _index = virtualPackItems[packType].FindIndex((x) =>
- {
- return x.index == packIndex;
- });
- if (_index != -1)
- {
- item = virtualPackItems[packType][_index] as T;
- }
- return _index != -1;
- }
- return false;
- }
-
- public void OnReceiveServerPack(HA204_tagMCVPackRefresh package)
- {
- var packType = (PackType)package.PackType;
- if (!IsVirtualPack(packType))
- {
- return;
- }
- List<VirtualPackItem> list;
- if (!virtualPackItems.TryGetValue(packType, out list))
- {
- list = new List<VirtualPackItem>();
- virtualPackItems.Add(packType, list);
- }
- SetVirtualItem(packType, ref list, package.VPacklItemList);
- if (virtualPackRefresh != null)
- {
- virtualPackRefresh((PackType)package.PackType);
- }
-
- }
-
- public void OnReceiveServerPack(HA205_tagMCVPackClear package)
- {
- var packType = (PackType)package.PackType;
- if (!IsVirtualPack(packType))
- {
- return;
- }
- List<VirtualPackItem> list;
- if (virtualPackItems.TryGetValue(packType, out list))
- {
- var pool = m_VirtualItemPool[packType];
- for (int i = 0; i < package.Count; i++)
- {
- var index = package.ItemPlaceList[i];
- var items = list.FindAll((x) =>
- {
- return x.index == index;
- });
- foreach (var item in items)
- {
- list.Remove(item);
- pool.Release(item);
- }
- }
- if (virtualPackRefresh != null)
- {
- virtualPackRefresh(packType);
- }
- }
- }
-
-
- public void UpdateAutoItemCountRefresh(HA206_tagMCAutoItemCountRefresh netPack)
- {
-
- ShowRewardWin(netPack);//vNetData涓璉temCount浼犵殑鏄鐗囨�绘暟锛岄渶瑕佸湪noPackItemCountDict鍐欏叆鏁版嵁涔嬪墠璁$畻宸��
- for (int i = 0; i < netPack.Count; i++)
- {
- noPackItemCountDict[(int)netPack.ItemCountList[i].ItemID] = (int)netPack.ItemCountList[i].ItemCount;
- }
- OnNoPackItemCountRefresh?.Invoke();
- }
-
- void ShowRewardWin(HA206_tagMCAutoItemCountRefresh vNetData)
- {
- getA206Count += 1;
- if (ItemLogicUtility.Instance.hidePickItem)
- return;
- // if (ModelCenter.Instance.GetModel<GatheringSoulModel>().isOpenXBWin)
- // return;
- if (getA206Count <= 1 && !isFrist)
- return;
-
- for (int i = 0; i < vNetData.ItemCountList.Length; i++)
- {
- int itemID = (int)vNetData.ItemCountList[i].ItemID;
- int itemCount = (int)vNetData.ItemCountList[i].ItemCount;
- if (noPackItemCountDict.ContainsKey(itemID) && noPackItemCountDict[itemID] > itemCount)
- return;
- ItemLogicUtility.Instance.RefreshPickItem(PackType.Item, itemID.ToString());
- }
- }
-
-
- public int GetNoPackItemCount(int id)
- {
- if (noPackItemCountDict.ContainsKey(id))
- {
- return noPackItemCountDict[id];
- }
- return 0;
- }
-
- public Dictionary<int, int> GetAllNoPackItem()
- {
- return noPackItemCountDict;
- }
-
-
-
- void SetVirtualItem(PackType packType, ref List<VirtualPackItem> list, HA204_tagMCVPackRefresh.tagMCVPackItem[] items)
- {
- var pool = m_VirtualItemPool[packType];
- for (int i = 0; i < items.Length; i++)
- {
- var item = list.Find((x) =>
- {
- return x.index == items[i].ItemPlace;
- });
- if (item != null)
- {
- item.Release();
- }
- else
- {
- if (pool.inactivedCount > 0)
- {
- item = pool.Get();
- list.Add(item);
- }
- }
- if (item == null)
- {
- item = VirtualPackItem.Get(packType);
- list.Add(item);
- }
- item.ParsePackItem(items[i].ItemPlace, items[i].ItemData);
-
- ItemLogicUtility.Instance.RefreshPickItem(packType, item.id.ToString());
- }
- }
-
- static void OnGetItem(VirtualPackItem item)
- {
-
- }
-
- static void OnReleaseItem(VirtualPackItem item)
- {
- item.Release();
- }
- }
-
- public abstract class VirtualPackItem
- {
- public int index { get; private set; }
-
- public int id { get; private set; }
-
- public int level { get; private set; }
-
- protected string dataString { get; set; }
-
- protected static StringBuilder sb = new StringBuilder();
-
- public virtual void ParsePackItem(int index, uint data)
- {
- this.index = index;
-
- dataString = data.ToString();
- int delta = 10 - dataString.Length;
- sb.Length = 0;
- sb.Append('0', delta);
- dataString = dataString.Insert(0, sb.ToString());
-
- id = int.Parse(dataString.Substring(5, 5));
- level = int.Parse(dataString.Substring(2, 3)) + 1;
- }
-
- public virtual void Release()
- {
- dataString = null;
- }
-
- public static VirtualPackItem Get(PackType packType)
- {
- // switch (packType)
- // {
- // case PackType.RunePack:
- // return new RuneItem();
- // }
- return null;
- }
- }
-
- public struct VirtualItem
- {
- public PackType packType;
- public int itemId;
- public int index;
- public int level;
- }
-}
-
+锘縰sing System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+
+using UnityEngine;
+namespace vnxbqy.UI
+{
+
+ public class VirtualPackManager : GameSystemManager<VirtualPackManager>
+ {
+ Dictionary<PackType, List<VirtualPackItem>> virtualPackItems
+ = new Dictionary<PackType, List<VirtualPackItem>>();
+ Dictionary<PackType, ObjectPool<VirtualPackItem>> m_VirtualItemPool
+ = new Dictionary<PackType, ObjectPool<VirtualPackItem>>();
+ Dictionary<PackType, int> virtualPackCapacityDict = new Dictionary<PackType, int>();
+
+ public event Action<PackType> virtualPackRefresh;
+ int getA206Count = 0; //鏀跺埌浜嗗嚑娆206鍖�
+ bool isFrist = false; //鏄笉鏄涓�娆¤幏寰楄仛榄傜鐗�
+ Dictionary<int, int> noPackItemCountDict = new Dictionary<int, int>(); //鏃犻渶鑳屽寘鐨勭墿鍝佹暟閲忓埛鏂帮紝鑷姩杞寲涓烘暟鍊�
+ public event Action OnNoPackItemCountRefresh;
+
+ public void OnBeforePlayerDataInitialize()
+ {
+ foreach (var packType in virtualPackItems.Keys)
+ {
+ var pool = m_VirtualItemPool[packType];
+ var items = virtualPackItems[packType];
+ foreach (var item in items)
+ {
+ pool.Release(item);
+ }
+ }
+ virtualPackItems.Clear();
+ noPackItemCountDict.Clear();
+ getA206Count = 0;
+ isFrist = false;
+ }
+
+ public void OnPlayerLoginOk()
+ {
+ isFrist = noPackItemCountDict.Count == 0;
+ }
+
+ public override void Init()
+ {
+ base.Init();
+ ParseConfig();
+ m_VirtualItemPool.Add(PackType.GatherSoul, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem));
+ m_VirtualItemPool.Add(PackType.RunePack, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem));
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
+ DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
+ }
+
+ public override void Release()
+ {
+ base.Release();
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
+ DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
+ }
+
+ void ParseConfig()
+ {
+ var funcConfig = FuncConfigConfig.Get("RunePackageNum");
+ virtualPackCapacityDict.Add(PackType.RunePack, int.Parse(funcConfig.Numerical1));
+ }
+
+ public bool IsVirtualPack(PackType packType)
+ {
+ switch (packType)
+ {
+ case PackType.GatherSoul:
+ case PackType.RunePack:
+ return true;
+ }
+ return false;
+ }
+
+ public int GetPackCapacity(PackType packType)
+ {
+ if (virtualPackCapacityDict.ContainsKey(packType))
+ {
+ return virtualPackCapacityDict[packType];
+ }
+ return 0;
+ }
+
+ public int GetPackRemainCount(PackType packType)
+ {
+ var capacity = GetPackCapacity(packType);
+ return capacity - GetPackItemCount(packType);
+ }
+
+ public int GetPackItemCount(PackType packType)
+ {
+ if (virtualPackItems.ContainsKey(packType))
+ {
+ return virtualPackItems[packType].Count;
+ }
+ return 0;
+ }
+
+ public int GetItemCountById(PackType packType, int id)
+ {
+ var count = 0;
+ List<int> list;
+ if (TryGetItems(packType, out list))
+ {
+ for (int i = 0; i < list.Count; i++)
+ {
+ VirtualPackItem item;
+ if (TryGetItem(packType, list[i], out item)
+ && item.id == id)
+ {
+ count++;
+ }
+ }
+ }
+ return count;
+ }
+
+ public void GetItemIndexs(PackType packType, ref List<int> list)
+ {
+ list.Clear();
+ List<VirtualPackItem> _list;
+ if (virtualPackItems.TryGetValue(packType, out _list))
+ {
+ for (int i = 0; i < _list.Count; i++)
+ {
+ list.Add(_list[i].index);
+ }
+ }
+ }
+
+ public bool TryGetItems(PackType packType, out List<int> list)
+ {
+ list = new List<int>();
+ List<VirtualPackItem> _list;
+ if (virtualPackItems.TryGetValue(packType, out _list))
+ {
+ for (int i = 0; i < _list.Count; i++)
+ {
+ list.Add(_list[i].index);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public bool TryGetItem<T>(PackType packType, int packIndex, out T item) where T : VirtualPackItem
+ {
+ item = default(T);
+ if (virtualPackItems.ContainsKey(packType))
+ {
+ var _index = virtualPackItems[packType].FindIndex((x) =>
+ {
+ return x.index == packIndex;
+ });
+ if (_index != -1)
+ {
+ item = virtualPackItems[packType][_index] as T;
+ }
+ return _index != -1;
+ }
+ return false;
+ }
+
+ public void OnReceiveServerPack(HA204_tagMCVPackRefresh package)
+ {
+ var packType = (PackType)package.PackType;
+ if (!IsVirtualPack(packType))
+ {
+ return;
+ }
+ List<VirtualPackItem> list;
+ if (!virtualPackItems.TryGetValue(packType, out list))
+ {
+ list = new List<VirtualPackItem>();
+ virtualPackItems.Add(packType, list);
+ }
+ SetVirtualItem(packType, ref list, package.VPacklItemList);
+ if (virtualPackRefresh != null)
+ {
+ virtualPackRefresh((PackType)package.PackType);
+ }
+
+ }
+
+ public void OnReceiveServerPack(HA205_tagMCVPackClear package)
+ {
+ var packType = (PackType)package.PackType;
+ if (!IsVirtualPack(packType))
+ {
+ return;
+ }
+ List<VirtualPackItem> list;
+ if (virtualPackItems.TryGetValue(packType, out list))
+ {
+ var pool = m_VirtualItemPool[packType];
+ for (int i = 0; i < package.Count; i++)
+ {
+ var index = package.ItemPlaceList[i];
+ var items = list.FindAll((x) =>
+ {
+ return x.index == index;
+ });
+ foreach (var item in items)
+ {
+ list.Remove(item);
+ pool.Release(item);
+ }
+ }
+ if (virtualPackRefresh != null)
+ {
+ virtualPackRefresh(packType);
+ }
+ }
+ }
+
+
+ public void UpdateAutoItemCountRefresh(HA206_tagMCAutoItemCountRefresh netPack)
+ {
+
+ ShowRewardWin(netPack);//vNetData涓璉temCount浼犵殑鏄鐗囨�绘暟锛岄渶瑕佸湪noPackItemCountDict鍐欏叆鏁版嵁涔嬪墠璁$畻宸��
+ for (int i = 0; i < netPack.Count; i++)
+ {
+ noPackItemCountDict[(int)netPack.ItemCountList[i].ItemID] = (int)netPack.ItemCountList[i].ItemCount;
+ }
+ OnNoPackItemCountRefresh?.Invoke();
+ }
+
+ void ShowRewardWin(HA206_tagMCAutoItemCountRefresh vNetData)
+ {
+ getA206Count += 1;
+ if (ItemLogicUtility.Instance.hidePickItem)
+ return;
+ // if (ModelCenter.Instance.GetModel<GatheringSoulModel>().isOpenXBWin)
+ // return;
+ if (getA206Count <= 1 && !isFrist)
+ return;
+
+ for (int i = 0; i < vNetData.ItemCountList.Length; i++)
+ {
+ int itemID = (int)vNetData.ItemCountList[i].ItemID;
+ int itemCount = (int)vNetData.ItemCountList[i].ItemCount;
+ if (noPackItemCountDict.ContainsKey(itemID) && noPackItemCountDict[itemID] > itemCount)
+ return;
+ ItemLogicUtility.Instance.RefreshPickItem(PackType.Item, itemID.ToString());
+ }
+ }
+
+
+ public int GetNoPackItemCount(int id)
+ {
+ if (noPackItemCountDict.ContainsKey(id))
+ {
+ return noPackItemCountDict[id];
+ }
+ return 0;
+ }
+
+ public Dictionary<int, int> GetAllNoPackItem()
+ {
+ return noPackItemCountDict;
+ }
+
+
+
+ void SetVirtualItem(PackType packType, ref List<VirtualPackItem> list, HA204_tagMCVPackRefresh.tagMCVPackItem[] items)
+ {
+ var pool = m_VirtualItemPool[packType];
+ for (int i = 0; i < items.Length; i++)
+ {
+ var item = list.Find((x) =>
+ {
+ return x.index == items[i].ItemPlace;
+ });
+ if (item != null)
+ {
+ item.Release();
+ }
+ else
+ {
+ if (pool.inactivedCount > 0)
+ {
+ item = pool.Get();
+ list.Add(item);
+ }
+ }
+ if (item == null)
+ {
+ item = VirtualPackItem.Get(packType);
+ list.Add(item);
+ }
+ item.ParsePackItem(items[i].ItemPlace, items[i].ItemData);
+
+ ItemLogicUtility.Instance.RefreshPickItem(packType, item.id.ToString());
+ }
+ }
+
+ static void OnGetItem(VirtualPackItem item)
+ {
+
+ }
+
+ static void OnReleaseItem(VirtualPackItem item)
+ {
+ item.Release();
+ }
+ }
+
+ public abstract class VirtualPackItem
+ {
+ public int index { get; private set; }
+
+ public int id { get; private set; }
+
+ public int level { get; private set; }
+
+ protected string dataString { get; set; }
+
+ protected static StringBuilder sb = new StringBuilder();
+
+ public virtual void ParsePackItem(int index, uint data)
+ {
+ this.index = index;
+
+ dataString = data.ToString();
+ int delta = 10 - dataString.Length;
+ sb.Length = 0;
+ sb.Append('0', delta);
+ dataString = dataString.Insert(0, sb.ToString());
+
+ id = int.Parse(dataString.Substring(5, 5));
+ level = int.Parse(dataString.Substring(2, 3)) + 1;
+ }
+
+ public virtual void Release()
+ {
+ dataString = null;
+ }
+
+ public static VirtualPackItem Get(PackType packType)
+ {
+ // switch (packType)
+ // {
+ // case PackType.RunePack:
+ // return new RuneItem();
+ // }
+ return null;
+ }
+ }
+
+ public struct VirtualItem
+ {
+ public PackType packType;
+ public int itemId;
+ public int index;
+ public int level;
+ }
+}
+
diff --git a/Main/Manager/GameSystemManager/VirtualPackManager.cs.meta b/Main/System/KnapSack/VirtualPackManager.cs.meta
similarity index 100%
rename from Main/Manager/GameSystemManager/VirtualPackManager.cs.meta
rename to Main/System/KnapSack/VirtualPackManager.cs.meta
diff --git a/Main/UI/LoadingWin.cs b/Main/System/Launch/LoadingWin.cs
similarity index 99%
rename from Main/UI/LoadingWin.cs
rename to Main/System/Launch/LoadingWin.cs
index a56b318..c880bb3 100644
--- a/Main/UI/LoadingWin.cs
+++ b/Main/System/Launch/LoadingWin.cs
@@ -1,73 +1,73 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.UI;
-
-public class LoadingWin : UIBase
-{
- protected int currentProgress = 0;
- protected int targetProgress = 0;
-
- protected Text titleText;
- protected Text tipsText;
- protected Image progressBar;
- protected Text progressText;
-
- protected override void InitComponent()
- {
- base.InitComponent();
- titleText = transform.Find("Text_Loading").GetComponent<Text>();
- tipsText = transform.Find("Text_Tips").GetComponent<Text>();
- progressBar = transform.Find("Img_Progress/Img_Foreground").GetComponent<Image>();
- progressText = transform.Find("Text_Progress").GetComponent<Text>();
- }
-
- protected override void OnPreOpen()
- {
- base.OnPreOpen();
- currentProgress = targetProgress = 0;
- Refresh();
- }
-
- protected override void OnPreClose()
- {
- base.OnPreClose();
- }
-
- public override void Refresh()
- {
- base.Refresh();
- UpdateProgress();
- }
-
- public void SetProgress(float value, bool directly = false)
- {
- if (directly)
- {
- currentProgress = targetProgress = (int)(value * 100);
- UpdateProgress();
- }
- else
- {
- currentProgress = (int)(value * 100);
- }
-
-
- }
-
- protected void UpdateProgress()
- {
- progressText.text = currentProgress + "%";
- progressBar.fillAmount = currentProgress / 100f;
- }
-
- protected void Update()
- {
- if (currentProgress < targetProgress)
- {
- currentProgress = (int)Mathf.Lerp(currentProgress, targetProgress, 0.1f);
- UpdateProgress();
- }
- }
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class LoadingWin : UIBase
+{
+ protected int currentProgress = 0;
+ protected int targetProgress = 0;
+
+ protected Text titleText;
+ protected Text tipsText;
+ protected Image progressBar;
+ protected Text progressText;
+
+ protected override void InitComponent()
+ {
+ base.InitComponent();
+ titleText = transform.Find("Text_Loading").GetComponent<Text>();
+ tipsText = transform.Find("Text_Tips").GetComponent<Text>();
+ progressBar = transform.Find("Img_Progress/Img_Foreground").GetComponent<Image>();
+ progressText = transform.Find("Text_Progress").GetComponent<Text>();
+ }
+
+ protected override void OnPreOpen()
+ {
+ base.OnPreOpen();
+ currentProgress = targetProgress = 0;
+ Refresh();
+ }
+
+ protected override void OnPreClose()
+ {
+ base.OnPreClose();
+ }
+
+ public override void Refresh()
+ {
+ base.Refresh();
+ UpdateProgress();
+ }
+
+ public void SetProgress(float value, bool directly = false)
+ {
+ if (directly)
+ {
+ currentProgress = targetProgress = (int)(value * 100);
+ UpdateProgress();
+ }
+ else
+ {
+ currentProgress = (int)(value * 100);
+ }
+
+
+ }
+
+ protected void UpdateProgress()
+ {
+ progressText.text = currentProgress + "%";
+ progressBar.fillAmount = currentProgress / 100f;
+ }
+
+ protected void Update()
+ {
+ if (currentProgress < targetProgress)
+ {
+ currentProgress = (int)Mathf.Lerp(currentProgress, targetProgress, 0.1f);
+ UpdateProgress();
+ }
+ }
}
\ No newline at end of file
diff --git a/Main/UI/LoadingWin.cs.meta b/Main/System/Launch/LoadingWin.cs.meta
similarity index 100%
rename from Main/UI/LoadingWin.cs.meta
rename to Main/System/Launch/LoadingWin.cs.meta
diff --git a/Main/Manager/LoginManager.cs b/Main/System/Login/LoginManager.cs
similarity index 99%
rename from Main/Manager/LoginManager.cs
rename to Main/System/Login/LoginManager.cs
index 5c7a625..15d04ba 100644
--- a/Main/Manager/LoginManager.cs
+++ b/Main/System/Login/LoginManager.cs
@@ -1,383 +1,383 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using System;
-
-
-public class LoginManager : ManagerBase<LoginManager>
-{
- public const uint DwVersionNo = 153518004;
- public readonly static string USER_ACCOUNT = Application.dataPath + "UserAccount";
- public readonly static string USER_PASSWORD = Application.dataPath + "UserPassword";
-
- public bool sdkLogined
- {
- get;
- set;
- } = false;
-
- public bool reconnectBackGround
- {
- get;
- set;
- } = false;
-
- public bool onCreateRole
- {
- get;
- set;
- } = false;
-
- public bool busy
- {
- get;
- set;
- } = false;
-
- int ServerListLoop = 200; //绉掞細鍦ㄧ櫥褰曠晫闈㈣姹傛湇鍔″櫒鍒楄〃鐨勯棿闅�
- long LastLoopSecond = 0; //涓婁竴娆$殑璇锋眰鏃堕棿 100绾崇鍗曚綅
-
- public SDKUtils.FP_LoginOk sdkLoginResult;
- public SDKUtils.FP_CheckIDAuthentication sdkIDCheckIDAuthentication;
-
- public string localSaveAccountName
- {
- get { return LocalSave.GetString(USER_ACCOUNT); }
- set { LocalSave.SetString(USER_ACCOUNT, value); }
- }
-
- public event Action<bool> registerResultEvent;
- public event Action accountBindOkEvent;
- public event Action loginErrorEvent; //娓告垙鍚姩鍚庤〃鏍煎姞杞� 妯″潡鍔犺浇澶辫触鐨勬彁绀�
- public string loginErrorInfo;
-
- public string ipBuf { get; private set; }
- public int portBuf { get; private set; }
- public int gamePortBuf { get; private set; }
- public string accountBuf { get; private set; }
- public string passwordBuf { get; private set; }
-
- public bool isLogined { get; set; }
-
- public override void Init()
- {
- SDKUtils.Instance.onFreePlatformLoginOk += OnSDKAccountLoginOk;
- SDKUtils.Instance.onFreePlatformLogoutOk += OnSDKAccountLoginOutOk;
- SDKUtils.Instance.onFreePlatformBindOk += OnSDKAccountBindOk;
-
- LaunchInHot.Instance.OnApplicationOut += OnApplicationOut;
- }
-
- public override void Release()
- {
- SDKUtils.Instance.onFreePlatformLoginOk -= OnSDKAccountLoginOk;
- SDKUtils.Instance.onFreePlatformLogoutOk -= OnSDKAccountLoginOutOk;
- SDKUtils.Instance.onFreePlatformBindOk -= OnSDKAccountBindOk;
-
- LaunchInHot.Instance.OnApplicationOut -= OnApplicationOut;
- }
-
- private void OnSDKAccountLoginOk(SDKUtils.FP_LoginOk _result)
- {
- sdkLogined = true;
- sdkLoginResult = _result;
-
- if (!DebugUtility.Instance.isWhiteListAccount)
- {
- DebugUtility.Instance.RequestWhiteListAuthority(sdkLoginResult.account);
- }
-
- ServerListCenter.Instance.RequestServerListPlayer(sdkLoginResult.account);
- SDKUtils.Instance.MakeKeyAndVisible();
-
- // TODO YYL
- // OperationLogCollect.Instance.RecordLauchEvent(5);
-
- GameNotice.OpenGameNotice();
- }
-
- private void OnSDKAccountLoginOutOk()
- {
- sdkLogined = false;
- sdkLoginResult = default(SDKUtils.FP_LoginOk);
- GameNetSystem.Instance.LoginOut();
- }
-
- private void OnSDKAccountBindOk()
- {
- sdkLoginResult.phone = 1;
- if (accountBindOkEvent != null)
- {
- accountBindOkEvent();
- }
- }
-
- private void OnGetIDAuthenticationInfo(SDKUtils.FP_CheckIDAuthentication _info)
- {
- sdkIDCheckIDAuthentication = _info;
- }
-
- public void AccountLogin(string _account, string _ip, int _port, int _gamePort)
- {
- Debug.LogFormat("璐﹀彿鐧诲綍, account:{0} ; ip:{1} ; port:{2} ; gamePort:{3}", _account, _ip, _port, _gamePort);
- isLogined = true;
- if (Application.internetReachability == NetworkReachability.NotReachable)
- {
- ConfirmCancel.ShowPopConfirm(
- Language.Get("Mail101"),
- Language.Get("L1116"),
- () => { }
- );
- return;
- }
-
- if (busy)
- {
- return;
- }
-
- busy = true;
-
- try
- {
- reconnectBackGround = false;
- accountBuf = _account;
- localSaveAccountName = accountBuf;
- ipBuf = _ip;
- portBuf = _port;
- gamePortBuf = _gamePort;
-
- ConnectGameServer(ipBuf, gamePortBuf);
-
- GameNetSystem.Instance.OnAccountLogin();
- NetLinkWin.Show();
- }
- catch (Exception ex)
- {
- Debug.Log(ex);
- busy = false;
- }
-
- }
-
- public void AccountLogin(string _ip, int _port, int _gamePort)
- {
- if (sdkLogined)
- {
- AccountLogin(sdkLoginResult.account, _ip, _port, _gamePort);
- }
- else
- {
- SDKUtils.Instance.FreePlatformLogin();
- }
- }
-
- public void ReAccountLogin()
- {
- if (busy)
- {
- return;
- }
-
- busy = true;
- reconnectBackGround = true;
-
- try
- {
- ConnectGameServer(ipBuf, gamePortBuf);
- NetLinkWin.Show();
- }
- catch (Exception ex)
- {
- Debug.Log(ex);
- busy = false;
- }
- }
-
- private void OnAccountLogin(bool _ok, string _result)
- {
- if (!_ok)
- {
- busy = false;
- Debug.LogError(_result);
- NetLinkWin.Hide();
- return;
- }
-
- if (string.IsNullOrEmpty(_result))
- {
- busy = false;
- ServerTipDetails.DisplayNormalTip(Language.Get("L1117"));
- NetLinkWin.Hide();
- return;
- }
-
- var stringSet = _result.Split('|');
- if (stringSet[0] != "OK")
- {
- if (stringSet.Length > 1)
- {
- ServerTipDetails.DisplayNormalTip(stringSet[1]);
- }
-
- busy = false;
- NetLinkWin.Hide();
- return;
- }
-
- localSaveAccountName = accountBuf;
- try
- {
- ConnectGameServer(ipBuf, gamePortBuf);
- }
- catch (Exception ex)
- {
- busy = false;
- Debug.Log(ex);
- }
- }
-
-
- void ConnectGameServer(string _ip, int _port)
- {
- GameNetSystem.Instance.BeginConnectGameServer(_ip, _port, OnGameServerConnected);
- }
-
- private void OnGameServerConnected(bool ok)
- {
- if (ok)
- {
- var sendInfo = new C0123_tagCClientPackVersion();
- sendInfo.Version = DwVersionNo;
- GameNetSystem.Instance.SendInfo(sendInfo);
- }
- else
- {
- busy = false;
- }
- }
-
-
- public void AccessLogin(H0101_tagServerPrepared _serverInfo)
- {
- GameNetSystem.Instance.SendInfo(Get0101SendPackage(_serverInfo)); // 鐧诲綍
- }
-
- public void CheckClientVersion()
- {
- var sendInfo = new C010D_tagCClientVersion();
- sendInfo.Version = "10.1000.1";
- GameNetSystem.Instance.SendInfo(sendInfo);
- }
-
- private void OnApplicationOut()
- {
- var sendInfo = new C0103_tagCPlayerLogOut();
- sendInfo.Type = 1;
- GameNetSystem.Instance.SendInfo(sendInfo);
- }
-
- public void RequestServerListLoop()
- {
- long nowTick = DateTime.Now.Ticks;
- if (LastLoopSecond == 0)
- {
- LastLoopSecond = nowTick;
- return;
- }
- if ((nowTick - LastLoopSecond) / 10000000 > ServerListLoop)
- {
- Debug.Log("瀹氭椂璇锋眰鏈嶅姟鍣ㄥ垪琛�");
- ServerListCenter.Instance.RequestServerCommonList();
- LastLoopSecond = nowTick;
- }
- }
-
- public C0101_tagCPlayerLogin Get0101SendPackage(H0101_tagServerPrepared _serverInfo)
- {
- var send = new C0101_tagCPlayerLogin();
- switch (VersionConfig.Get().versionAuthority)
- {
- case VersionAuthority.InterTest:
- send.IDType = 1;
- send.AccID = accountBuf;
- if (sdkLoginResult == null)
- send.Password = "111";
- else
- send.Password = sdkLoginResult.token;
- send.MAC = DeviceUtility.GetMac();
- send.Version = _serverInfo.Version;
- send.LineNO = 255;
- send.AppID = VersionConfig.Get().appId;
- send.AccountID = 1000;// 鍐呴儴鐧婚檰鐨勬椂鍊欑殑id
- send.TokenExpire = "1519750743000";// 鍐呴儴鐧婚檰鐨勬椂闀�,鏃犳墍璋撶殑
- send.Phone = 0;
- send.ServerID = (uint)ServerListCenter.Instance.currentServer.region_flag;
- send.Adult = 1;
- send.ExtraLen = 0;
- send.Extra = "";
- break;
- case VersionAuthority.Release:
- send.Extra = VersionConfig.Get().SpID + "|" + SDKUtils.Instance.Device.uniqueID;
- send.ExtraLen = (ushort)send.Extra.Length;
- if (SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.Free)
- {
- send.IDType = 1;
- send.Password = sdkLoginResult.token;
- }
- else if (SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.Quick)
- {
- send.IDType = 10;
- send.Extra += ("|" + sdkLoginResult.token + "|" + sdkLoginResult.qkUserName);
- send.ExtraLen = (ushort)send.Extra.Length;
- }
- else if (SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.Hy ||
- SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.hygt ||
- SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.newyn ||
- SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.en
- )
- {
- send.IDType = (byte)SDKUtils.Instance.ChannelPlatform;
- send.Extra += ("|" + sdkLoginResult.token + "|" + sdkLoginResult.qkUserName);
- send.ExtraLen = (ushort)send.Extra.Length;
- }
-
- send.AccID = sdkLoginResult.account;
-
- var deviceInfo = DeviceUtility.GetDeviceModel();
- deviceInfo.Replace(" ", "").Replace("=", "").Replace("%", "").Replace("-", "").Replace("|","");
- var versionStr = StringUtility.Contact(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex, "_", deviceInfo);
-
- send.Extra += ("|" + versionStr.Substring(0, Math.Min(24, versionStr.Length)));
- Debug.Log("=====> extra: " + send.Extra);
- send.ExtraLen = (ushort)send.Extra.Length;
- send.MAC = DeviceUtility.GetMac();
- send.Version = _serverInfo.Version;
- send.LineNO = 255;
- send.AppID = VersionConfig.Get().appId;
- send.AccountID = (uint)sdkLoginResult.accountID;
- send.TokenExpire = sdkLoginResult.tokenExpire;
- if (SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.Sp)
- {
- send.TokenExpire = SDKUtils.Instance.FreePlatformInfo.timeStamp;
- }
- send.Phone = (byte)sdkLoginResult.phone;
- send.ServerID = (uint)ServerListCenter.Instance.currentServer.region_flag;
- if (sdkIDCheckIDAuthentication.type == "1")
- {
- send.Adult = 1;
- }
- else if (sdkIDCheckIDAuthentication.type == "2")
- {
- send.Adult = MathUtility.CheckAdult(sdkIDCheckIDAuthentication.card_id) ? (byte)1 : (byte)0;
- }
- else
- {
- send.Adult = 0;
- }
- break;
- }
-
- return send;
- }
-}
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using System;
+
+
+public class LoginManager : ManagerBase<LoginManager>
+{
+ public const uint DwVersionNo = 153518004;
+ public readonly static string USER_ACCOUNT = Application.dataPath + "UserAccount";
+ public readonly static string USER_PASSWORD = Application.dataPath + "UserPassword";
+
+ public bool sdkLogined
+ {
+ get;
+ set;
+ } = false;
+
+ public bool reconnectBackGround
+ {
+ get;
+ set;
+ } = false;
+
+ public bool onCreateRole
+ {
+ get;
+ set;
+ } = false;
+
+ public bool busy
+ {
+ get;
+ set;
+ } = false;
+
+ int ServerListLoop = 200; //绉掞細鍦ㄧ櫥褰曠晫闈㈣姹傛湇鍔″櫒鍒楄〃鐨勯棿闅�
+ long LastLoopSecond = 0; //涓婁竴娆$殑璇锋眰鏃堕棿 100绾崇鍗曚綅
+
+ public SDKUtils.FP_LoginOk sdkLoginResult;
+ public SDKUtils.FP_CheckIDAuthentication sdkIDCheckIDAuthentication;
+
+ public string localSaveAccountName
+ {
+ get { return LocalSave.GetString(USER_ACCOUNT); }
+ set { LocalSave.SetString(USER_ACCOUNT, value); }
+ }
+
+ public event Action<bool> registerResultEvent;
+ public event Action accountBindOkEvent;
+ public event Action loginErrorEvent; //娓告垙鍚姩鍚庤〃鏍煎姞杞� 妯″潡鍔犺浇澶辫触鐨勬彁绀�
+ public string loginErrorInfo;
+
+ public string ipBuf { get; private set; }
+ public int portBuf { get; private set; }
+ public int gamePortBuf { get; private set; }
+ public string accountBuf { get; private set; }
+ public string passwordBuf { get; private set; }
+
+ public bool isLogined { get; set; }
+
+ public override void Init()
+ {
+ SDKUtils.Instance.onFreePlatformLoginOk += OnSDKAccountLoginOk;
+ SDKUtils.Instance.onFreePlatformLogoutOk += OnSDKAccountLoginOutOk;
+ SDKUtils.Instance.onFreePlatformBindOk += OnSDKAccountBindOk;
+
+ LaunchInHot.Instance.OnApplicationOut += OnApplicationOut;
+ }
+
+ public override void Release()
+ {
+ SDKUtils.Instance.onFreePlatformLoginOk -= OnSDKAccountLoginOk;
+ SDKUtils.Instance.onFreePlatformLogoutOk -= OnSDKAccountLoginOutOk;
+ SDKUtils.Instance.onFreePlatformBindOk -= OnSDKAccountBindOk;
+
+ LaunchInHot.Instance.OnApplicationOut -= OnApplicationOut;
+ }
+
+ private void OnSDKAccountLoginOk(SDKUtils.FP_LoginOk _result)
+ {
+ sdkLogined = true;
+ sdkLoginResult = _result;
+
+ if (!DebugUtility.Instance.isWhiteListAccount)
+ {
+ DebugUtility.Instance.RequestWhiteListAuthority(sdkLoginResult.account);
+ }
+
+ ServerListCenter.Instance.RequestServerListPlayer(sdkLoginResult.account);
+ SDKUtils.Instance.MakeKeyAndVisible();
+
+ // TODO YYL
+ // OperationLogCollect.Instance.RecordLauchEvent(5);
+
+ GameNotice.OpenGameNotice();
+ }
+
+ private void OnSDKAccountLoginOutOk()
+ {
+ sdkLogined = false;
+ sdkLoginResult = default(SDKUtils.FP_LoginOk);
+ GameNetSystem.Instance.LoginOut();
+ }
+
+ private void OnSDKAccountBindOk()
+ {
+ sdkLoginResult.phone = 1;
+ if (accountBindOkEvent != null)
+ {
+ accountBindOkEvent();
+ }
+ }
+
+ private void OnGetIDAuthenticationInfo(SDKUtils.FP_CheckIDAuthentication _info)
+ {
+ sdkIDCheckIDAuthentication = _info;
+ }
+
+ public void AccountLogin(string _account, string _ip, int _port, int _gamePort)
+ {
+ Debug.LogFormat("璐﹀彿鐧诲綍, account:{0} ; ip:{1} ; port:{2} ; gamePort:{3}", _account, _ip, _port, _gamePort);
+ isLogined = true;
+ if (Application.internetReachability == NetworkReachability.NotReachable)
+ {
+ ConfirmCancel.ShowPopConfirm(
+ Language.Get("Mail101"),
+ Language.Get("L1116"),
+ () => { }
+ );
+ return;
+ }
+
+ if (busy)
+ {
+ return;
+ }
+
+ busy = true;
+
+ try
+ {
+ reconnectBackGround = false;
+ accountBuf = _account;
+ localSaveAccountName = accountBuf;
+ ipBuf = _ip;
+ portBuf = _port;
+ gamePortBuf = _gamePort;
+
+ ConnectGameServer(ipBuf, gamePortBuf);
+
+ GameNetSystem.Instance.OnAccountLogin();
+ NetLinkWin.Show();
+ }
+ catch (Exception ex)
+ {
+ Debug.Log(ex);
+ busy = false;
+ }
+
+ }
+
+ public void AccountLogin(string _ip, int _port, int _gamePort)
+ {
+ if (sdkLogined)
+ {
+ AccountLogin(sdkLoginResult.account, _ip, _port, _gamePort);
+ }
+ else
+ {
+ SDKUtils.Instance.FreePlatformLogin();
+ }
+ }
+
+ public void ReAccountLogin()
+ {
+ if (busy)
+ {
+ return;
+ }
+
+ busy = true;
+ reconnectBackGround = true;
+
+ try
+ {
+ ConnectGameServer(ipBuf, gamePortBuf);
+ NetLinkWin.Show();
+ }
+ catch (Exception ex)
+ {
+ Debug.Log(ex);
+ busy = false;
+ }
+ }
+
+ private void OnAccountLogin(bool _ok, string _result)
+ {
+ if (!_ok)
+ {
+ busy = false;
+ Debug.LogError(_result);
+ NetLinkWin.Hide();
+ return;
+ }
+
+ if (string.IsNullOrEmpty(_result))
+ {
+ busy = false;
+ ServerTipDetails.DisplayNormalTip(Language.Get("L1117"));
+ NetLinkWin.Hide();
+ return;
+ }
+
+ var stringSet = _result.Split('|');
+ if (stringSet[0] != "OK")
+ {
+ if (stringSet.Length > 1)
+ {
+ ServerTipDetails.DisplayNormalTip(stringSet[1]);
+ }
+
+ busy = false;
+ NetLinkWin.Hide();
+ return;
+ }
+
+ localSaveAccountName = accountBuf;
+ try
+ {
+ ConnectGameServer(ipBuf, gamePortBuf);
+ }
+ catch (Exception ex)
+ {
+ busy = false;
+ Debug.Log(ex);
+ }
+ }
+
+
+ void ConnectGameServer(string _ip, int _port)
+ {
+ GameNetSystem.Instance.BeginConnectGameServer(_ip, _port, OnGameServerConnected);
+ }
+
+ private void OnGameServerConnected(bool ok)
+ {
+ if (ok)
+ {
+ var sendInfo = new C0123_tagCClientPackVersion();
+ sendInfo.Version = DwVersionNo;
+ GameNetSystem.Instance.SendInfo(sendInfo);
+ }
+ else
+ {
+ busy = false;
+ }
+ }
+
+
+ public void AccessLogin(H0101_tagServerPrepared _serverInfo)
+ {
+ GameNetSystem.Instance.SendInfo(Get0101SendPackage(_serverInfo)); // 鐧诲綍
+ }
+
+ public void CheckClientVersion()
+ {
+ var sendInfo = new C010D_tagCClientVersion();
+ sendInfo.Version = "10.1000.1";
+ GameNetSystem.Instance.SendInfo(sendInfo);
+ }
+
+ private void OnApplicationOut()
+ {
+ var sendInfo = new C0103_tagCPlayerLogOut();
+ sendInfo.Type = 1;
+ GameNetSystem.Instance.SendInfo(sendInfo);
+ }
+
+ public void RequestServerListLoop()
+ {
+ long nowTick = DateTime.Now.Ticks;
+ if (LastLoopSecond == 0)
+ {
+ LastLoopSecond = nowTick;
+ return;
+ }
+ if ((nowTick - LastLoopSecond) / 10000000 > ServerListLoop)
+ {
+ Debug.Log("瀹氭椂璇锋眰鏈嶅姟鍣ㄥ垪琛�");
+ ServerListCenter.Instance.RequestServerCommonList();
+ LastLoopSecond = nowTick;
+ }
+ }
+
+ public C0101_tagCPlayerLogin Get0101SendPackage(H0101_tagServerPrepared _serverInfo)
+ {
+ var send = new C0101_tagCPlayerLogin();
+ switch (VersionConfig.Get().versionAuthority)
+ {
+ case VersionAuthority.InterTest:
+ send.IDType = 1;
+ send.AccID = accountBuf;
+ if (sdkLoginResult == null)
+ send.Password = "111";
+ else
+ send.Password = sdkLoginResult.token;
+ send.MAC = DeviceUtility.GetMac();
+ send.Version = _serverInfo.Version;
+ send.LineNO = 255;
+ send.AppID = VersionConfig.Get().appId;
+ send.AccountID = 1000;// 鍐呴儴鐧婚檰鐨勬椂鍊欑殑id
+ send.TokenExpire = "1519750743000";// 鍐呴儴鐧婚檰鐨勬椂闀�,鏃犳墍璋撶殑
+ send.Phone = 0;
+ send.ServerID = (uint)ServerListCenter.Instance.currentServer.region_flag;
+ send.Adult = 1;
+ send.ExtraLen = 0;
+ send.Extra = "";
+ break;
+ case VersionAuthority.Release:
+ send.Extra = VersionConfig.Get().SpID + "|" + SDKUtils.Instance.Device.uniqueID;
+ send.ExtraLen = (ushort)send.Extra.Length;
+ if (SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.Free)
+ {
+ send.IDType = 1;
+ send.Password = sdkLoginResult.token;
+ }
+ else if (SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.Quick)
+ {
+ send.IDType = 10;
+ send.Extra += ("|" + sdkLoginResult.token + "|" + sdkLoginResult.qkUserName);
+ send.ExtraLen = (ushort)send.Extra.Length;
+ }
+ else if (SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.Hy ||
+ SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.hygt ||
+ SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.newyn ||
+ SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.en
+ )
+ {
+ send.IDType = (byte)SDKUtils.Instance.ChannelPlatform;
+ send.Extra += ("|" + sdkLoginResult.token + "|" + sdkLoginResult.qkUserName);
+ send.ExtraLen = (ushort)send.Extra.Length;
+ }
+
+ send.AccID = sdkLoginResult.account;
+
+ var deviceInfo = DeviceUtility.GetDeviceModel();
+ deviceInfo.Replace(" ", "").Replace("=", "").Replace("%", "").Replace("-", "").Replace("|","");
+ var versionStr = StringUtility.Contact(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex, "_", deviceInfo);
+
+ send.Extra += ("|" + versionStr.Substring(0, Math.Min(24, versionStr.Length)));
+ Debug.Log("=====> extra: " + send.Extra);
+ send.ExtraLen = (ushort)send.Extra.Length;
+ send.MAC = DeviceUtility.GetMac();
+ send.Version = _serverInfo.Version;
+ send.LineNO = 255;
+ send.AppID = VersionConfig.Get().appId;
+ send.AccountID = (uint)sdkLoginResult.accountID;
+ send.TokenExpire = sdkLoginResult.tokenExpire;
+ if (SDKUtils.Instance.ChannelPlatform == SDKUtils.E_ChannelPlatform.Sp)
+ {
+ send.TokenExpire = SDKUtils.Instance.FreePlatformInfo.timeStamp;
+ }
+ send.Phone = (byte)sdkLoginResult.phone;
+ send.ServerID = (uint)ServerListCenter.Instance.currentServer.region_flag;
+ if (sdkIDCheckIDAuthentication.type == "1")
+ {
+ send.Adult = 1;
+ }
+ else if (sdkIDCheckIDAuthentication.type == "2")
+ {
+ send.Adult = MathUtility.CheckAdult(sdkIDCheckIDAuthentication.card_id) ? (byte)1 : (byte)0;
+ }
+ else
+ {
+ send.Adult = 0;
+ }
+ break;
+ }
+
+ return send;
+ }
+}
diff --git a/Main/Manager/LoginManager.cs.meta b/Main/System/Login/LoginManager.cs.meta
similarity index 100%
rename from Main/Manager/LoginManager.cs.meta
rename to Main/System/Login/LoginManager.cs.meta
diff --git a/Main/Login/ServerData.cs b/Main/System/Login/ServerData.cs
similarity index 100%
rename from Main/Login/ServerData.cs
rename to Main/System/Login/ServerData.cs
diff --git a/Main/Login/ServerData.cs.meta b/Main/System/Login/ServerData.cs.meta
similarity index 100%
rename from Main/Login/ServerData.cs.meta
rename to Main/System/Login/ServerData.cs.meta
diff --git a/Main/Login/ServerListCenter.cs b/Main/System/Login/ServerListCenter.cs
similarity index 100%
rename from Main/Login/ServerListCenter.cs
rename to Main/System/Login/ServerListCenter.cs
diff --git a/Main/Login/ServerListCenter.cs.meta b/Main/System/Login/ServerListCenter.cs.meta
similarity index 100%
rename from Main/Login/ServerListCenter.cs.meta
rename to Main/System/Login/ServerListCenter.cs.meta
diff --git a/Main/Login/ServerListParser.cs b/Main/System/Login/ServerListParser.cs
similarity index 100%
rename from Main/Login/ServerListParser.cs
rename to Main/System/Login/ServerListParser.cs
diff --git a/Main/Login/ServerListParser.cs.meta b/Main/System/Login/ServerListParser.cs.meta
similarity index 100%
rename from Main/Login/ServerListParser.cs.meta
rename to Main/System/Login/ServerListParser.cs.meta
diff --git a/Main/Manager/GameSystemManager/MailManager.cs b/Main/System/Mail/MailManager.cs
similarity index 99%
rename from Main/Manager/GameSystemManager/MailManager.cs
rename to Main/System/Mail/MailManager.cs
index bf933e8..74b5968 100644
--- a/Main/Manager/GameSystemManager/MailManager.cs
+++ b/Main/System/Mail/MailManager.cs
@@ -1,334 +1,334 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using UnityEngine;
-
-namespace vnxbqy.UI
-{
- public class MailManager : GameSystemManager<MailManager>
- {
- /// <summary>
- /// 閭欢鏁版嵁瀛楀吀锛屽瓨鍌ㄦ墍鏈夐偖浠惰鎯�
- /// Key: 閭欢GUID(鍞竴鏍囪瘑)
- /// Value: 閭欢璇︾粏鏁版嵁(MailData缁撴瀯浣�)
- /// </summary>
- Dictionary<string, MailData> mailDataDict = new Dictionary<string, MailData>();
- public MailCategory nowMailCategory = MailCategory.Personal;
- public Redpoint parentRedpoint = new Redpoint(MainRedDot.MailRepoint);
- public Redpoint tabRedpoint0;
- public Redpoint tabRedpoint1;
- public event Action OnUpdateMailListEvent;// 鏇存柊閭欢鍒楄〃鏁版嵁
- public event Action OnUpdateMailStateChangeEvent;// 鏇存柊閭欢鐘舵�佸彉鏇�
- public readonly string dateFormat = "yyyy-MM-dd";
- public string nowUuid = string.Empty;
- public override void Init()
- {
- tabRedpoint0 = new Redpoint(MainRedDot.MailRepoint, GetTabRedpointId(MailCategory.Personal));
- tabRedpoint1 = new Redpoint(MainRedDot.MailRepoint, GetTabRedpointId(MailCategory.Global));
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitializeEvent;
- }
-
- public override void Release()
- {
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitializeEvent;
- }
-
- public void OnBeforePlayerDataInitializeEvent()
- {
- mailDataDict.Clear();
- }
-
- public bool HasNoReadMail(MailCategory category)
- {
- var list = GetMailList(category);
- if (list.IsNullOrEmpty())
- return false;
-
- foreach (var guid in list)
- {
- if (mailDataDict.TryGetValue(guid, out var mailData) && mailData.MailState == 1)
- return true;
- }
- return false;
- }
-
- public int GetTabRedpointId(MailCategory type)
- {
- return MainRedDot.MailRepoint * 10 + (int)type;
- }
-
- public void UpdatePersonalRedPoint()
- {
- if (tabRedpoint0 == null)
- return;
- tabRedpoint0.state = RedPointState.None;
- if (HasNoReadMail(MailCategory.Personal))
- {
- tabRedpoint0.state = RedPointState.Simple;
- }
- }
-
- public void UpdateGlobalRedPoint()
- {
- if (tabRedpoint1 == null) return;
- tabRedpoint1.state = RedPointState.None;
- if (HasNoReadMail(MailCategory.Global))
- {
- tabRedpoint1.state = RedPointState.Simple;
- }
- }
-
- /// <summary>
- /// 鏇存柊閭欢绾㈢偣鎻愮ず鐘舵��
- /// </summary>
- public void UpdateRedPoint()
- {
- UpdatePersonalRedPoint();
- UpdateGlobalRedPoint();
- }
-
- public bool TryGetMailData(string uuid, out MailData mailData)
- {
- return mailDataDict.TryGetValue(uuid, out mailData);
- }
- public string FormatCreateMailTime(DateTime createDateTime)
- {
- TimeSpan diff = TimeUtility.ServerNow - createDateTime;
- if (diff.TotalHours <= 24)
- {
- int hours = (int)Math.Floor(diff.TotalHours);
- return Language.Get("Mail05", hours);
- }
- else
- {
- return createDateTime.ToString(dateFormat);
- }
- }
-
- //杩斿洖鏈夋晥鏈熷ぉ鏁�(姝f暟=宸茶繃鏈熷ぉ鏁帮紝璐熸暟=鍓╀綑澶╂暟)
- public int GetMailExpiryDays(DateTime createDateTime, int limitDays)
- {
- DateTime expiryDate = createDateTime.AddDays(limitDays);
- return (int)(TimeUtility.ServerNow - expiryDate).TotalDays;
- }
-
-
- public List<string> GetMailList(MailCategory mailCategory)
- {
- var result = new List<string>();
- foreach (var kvp in mailDataDict)
- {
- if (kvp.Value.Category == mailCategory)
- {
- result.Add(kvp.Key);
- }
- }
- return result;
- }
-
- public List<string> GetSortMailScrList(MailCategory mailCategory)
- {
- List<string> resList = GetMailList(mailCategory);
- return resList.OrderByDescending(guid => mailDataDict[guid].CreateDateTime).ToList();
- }
-
- /// <summary>
- /// 鏇存柊閭欢鍒楄〃鏁版嵁
- /// </summary>
- /// <param name="vNetData">浠庢湇鍔″櫒鎺ユ敹鐨勯偖浠跺垪琛ㄦ暟鎹寘</param>
- public void UpdateMailList(HA362_tagMCMailList vNetData)
- {
- if (vNetData == null) return;
-
- // 鏇存柊閭欢鏁版嵁瀛楀吀
- foreach (var mail in vNetData.MailList)
- {
- var category = vNetData.IsServerMail == 1 ? MailCategory.Global : MailCategory.Personal;
- var mailData = new MailData();
-
- mailData.Category = category;
- mailData.GUID = mail.GUID;
- mailData.Type = mail.Type;
- mailData.CreateTime = mail.CreateTime;
- mailData.CreateDateTime = Convert.ToDateTime(UIHelper.GetTime(mail.CreateTime));
- mailData.LimitDays = mail.LimitDays;
- mailData.Title = mail.Title;
- mailData.Text = mail.Text;
- mailData.MailState = mail.MailState;
-
- mailData.Items = mail.Items?.Select(i => new MailItemData
- {
- ItemID = i.ItemID,
- Count = i.Count,
- IsBind = i.IsBind,
- UserData = i.UserData
- }).ToList();
- mailDataDict[mail.GUID] = mailData;
- }
-
- UpdateRedPoint();
- OnUpdateMailListEvent?.Invoke();
- }
-
- /// <summary>
- /// 鏇存柊閭欢鐘舵�佸彉鏇�
- /// </summary>
- /// <param name="vNetData">浠庢湇鍔″櫒鎺ユ敹鐨勯偖浠剁姸鎬佸彉鏇存暟鎹寘</param>
- public void UpdateMailStateChange(HA363_tagMCMailStateChange vNetData)
- {
- if (vNetData == null || vNetData.MailList == null) return;
-
- foreach (var stateChange in vNetData.MailList)
- {
- if (mailDataDict.TryGetValue(stateChange.GUID, out var mailData))
- {
- if (stateChange.MailState == 4)
- {
- mailDataDict.Remove(stateChange.GUID);
- continue;
- }
- mailData.MailState = stateChange.MailState;
- mailDataDict[stateChange.GUID] = mailData;
- }
- }
-
- UpdateRedPoint();
- OnUpdateMailStateChangeEvent?.Invoke();
- }
-
-
- /// <summary>
- /// 闃呰閭欢
- /// </summary>
- /// <param name="GUID">閭欢GUID</param>
- public void ReadMail(string GUID)
- {
- if (string.IsNullOrEmpty(GUID))
- {
- Debug.LogError("闃呰閭欢GUID涓嶈兘涓虹┖");
- return;
- }
- SendRequestMail(GUID, 0);
- }
-
- /// <summary>
- /// 棰嗗彇閭欢
- /// </summary>
- /// <param name="GUID">閭欢GUID锛屼负绌烘椂鎵归噺棰嗗彇鎵�鏈夐偖浠�</param>
- public void ClaimMail(string GUID = null)
- {
- SendRequestMail(GUID, 1);
- }
-
- /// <summary>
- /// 鍒犻櫎閭欢
- /// </summary>
- /// <param name="GUID">閭欢GUID锛屼负绌烘椂鎵归噺鍒犻櫎宸查鍙栨垨鏃犵墿鍝佺殑宸茶閭欢</param>
- public void DeleteMail(string GUID = null)
- {
- SendRequestMail(GUID, 2);
- }
-
- /// <summary>
- /// 鍙戦�侀偖浠惰姹傚埌鏈嶅姟鍣�
- /// </summary>
- /// <param name="GUID">閭欢GUID</param>
- /// <param name="ReqType">璇锋眰绫诲瀷 0-璁剧疆宸茶锛�1-棰嗗彇閭欢锛�2-鍒犻櫎閭欢</param>
- public void SendRequestMail(string GUID, byte ReqType)
- {
- CA537_tagCMRequestMail pack = new CA537_tagCMRequestMail();
- pack.GUID = GUID;
- pack.ReqType = ReqType;
- GameNetSystem.Instance.SendInfo(pack);
- }
-
- //娌℃湁涓�涓彲棰嗗彇鐨勪釜浜洪偖浠�
- public bool IsCanHaveMail()
- {
- var personalMails = GetMailList(MailCategory.Personal);
- return personalMails.Any(guid =>
- mailDataDict.TryGetValue(guid, out var mail) &&
- mail.MailState != 3 &&
- mail.Items != null &&
- mail.Items.Count > 0
- );
- }
- }
-
- public enum MailCategory
- {
- Personal = 0, // 涓汉閭欢
- Global = 1 // 鍏ㄦ湇閭欢
- }
-
- public class MailItemData
- {
- public uint ItemID; //鐗╁搧ID
- public uint Count; //鏁伴噺
- public byte IsBind; //鏄惁缁戝畾
- public string UserData; //鑷畾涔夋暟鎹�
- }
-
- public class MailData
- {
- public MailCategory Category;
- public string GUID; //閭欢GUID
- public byte Type; //閭欢绫诲瀷锛屾殏鏃堕粯璁�0
- public string CreateTime; //鍒涘缓鏃堕棿
- public DateTime CreateDateTime;
- public byte LimitDays; //鏈夋晥澶╂暟
- public string Title; //鏍囬
- public string Text; //鍐呭
- public byte MailState; //閭欢鐘舵�侊細 0-鏈煡锛�1-鏈锛�2-宸茶锛�3-宸查锛�
- public List<MailItemData> Items; //鐗╁搧淇℃伅
-
- /// <summary>
- /// 鍒ゆ柇鏄惁涓烘ā鏉跨被鍨嬮偖浠�
- /// </summary>
- /// <returns>true-妯℃澘閭欢, false-鏅�氶偖浠�</returns>
- public bool IsTemplateMail()
- {
- if (string.IsNullOrEmpty(Title))
- return false;
-
- return Title.StartsWith("<T>") && Title.EndsWith("</T>");
- }
-
- /// <summary>
- /// 鑾峰彇妯℃澘閭欢鐨勬ā鏉縦ey
- /// </summary>
- /// <returns>妯℃澘key锛屽鏋滀笉鏄ā鏉块偖浠惰繑鍥炵┖瀛楃涓�</returns>
- public string GetTemplateKey()
- {
- if (!IsTemplateMail())
- return string.Empty;
-
- // 妯℃澘鏍煎紡: <T>key</T>
- // 璺宠繃寮�澶寸殑"<T>" (3瀛楃)
- // 鍙栦腑闂撮儴鍒嗭紝鎬婚暱搴﹀噺鍘�"<T>"鍜�"</T>"鍏�7瀛楃
- const int prefixLength = 3; // "<T>"闀垮害
- const int suffixLength = 4; // "</T>"闀垮害
- return Title.Substring(prefixLength, Title.Length - (prefixLength + suffixLength));
- }
-
- /// <summary>
- /// 鑾峰彇妯℃澘閭欢鐨勫弬鏁板垪琛�
- /// </summary>
- /// <returns>鍙傛暟鍒楄〃锛屽鏋滀笉鏄ā鏉块偖浠舵垨鍙傛暟涓虹┖鍒欒繑鍥炵┖鍒楄〃</returns>
- public List<string> GetTemplateParams()
- {
- if (!IsTemplateMail() || string.IsNullOrEmpty(Text))
- return new List<string>();
-
- try
- {
- // 鍙傛暟鏍煎紡涓篔SON鏁扮粍锛歔鍙傛暟1, 鍙傛暟2, ...]
- return JsonUtility.FromJson<List<string>>(Text);
- }
- catch
- {
- return new List<string>();
- }
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+
+namespace vnxbqy.UI
+{
+ public class MailManager : GameSystemManager<MailManager>
+ {
+ /// <summary>
+ /// 閭欢鏁版嵁瀛楀吀锛屽瓨鍌ㄦ墍鏈夐偖浠惰鎯�
+ /// Key: 閭欢GUID(鍞竴鏍囪瘑)
+ /// Value: 閭欢璇︾粏鏁版嵁(MailData缁撴瀯浣�)
+ /// </summary>
+ Dictionary<string, MailData> mailDataDict = new Dictionary<string, MailData>();
+ public MailCategory nowMailCategory = MailCategory.Personal;
+ public Redpoint parentRedpoint = new Redpoint(MainRedDot.MailRepoint);
+ public Redpoint tabRedpoint0;
+ public Redpoint tabRedpoint1;
+ public event Action OnUpdateMailListEvent;// 鏇存柊閭欢鍒楄〃鏁版嵁
+ public event Action OnUpdateMailStateChangeEvent;// 鏇存柊閭欢鐘舵�佸彉鏇�
+ public readonly string dateFormat = "yyyy-MM-dd";
+ public string nowUuid = string.Empty;
+ public override void Init()
+ {
+ tabRedpoint0 = new Redpoint(MainRedDot.MailRepoint, GetTabRedpointId(MailCategory.Personal));
+ tabRedpoint1 = new Redpoint(MainRedDot.MailRepoint, GetTabRedpointId(MailCategory.Global));
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitializeEvent;
+ }
+
+ public override void Release()
+ {
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitializeEvent;
+ }
+
+ public void OnBeforePlayerDataInitializeEvent()
+ {
+ mailDataDict.Clear();
+ }
+
+ public bool HasNoReadMail(MailCategory category)
+ {
+ var list = GetMailList(category);
+ if (list.IsNullOrEmpty())
+ return false;
+
+ foreach (var guid in list)
+ {
+ if (mailDataDict.TryGetValue(guid, out var mailData) && mailData.MailState == 1)
+ return true;
+ }
+ return false;
+ }
+
+ public int GetTabRedpointId(MailCategory type)
+ {
+ return MainRedDot.MailRepoint * 10 + (int)type;
+ }
+
+ public void UpdatePersonalRedPoint()
+ {
+ if (tabRedpoint0 == null)
+ return;
+ tabRedpoint0.state = RedPointState.None;
+ if (HasNoReadMail(MailCategory.Personal))
+ {
+ tabRedpoint0.state = RedPointState.Simple;
+ }
+ }
+
+ public void UpdateGlobalRedPoint()
+ {
+ if (tabRedpoint1 == null) return;
+ tabRedpoint1.state = RedPointState.None;
+ if (HasNoReadMail(MailCategory.Global))
+ {
+ tabRedpoint1.state = RedPointState.Simple;
+ }
+ }
+
+ /// <summary>
+ /// 鏇存柊閭欢绾㈢偣鎻愮ず鐘舵��
+ /// </summary>
+ public void UpdateRedPoint()
+ {
+ UpdatePersonalRedPoint();
+ UpdateGlobalRedPoint();
+ }
+
+ public bool TryGetMailData(string uuid, out MailData mailData)
+ {
+ return mailDataDict.TryGetValue(uuid, out mailData);
+ }
+ public string FormatCreateMailTime(DateTime createDateTime)
+ {
+ TimeSpan diff = TimeUtility.ServerNow - createDateTime;
+ if (diff.TotalHours <= 24)
+ {
+ int hours = (int)Math.Floor(diff.TotalHours);
+ return Language.Get("Mail05", hours);
+ }
+ else
+ {
+ return createDateTime.ToString(dateFormat);
+ }
+ }
+
+ //杩斿洖鏈夋晥鏈熷ぉ鏁�(姝f暟=宸茶繃鏈熷ぉ鏁帮紝璐熸暟=鍓╀綑澶╂暟)
+ public int GetMailExpiryDays(DateTime createDateTime, int limitDays)
+ {
+ DateTime expiryDate = createDateTime.AddDays(limitDays);
+ return (int)(TimeUtility.ServerNow - expiryDate).TotalDays;
+ }
+
+
+ public List<string> GetMailList(MailCategory mailCategory)
+ {
+ var result = new List<string>();
+ foreach (var kvp in mailDataDict)
+ {
+ if (kvp.Value.Category == mailCategory)
+ {
+ result.Add(kvp.Key);
+ }
+ }
+ return result;
+ }
+
+ public List<string> GetSortMailScrList(MailCategory mailCategory)
+ {
+ List<string> resList = GetMailList(mailCategory);
+ return resList.OrderByDescending(guid => mailDataDict[guid].CreateDateTime).ToList();
+ }
+
+ /// <summary>
+ /// 鏇存柊閭欢鍒楄〃鏁版嵁
+ /// </summary>
+ /// <param name="vNetData">浠庢湇鍔″櫒鎺ユ敹鐨勯偖浠跺垪琛ㄦ暟鎹寘</param>
+ public void UpdateMailList(HA362_tagMCMailList vNetData)
+ {
+ if (vNetData == null) return;
+
+ // 鏇存柊閭欢鏁版嵁瀛楀吀
+ foreach (var mail in vNetData.MailList)
+ {
+ var category = vNetData.IsServerMail == 1 ? MailCategory.Global : MailCategory.Personal;
+ var mailData = new MailData();
+
+ mailData.Category = category;
+ mailData.GUID = mail.GUID;
+ mailData.Type = mail.Type;
+ mailData.CreateTime = mail.CreateTime;
+ mailData.CreateDateTime = Convert.ToDateTime(UIHelper.GetTime(mail.CreateTime));
+ mailData.LimitDays = mail.LimitDays;
+ mailData.Title = mail.Title;
+ mailData.Text = mail.Text;
+ mailData.MailState = mail.MailState;
+
+ mailData.Items = mail.Items?.Select(i => new MailItemData
+ {
+ ItemID = i.ItemID,
+ Count = i.Count,
+ IsBind = i.IsBind,
+ UserData = i.UserData
+ }).ToList();
+ mailDataDict[mail.GUID] = mailData;
+ }
+
+ UpdateRedPoint();
+ OnUpdateMailListEvent?.Invoke();
+ }
+
+ /// <summary>
+ /// 鏇存柊閭欢鐘舵�佸彉鏇�
+ /// </summary>
+ /// <param name="vNetData">浠庢湇鍔″櫒鎺ユ敹鐨勯偖浠剁姸鎬佸彉鏇存暟鎹寘</param>
+ public void UpdateMailStateChange(HA363_tagMCMailStateChange vNetData)
+ {
+ if (vNetData == null || vNetData.MailList == null) return;
+
+ foreach (var stateChange in vNetData.MailList)
+ {
+ if (mailDataDict.TryGetValue(stateChange.GUID, out var mailData))
+ {
+ if (stateChange.MailState == 4)
+ {
+ mailDataDict.Remove(stateChange.GUID);
+ continue;
+ }
+ mailData.MailState = stateChange.MailState;
+ mailDataDict[stateChange.GUID] = mailData;
+ }
+ }
+
+ UpdateRedPoint();
+ OnUpdateMailStateChangeEvent?.Invoke();
+ }
+
+
+ /// <summary>
+ /// 闃呰閭欢
+ /// </summary>
+ /// <param name="GUID">閭欢GUID</param>
+ public void ReadMail(string GUID)
+ {
+ if (string.IsNullOrEmpty(GUID))
+ {
+ Debug.LogError("闃呰閭欢GUID涓嶈兘涓虹┖");
+ return;
+ }
+ SendRequestMail(GUID, 0);
+ }
+
+ /// <summary>
+ /// 棰嗗彇閭欢
+ /// </summary>
+ /// <param name="GUID">閭欢GUID锛屼负绌烘椂鎵归噺棰嗗彇鎵�鏈夐偖浠�</param>
+ public void ClaimMail(string GUID = null)
+ {
+ SendRequestMail(GUID, 1);
+ }
+
+ /// <summary>
+ /// 鍒犻櫎閭欢
+ /// </summary>
+ /// <param name="GUID">閭欢GUID锛屼负绌烘椂鎵归噺鍒犻櫎宸查鍙栨垨鏃犵墿鍝佺殑宸茶閭欢</param>
+ public void DeleteMail(string GUID = null)
+ {
+ SendRequestMail(GUID, 2);
+ }
+
+ /// <summary>
+ /// 鍙戦�侀偖浠惰姹傚埌鏈嶅姟鍣�
+ /// </summary>
+ /// <param name="GUID">閭欢GUID</param>
+ /// <param name="ReqType">璇锋眰绫诲瀷 0-璁剧疆宸茶锛�1-棰嗗彇閭欢锛�2-鍒犻櫎閭欢</param>
+ public void SendRequestMail(string GUID, byte ReqType)
+ {
+ CA537_tagCMRequestMail pack = new CA537_tagCMRequestMail();
+ pack.GUID = GUID;
+ pack.ReqType = ReqType;
+ GameNetSystem.Instance.SendInfo(pack);
+ }
+
+ //娌℃湁涓�涓彲棰嗗彇鐨勪釜浜洪偖浠�
+ public bool IsCanHaveMail()
+ {
+ var personalMails = GetMailList(MailCategory.Personal);
+ return personalMails.Any(guid =>
+ mailDataDict.TryGetValue(guid, out var mail) &&
+ mail.MailState != 3 &&
+ mail.Items != null &&
+ mail.Items.Count > 0
+ );
+ }
+ }
+
+ public enum MailCategory
+ {
+ Personal = 0, // 涓汉閭欢
+ Global = 1 // 鍏ㄦ湇閭欢
+ }
+
+ public class MailItemData
+ {
+ public uint ItemID; //鐗╁搧ID
+ public uint Count; //鏁伴噺
+ public byte IsBind; //鏄惁缁戝畾
+ public string UserData; //鑷畾涔夋暟鎹�
+ }
+
+ public class MailData
+ {
+ public MailCategory Category;
+ public string GUID; //閭欢GUID
+ public byte Type; //閭欢绫诲瀷锛屾殏鏃堕粯璁�0
+ public string CreateTime; //鍒涘缓鏃堕棿
+ public DateTime CreateDateTime;
+ public byte LimitDays; //鏈夋晥澶╂暟
+ public string Title; //鏍囬
+ public string Text; //鍐呭
+ public byte MailState; //閭欢鐘舵�侊細 0-鏈煡锛�1-鏈锛�2-宸茶锛�3-宸查锛�
+ public List<MailItemData> Items; //鐗╁搧淇℃伅
+
+ /// <summary>
+ /// 鍒ゆ柇鏄惁涓烘ā鏉跨被鍨嬮偖浠�
+ /// </summary>
+ /// <returns>true-妯℃澘閭欢, false-鏅�氶偖浠�</returns>
+ public bool IsTemplateMail()
+ {
+ if (string.IsNullOrEmpty(Title))
+ return false;
+
+ return Title.StartsWith("<T>") && Title.EndsWith("</T>");
+ }
+
+ /// <summary>
+ /// 鑾峰彇妯℃澘閭欢鐨勬ā鏉縦ey
+ /// </summary>
+ /// <returns>妯℃澘key锛屽鏋滀笉鏄ā鏉块偖浠惰繑鍥炵┖瀛楃涓�</returns>
+ public string GetTemplateKey()
+ {
+ if (!IsTemplateMail())
+ return string.Empty;
+
+ // 妯℃澘鏍煎紡: <T>key</T>
+ // 璺宠繃寮�澶寸殑"<T>" (3瀛楃)
+ // 鍙栦腑闂撮儴鍒嗭紝鎬婚暱搴﹀噺鍘�"<T>"鍜�"</T>"鍏�7瀛楃
+ const int prefixLength = 3; // "<T>"闀垮害
+ const int suffixLength = 4; // "</T>"闀垮害
+ return Title.Substring(prefixLength, Title.Length - (prefixLength + suffixLength));
+ }
+
+ /// <summary>
+ /// 鑾峰彇妯℃澘閭欢鐨勫弬鏁板垪琛�
+ /// </summary>
+ /// <returns>鍙傛暟鍒楄〃锛屽鏋滀笉鏄ā鏉块偖浠舵垨鍙傛暟涓虹┖鍒欒繑鍥炵┖鍒楄〃</returns>
+ public List<string> GetTemplateParams()
+ {
+ if (!IsTemplateMail() || string.IsNullOrEmpty(Text))
+ return new List<string>();
+
+ try
+ {
+ // 鍙傛暟鏍煎紡涓篔SON鏁扮粍锛歔鍙傛暟1, 鍙傛暟2, ...]
+ return JsonUtility.FromJson<List<string>>(Text);
+ }
+ catch
+ {
+ return new List<string>();
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/Main/Manager/GameSystemManager/MailManager.cs.meta b/Main/System/Mail/MailManager.cs.meta
similarity index 100%
rename from Main/Manager/GameSystemManager/MailManager.cs.meta
rename to Main/System/Mail/MailManager.cs.meta
diff --git a/Main/System/GatheringSoul.meta b/Main/System/Main.meta
similarity index 77%
copy from Main/System/GatheringSoul.meta
copy to Main/System/Main.meta
index b6009f9..e2e96ab 100644
--- a/Main/System/GatheringSoul.meta
+++ b/Main/System/Main.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: e738788740f4f644e9d10089a38d623d
+guid: 3df002b1f0eb7264f922ecd63ac48be6
folderAsset: yes
DefaultImporter:
externalObjects: {}
diff --git a/Main/UI/Main/MainWin.cs b/Main/System/Main/MainWin.cs
similarity index 99%
rename from Main/UI/Main/MainWin.cs
rename to Main/System/Main/MainWin.cs
index 6b059df..bafdf44 100644
--- a/Main/UI/Main/MainWin.cs
+++ b/Main/System/Main/MainWin.cs
@@ -1,204 +1,204 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.UI;
-
-/// <summary>
-/// 娓告垙涓荤晫闈�
-/// </summary>
-public class MainWin : UIBase
-{
- private GameObject windowBackground;
-
- // 搴曢儴鎸夐挳缁�
- private Button[] bottomTabButtons;
-
- // 褰撳墠閫変腑鐨勫簳閮ㄦ爣绛剧储寮�
- private int currentTabIndex = 0;
-
- // 褰撳墠鎵撳紑鐨勫瓙鐣岄潰
- private UIBase currentSubUI;
-
- /// <summary>
- /// 鍒濆鍖栫粍浠�
- /// </summary>
- protected override void InitComponent()
- {
- base.InitComponent();
-
- windowBackground = transform.Find("RawImgBackground").gameObject;
-
- bottomTabButtons = new Button[5];
-
- for (int i = 1; i <= 5; i++)
- {
- string buttonName = "Buttons/Button" + i;
- bottomTabButtons[i-1] = transform.Find(buttonName).GetComponent<Button>();
- }
-
- // 鍒濆鍖朥I缁勪欢浜嬩欢
- InitButtonEvents();
- }
-
- /// <summary>
- /// 鍒濆鍖朥I缁勪欢浜嬩欢
- /// </summary>
- private void InitButtonEvents()
- {
- // 鍒濆鍖栧簳閮ㄦ寜閽�
- for (int i = 0; i < bottomTabButtons.Length; i++)
- {
- int index = i; // 鎹曡幏绱㈠紩
- bottomTabButtons[i].onClick.AddListener(() => {
- OnBottomTabButtonClicked(index);
- });
- }
- }
-
- protected override void OnOpen()
- {
- base.OnOpen();
-
- // 榛樿閫変腑绗竴涓爣绛�
- SelectBottomTab(0);
-
- // 鍒锋柊UI
- Refresh();
- }
-
- public override void Refresh()
- {
- UpdatePlayerInfo();
- UpdateCurrency();
- }
-
- /// <summary>
- /// 鏇存柊鐜╁淇℃伅
- /// </summary>
- private void UpdatePlayerInfo()
- {
- // 浠庣帺瀹舵暟鎹腑鑾峰彇淇℃伅骞舵洿鏂癠I
- // 渚嬪锛�
- // playerNameText.text = PlayerData.Instance.Name;
- // playerLevelText.text = "Lv." + PlayerData.Instance.Level;
- // powerText.text = PlayerData.Instance.Power.ToString();
- // expSlider.value = PlayerData.Instance.ExpRatio;
- }
-
- /// <summary>
- /// 鏇存柊璐у竵淇℃伅
- /// </summary>
- private void UpdateCurrency()
- {
- // 浠庣帺瀹舵暟鎹腑鑾峰彇璐у竵淇℃伅骞舵洿鏂癠I
- // 渚嬪锛�
- // goldText.text = PlayerData.Instance.Gold.ToString();
- // diamondText.text = PlayerData.Instance.Diamond.ToString();
- // energyText.text = PlayerData.Instance.Energy + "/" + PlayerData.Instance.MaxEnergy;
- }
-
- /// <summary>
- /// 搴曢儴鏍囩鎸夐挳鐐瑰嚮
- /// </summary>
- private void OnBottomTabButtonClicked(int index)
- {
- SelectBottomTab(index);
- }
-
- /// <summary>
- /// 閫夋嫨搴曢儴鏍囩
- /// </summary>
- private void SelectBottomTab(int index)
- {
- // 濡傛灉鐐瑰嚮褰撳墠宸查�変腑鐨勬爣绛撅紝涓嶅仛澶勭悊
- if (currentTabIndex == index && currentSubUI != null)
- {
- return;
- }
-
- // 鏇存柊褰撳墠閫変腑鐨勬爣绛剧储寮�
- currentTabIndex = index;
-
- // 鏇存柊鎸夐挳鐘舵��
- UpdateButtonsState();
-
- // 鍏抽棴褰撳墠鎵撳紑鐨勫瓙鐣岄潰
- CloseCurrentSubUI();
-
- // 鏍规嵁閫変腑鐨勬爣绛炬墦寮�瀵瑰簲鐨勭晫闈�
- OpenSubUIByTabIndex(index);
- }
-
- /// <summary>
- /// 鏇存柊鎸夐挳鐘舵��
- /// </summary>
- private void UpdateButtonsState()
- {
- // 閬嶅巻鎵�鏈夋寜閽紝璁剧疆閫変腑鐘舵��
- for (int i = 0; i < bottomTabButtons.Length; i++)
- {
- // 杩欓噷鍙互鏍规嵁鏄惁閫変腑璁剧疆鎸夐挳鐨勮瑙夋晥鏋�
- // 渚嬪锛氭敼鍙樺浘鐗囥�侀鑹茬瓑
- // bottomTabButtons[i].GetComponent<Image>().color = (i == currentTabIndex) ? Color.blue : Color.white;
-
- // 鎴栬�呮縺娲�/绂佺敤閫変腑鍥炬爣
- bottomTabButtons[i].image.color = (i == currentTabIndex) ? Color.white : Color.gray;
- }
- }
-
- /// <summary>
- /// 鍏抽棴褰撳墠鎵撳紑鐨勫瓙鐣岄潰
- /// </summary>
- private void CloseCurrentSubUI()
- {
- if (currentSubUI != null)
- {
- // 鍏抽棴褰撳墠鐣岄潰
- currentSubUI.CloseWindow();
- currentSubUI = null;
- }
- }
-
- /// <summary>
- /// 鏍规嵁鏍囩绱㈠紩鎵撳紑瀵瑰簲鐨勫瓙鐣岄潰
- /// </summary>
- private void OpenSubUIByTabIndex(int index)
- {
-
- Debug.Log("鎵撳紑瀛愮晫闈� : " + index);
- // 涓诲煄 闃靛 鍚岀洘 绂忓埄 鍐掗櫓
- windowBackground.SetActive(index != 4);
- //鏍规嵁绱㈠紩鎵撳紑涓嶅悓鐨勭晫闈�
- switch (index)
- {
- case 0:
- // 渚嬪锛氭墦寮�涓婚〉鐣岄潰
- // currentSubUI = UIManager.Instance.OpenUI<HomeUI>();
- Debug.Log("鎵撳紑涓诲煄鐣岄潰");
- break;
- case 1:
- // 渚嬪锛氭墦寮�瑙掕壊鐣岄潰
- // currentSubUI = UIManager.Instance.OpenUI<CharacterUI>();
- Debug.Log("鎵撳紑闃靛鐣岄潰");
- break;
- case 2:
- // 渚嬪锛氭墦寮�鑳屽寘鐣岄潰
- // currentSubUI = UIManager.Instance.OpenUI<BagUI>();
- Debug.Log("鎵撳紑鍚岀洘鐣岄潰");
- break;
- case 3:
- // 渚嬪锛氭墦寮�浠诲姟鐣岄潰
- // currentSubUI = UIManager.Instance.OpenUI<QuestUI>();
- Debug.Log("鎵撳紑绂忓埄鐣岄潰");
- break;
- case 4:
- // 渚嬪锛氭墦寮�璁剧疆鐣岄潰
- currentSubUI = UIManager.Instance.OpenWindow<PlaceWin>();
- Debug.Log("鎵撳紑鍐掗櫓鐣岄潰");
- break;
- default:
- Debug.LogWarning("鏈煡鐨勬爣绛剧储寮�: " + index);
- break;
- }
- }
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+/// <summary>
+/// 娓告垙涓荤晫闈�
+/// </summary>
+public class MainWin : UIBase
+{
+ private GameObject windowBackground;
+
+ // 搴曢儴鎸夐挳缁�
+ private Button[] bottomTabButtons;
+
+ // 褰撳墠閫変腑鐨勫簳閮ㄦ爣绛剧储寮�
+ private int currentTabIndex = 0;
+
+ // 褰撳墠鎵撳紑鐨勫瓙鐣岄潰
+ private UIBase currentSubUI;
+
+ /// <summary>
+ /// 鍒濆鍖栫粍浠�
+ /// </summary>
+ protected override void InitComponent()
+ {
+ base.InitComponent();
+
+ windowBackground = transform.Find("RawImgBackground").gameObject;
+
+ bottomTabButtons = new Button[5];
+
+ for (int i = 1; i <= 5; i++)
+ {
+ string buttonName = "Buttons/Button" + i;
+ bottomTabButtons[i-1] = transform.Find(buttonName).GetComponent<Button>();
+ }
+
+ // 鍒濆鍖朥I缁勪欢浜嬩欢
+ InitButtonEvents();
+ }
+
+ /// <summary>
+ /// 鍒濆鍖朥I缁勪欢浜嬩欢
+ /// </summary>
+ private void InitButtonEvents()
+ {
+ // 鍒濆鍖栧簳閮ㄦ寜閽�
+ for (int i = 0; i < bottomTabButtons.Length; i++)
+ {
+ int index = i; // 鎹曡幏绱㈠紩
+ bottomTabButtons[i].onClick.AddListener(() => {
+ OnBottomTabButtonClicked(index);
+ });
+ }
+ }
+
+ protected override void OnOpen()
+ {
+ base.OnOpen();
+
+ // 榛樿閫変腑绗竴涓爣绛�
+ SelectBottomTab(0);
+
+ // 鍒锋柊UI
+ Refresh();
+ }
+
+ public override void Refresh()
+ {
+ UpdatePlayerInfo();
+ UpdateCurrency();
+ }
+
+ /// <summary>
+ /// 鏇存柊鐜╁淇℃伅
+ /// </summary>
+ private void UpdatePlayerInfo()
+ {
+ // 浠庣帺瀹舵暟鎹腑鑾峰彇淇℃伅骞舵洿鏂癠I
+ // 渚嬪锛�
+ // playerNameText.text = PlayerData.Instance.Name;
+ // playerLevelText.text = "Lv." + PlayerData.Instance.Level;
+ // powerText.text = PlayerData.Instance.Power.ToString();
+ // expSlider.value = PlayerData.Instance.ExpRatio;
+ }
+
+ /// <summary>
+ /// 鏇存柊璐у竵淇℃伅
+ /// </summary>
+ private void UpdateCurrency()
+ {
+ // 浠庣帺瀹舵暟鎹腑鑾峰彇璐у竵淇℃伅骞舵洿鏂癠I
+ // 渚嬪锛�
+ // goldText.text = PlayerData.Instance.Gold.ToString();
+ // diamondText.text = PlayerData.Instance.Diamond.ToString();
+ // energyText.text = PlayerData.Instance.Energy + "/" + PlayerData.Instance.MaxEnergy;
+ }
+
+ /// <summary>
+ /// 搴曢儴鏍囩鎸夐挳鐐瑰嚮
+ /// </summary>
+ private void OnBottomTabButtonClicked(int index)
+ {
+ SelectBottomTab(index);
+ }
+
+ /// <summary>
+ /// 閫夋嫨搴曢儴鏍囩
+ /// </summary>
+ private void SelectBottomTab(int index)
+ {
+ // 濡傛灉鐐瑰嚮褰撳墠宸查�変腑鐨勬爣绛撅紝涓嶅仛澶勭悊
+ if (currentTabIndex == index && currentSubUI != null)
+ {
+ return;
+ }
+
+ // 鏇存柊褰撳墠閫変腑鐨勬爣绛剧储寮�
+ currentTabIndex = index;
+
+ // 鏇存柊鎸夐挳鐘舵��
+ UpdateButtonsState();
+
+ // 鍏抽棴褰撳墠鎵撳紑鐨勫瓙鐣岄潰
+ CloseCurrentSubUI();
+
+ // 鏍规嵁閫変腑鐨勬爣绛炬墦寮�瀵瑰簲鐨勭晫闈�
+ OpenSubUIByTabIndex(index);
+ }
+
+ /// <summary>
+ /// 鏇存柊鎸夐挳鐘舵��
+ /// </summary>
+ private void UpdateButtonsState()
+ {
+ // 閬嶅巻鎵�鏈夋寜閽紝璁剧疆閫変腑鐘舵��
+ for (int i = 0; i < bottomTabButtons.Length; i++)
+ {
+ // 杩欓噷鍙互鏍规嵁鏄惁閫変腑璁剧疆鎸夐挳鐨勮瑙夋晥鏋�
+ // 渚嬪锛氭敼鍙樺浘鐗囥�侀鑹茬瓑
+ // bottomTabButtons[i].GetComponent<Image>().color = (i == currentTabIndex) ? Color.blue : Color.white;
+
+ // 鎴栬�呮縺娲�/绂佺敤閫変腑鍥炬爣
+ bottomTabButtons[i].image.color = (i == currentTabIndex) ? Color.white : Color.gray;
+ }
+ }
+
+ /// <summary>
+ /// 鍏抽棴褰撳墠鎵撳紑鐨勫瓙鐣岄潰
+ /// </summary>
+ private void CloseCurrentSubUI()
+ {
+ if (currentSubUI != null)
+ {
+ // 鍏抽棴褰撳墠鐣岄潰
+ currentSubUI.CloseWindow();
+ currentSubUI = null;
+ }
+ }
+
+ /// <summary>
+ /// 鏍规嵁鏍囩绱㈠紩鎵撳紑瀵瑰簲鐨勫瓙鐣岄潰
+ /// </summary>
+ private void OpenSubUIByTabIndex(int index)
+ {
+
+ Debug.Log("鎵撳紑瀛愮晫闈� : " + index);
+ // 涓诲煄 闃靛 鍚岀洘 绂忓埄 鍐掗櫓
+ windowBackground.SetActive(index != 4);
+ //鏍规嵁绱㈠紩鎵撳紑涓嶅悓鐨勭晫闈�
+ switch (index)
+ {
+ case 0:
+ // 渚嬪锛氭墦寮�涓婚〉鐣岄潰
+ // currentSubUI = UIManager.Instance.OpenUI<HomeUI>();
+ Debug.Log("鎵撳紑涓诲煄鐣岄潰");
+ break;
+ case 1:
+ // 渚嬪锛氭墦寮�瑙掕壊鐣岄潰
+ // currentSubUI = UIManager.Instance.OpenUI<CharacterUI>();
+ Debug.Log("鎵撳紑闃靛鐣岄潰");
+ break;
+ case 2:
+ // 渚嬪锛氭墦寮�鑳屽寘鐣岄潰
+ // currentSubUI = UIManager.Instance.OpenUI<BagUI>();
+ Debug.Log("鎵撳紑鍚岀洘鐣岄潰");
+ break;
+ case 3:
+ // 渚嬪锛氭墦寮�浠诲姟鐣岄潰
+ // currentSubUI = UIManager.Instance.OpenUI<QuestUI>();
+ Debug.Log("鎵撳紑绂忓埄鐣岄潰");
+ break;
+ case 4:
+ // 渚嬪锛氭墦寮�璁剧疆鐣岄潰
+ currentSubUI = UIManager.Instance.OpenWindow<PlaceWin>();
+ Debug.Log("鎵撳紑鍐掗櫓鐣岄潰");
+ break;
+ default:
+ Debug.LogWarning("鏈煡鐨勬爣绛剧储寮�: " + index);
+ break;
+ }
+ }
}
\ No newline at end of file
diff --git a/Main/UI/Main/MainWin.cs.meta b/Main/System/Main/MainWin.cs.meta
similarity index 100%
rename from Main/UI/Main/MainWin.cs.meta
rename to Main/System/Main/MainWin.cs.meta
diff --git a/Main/UI/Place.meta b/Main/System/Place.meta
similarity index 100%
rename from Main/UI/Place.meta
rename to Main/System/Place.meta
diff --git a/Main/UI/Place/PlaceWin.cs b/Main/System/Place/PlaceWin.cs
similarity index 99%
rename from Main/UI/Place/PlaceWin.cs
rename to Main/System/Place/PlaceWin.cs
index a93134d..9e0caff 100644
--- a/Main/UI/Place/PlaceWin.cs
+++ b/Main/System/Place/PlaceWin.cs
@@ -1,62 +1,62 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEngine.UI;
-
-/// <summary>
-/// 鍦烘櫙鐣岄潰
-/// </summary>
-public class PlaceWin : UIBase
-{
- protected Button btnExplore;
-
- // protected
-
- /// <summary>
- /// 鍒濆鍖栫粍浠�
- /// </summary>
- protected override void InitComponent()
- {
- base.InitComponent();
-
- // 鍦ㄨ繖閲屽垵濮嬪寲缁勪欢
- btnExplore = transform.Find("BtnExplore").GetComponent<Button>();
- btnExplore.onClick.AddListener(OnExploreClick);
- }
-
-
- /// <summary>
- /// 绐楀彛鎵撳紑鏃惰皟鐢�
- /// </summary>
- protected override void OnOpen()
- {
- base.OnOpen();
-
- // 绐楀彛鎵撳紑鏃剁殑閫昏緫
-
- }
-
- /// <summary>
- /// 绐楀彛鍏抽棴鏃惰皟鐢�
- /// </summary>
- protected override void OnClose()
- {
- base.OnClose();
-
- // 绐楀彛鍏抽棴鏃剁殑閫昏緫
-
- }
-
- /// <summary>
- /// 鍒锋柊鐣岄潰
- /// </summary>
- public override void Refresh()
- {
- // 鍒锋柊鐣岄潰鐨勯�昏緫
- }
-
- private void OnExploreClick()
- {
- // UIManager.Instance.OpenUI<ExploreWin>();
- }
-}
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+/// <summary>
+/// 鍦烘櫙鐣岄潰
+/// </summary>
+public class PlaceWin : UIBase
+{
+ protected Button btnExplore;
+
+ // protected
+
+ /// <summary>
+ /// 鍒濆鍖栫粍浠�
+ /// </summary>
+ protected override void InitComponent()
+ {
+ base.InitComponent();
+
+ // 鍦ㄨ繖閲屽垵濮嬪寲缁勪欢
+ btnExplore = transform.Find("BtnExplore").GetComponent<Button>();
+ btnExplore.onClick.AddListener(OnExploreClick);
+ }
+
+
+ /// <summary>
+ /// 绐楀彛鎵撳紑鏃惰皟鐢�
+ /// </summary>
+ protected override void OnOpen()
+ {
+ base.OnOpen();
+
+ // 绐楀彛鎵撳紑鏃剁殑閫昏緫
+
+ }
+
+ /// <summary>
+ /// 绐楀彛鍏抽棴鏃惰皟鐢�
+ /// </summary>
+ protected override void OnClose()
+ {
+ base.OnClose();
+
+ // 绐楀彛鍏抽棴鏃剁殑閫昏緫
+
+ }
+
+ /// <summary>
+ /// 鍒锋柊鐣岄潰
+ /// </summary>
+ public override void Refresh()
+ {
+ // 鍒锋柊鐣岄潰鐨勯�昏緫
+ }
+
+ private void OnExploreClick()
+ {
+ // UIManager.Instance.OpenUI<ExploreWin>();
+ }
+}
diff --git a/Main/UI/Place/PlaceWin.cs.meta b/Main/System/Place/PlaceWin.cs.meta
similarity index 100%
rename from Main/UI/Place/PlaceWin.cs.meta
rename to Main/System/Place/PlaceWin.cs.meta
diff --git a/Main/System/GatheringSoul.meta b/Main/System/Task.meta
similarity index 77%
copy from Main/System/GatheringSoul.meta
copy to Main/System/Task.meta
index b6009f9..57ec414 100644
--- a/Main/System/GatheringSoul.meta
+++ b/Main/System/Task.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: e738788740f4f644e9d10089a38d623d
+guid: 0db20ba57de2cce4b851e1a61069ac25
folderAsset: yes
DefaultImporter:
externalObjects: {}
diff --git a/Main/Manager/GameSystemManager/TaskManager.cs b/Main/System/Task/TaskManager.cs
similarity index 100%
rename from Main/Manager/GameSystemManager/TaskManager.cs
rename to Main/System/Task/TaskManager.cs
diff --git a/Main/Manager/GameSystemManager/TaskManager.cs.meta b/Main/System/Task/TaskManager.cs.meta
similarity index 100%
rename from Main/Manager/GameSystemManager/TaskManager.cs.meta
rename to Main/System/Task/TaskManager.cs.meta
diff --git a/Main/Team.meta b/Main/System/Team.meta
similarity index 100%
rename from Main/Team.meta
rename to Main/System/Team.meta
diff --git a/Main/Team/TeamBase.Properties.cs b/Main/System/Team/TeamBase.Properties.cs
similarity index 100%
rename from Main/Team/TeamBase.Properties.cs
rename to Main/System/Team/TeamBase.Properties.cs
diff --git a/Main/Team/TeamBase.Properties.cs.meta b/Main/System/Team/TeamBase.Properties.cs.meta
similarity index 100%
rename from Main/Team/TeamBase.Properties.cs.meta
rename to Main/System/Team/TeamBase.Properties.cs.meta
diff --git a/Main/Team/TeamBase.cs b/Main/System/Team/TeamBase.cs
similarity index 100%
rename from Main/Team/TeamBase.cs
rename to Main/System/Team/TeamBase.cs
diff --git a/Main/Team/TeamBase.cs.meta b/Main/System/Team/TeamBase.cs.meta
similarity index 100%
rename from Main/Team/TeamBase.cs.meta
rename to Main/System/Team/TeamBase.cs.meta
diff --git a/Main/Team/TeamCard.cs b/Main/System/Team/TeamCard.cs
similarity index 100%
rename from Main/Team/TeamCard.cs
rename to Main/System/Team/TeamCard.cs
diff --git a/Main/Team/TeamCard.cs.meta b/Main/System/Team/TeamCard.cs.meta
similarity index 100%
rename from Main/Team/TeamCard.cs.meta
rename to Main/System/Team/TeamCard.cs.meta
diff --git a/Main/Team/TeamConst.cs b/Main/System/Team/TeamConst.cs
similarity index 100%
rename from Main/Team/TeamConst.cs
rename to Main/System/Team/TeamConst.cs
diff --git a/Main/Team/TeamConst.cs.meta b/Main/System/Team/TeamConst.cs.meta
similarity index 100%
rename from Main/Team/TeamConst.cs.meta
rename to Main/System/Team/TeamConst.cs.meta
diff --git a/Main/System/GatheringSoul.meta b/Main/System/UIBase.meta
similarity index 77%
rename from Main/System/GatheringSoul.meta
rename to Main/System/UIBase.meta
index b6009f9..097a26f 100644
--- a/Main/System/GatheringSoul.meta
+++ b/Main/System/UIBase.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: e738788740f4f644e9d10089a38d623d
+guid: c346976173115b649a424fbbd7dc50e6
folderAsset: yes
DefaultImporter:
externalObjects: {}
diff --git a/Main/UI/OneLevelWin.cs b/Main/System/UIBase/OneLevelWin.cs
similarity index 100%
rename from Main/UI/OneLevelWin.cs
rename to Main/System/UIBase/OneLevelWin.cs
diff --git a/Main/UI/OneLevelWin.cs.meta b/Main/System/UIBase/OneLevelWin.cs.meta
similarity index 100%
rename from Main/UI/OneLevelWin.cs.meta
rename to Main/System/UIBase/OneLevelWin.cs.meta
diff --git a/Main/UI/UIBase.cs b/Main/System/UIBase/UIBase.cs
similarity index 99%
rename from Main/UI/UIBase.cs
rename to Main/System/UIBase/UIBase.cs
index 9aa46cb..e78de21 100644
--- a/Main/UI/UIBase.cs
+++ b/Main/System/UIBase/UIBase.cs
@@ -1,815 +1,815 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using DG.Tweening;
-using UnityEngine.UI; // DOTween 鎻掍欢寮曠敤
-using Cysharp.Threading.Tasks;
-using System;
-
-public enum UILayer
-{
- Static, // 闈欐�乁I 閫傚悎鍋� 甯搁┗鐢ㄧ殑濡� 涓荤晫闈�
- Bottom, // 鏈�搴曞眰 閫傚悎鍋� 涓荤晫闈笂闈㈢殑 涓�绾х獥鍙� 涓�绾х晫闈�
- Mid, // 閫傚悎鍋� 浜岀骇绐楀彛 浜岀骇鐣岄潰
- Top, // 閫傚悎鍋氭彁绀哄脊绐�
- System // 缃戠粶寮圭獥/鍏朵粬閲嶈寮圭獥/绯荤粺鍏憡
-}
-
-public enum UIAnimationType
-{
- None, // 鏃犲姩鐢�
- FadeInOut, // 娣″叆娣″嚭
- ScaleInOut, // 缂╂斁
- SlideFromTop, // 浠庨《閮ㄦ粦鍏�
- SlideFromBottom, // 浠庡簳閮ㄦ粦鍏�
- SlideFromLeft, // 浠庡乏渚ф粦鍏�
- SlideFromRight // 浠庡彸渚ф粦鍏�
-}
-
-[RequireComponent(typeof(Canvas))]
-[RequireComponent(typeof(CanvasGroup))]
-[RequireComponent(typeof(CanvasScaler))]
-public class UIBase : MonoBehaviour
-{
- #region 灞炴�у拰鍙橀噺
-
- // UI鍩烘湰灞炴��
- [SerializeField] public UILayer uiLayer = UILayer.Mid;
- [SerializeField][HideInInspector] public string uiName;
- [SerializeField] public bool isMainUI = false;
- [SerializeField] public bool supportParentChildRelation = true; // 鏂板锛氭槸鍚︽敮鎸佺埗瀛愬叧绯�
-
- // 鎸佷箙鍖栫浉鍏�
- [SerializeField] public bool isPersistent = false;
- [SerializeField][HideInInspector] public int maxIdleRounds = 20;
-
- // 鍔ㄧ敾鐩稿叧
- [SerializeField] public UIAnimationType openAnimationType = UIAnimationType.None;
- [SerializeField] public UIAnimationType closeAnimationType = UIAnimationType.None;
- [SerializeField][HideInInspector] public float animationDuration = 0.3f;
- [SerializeField][HideInInspector] public Ease animationEase = Ease.OutQuad; // 纭繚浣跨敤 DG.Tweening.Ease
-
- // 杩愯鏃剁姸鎬�
- [HideInInspector] public int lastUsedRound = 0;
- [HideInInspector] public UIBase parentUI;
-
- // 瀛怳I绠$悊
- [HideInInspector] public List<UIBase> childrenUI = new List<UIBase>();
-
- // 鎵撳紑閬僵
- [SerializeField] public bool openMask = false;
-
- // 鐐瑰嚮绌虹櫧鍖哄煙鍏抽棴鐣岄潰
- [SerializeField] public bool clickEmptySpaceClose = false;
-
- private GameObject screenMask = null;
-
- private Button btnClickEmptyClose;
-
- protected int functionOrder = 0;
-
- // 鍐呴儴鐘舵��
- protected bool isActive = false;
- protected bool isAnimating = false;
- protected bool isClosing = false; // 鏂板锛氭爣璁版槸鍚︽鍦ㄥ叧闂�
-
- // 缁勪欢寮曠敤
- protected Canvas canvas;
- protected CanvasGroup canvasGroup;
- protected RectTransform rectTransform;
-
- // 鍔ㄧ敾鐩稿叧
- protected Vector3 originalScale;
- protected Vector3 originalPosition;
- protected Sequence currentAnimation;
-
- #endregion
-
- #region Unity鐢熷懡鍛ㄦ湡
-
- protected virtual void Awake()
- {
- // 纭繚 DOTween 宸插垵濮嬪寲
- DOTween.SetTweensCapacity(500, 50);
-
- // 鍦ˋwake涓繘琛屽熀鏈垵濮嬪寲
- InitComponent();
-
- // 淇濆瓨鍘熷鍊肩敤浜庡姩鐢�
- if (rectTransform != null)
- {
- originalScale = rectTransform.localScale;
- originalPosition = rectTransform.anchoredPosition;
- }
-
- ApplySettings();
-
- if (openMask)
- {
- screenMask = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/ScreenMask"), transform);
- screenMask.transform.localScale = Vector3.one;
- screenMask.transform.localPosition = Vector3.zero;
- screenMask.transform.SetAsFirstSibling();
- }
- }
-
- protected virtual void Start()
- {
- // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曡繘琛岄澶栧垵濮嬪寲
- }
-
- protected async UniTask ApplySettings()
- {
- await UniTask.DelayFrame(5);
-
- if (null != transform)
- {
- if (clickEmptySpaceClose)
- {
- GameObject goBtnESC = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/ClickEmptyCloseMask"), transform);
- // Load
- btnClickEmptyClose = goBtnESC.GetComponent<Button>();
- btnClickEmptyClose.AddListener(CloseWindow);
- btnClickEmptyClose.transform.SetAsFirstSibling();
- }
- }
- }
-
- protected async void ExecuteNextFrame(Action _action)
- {
- await UniTask.DelayFrame(1);
- _action?.Invoke();
- }
-
- protected virtual void OnDestroy()
- {
- // 纭繚鍔ㄧ敾琚纭竻鐞�
- if (currentAnimation != null)
- {
- currentAnimation.Kill();
- currentAnimation = null;
- }
- }
-
- #endregion
-
- #region 鍒濆鍖栨柟娉�
-
- // 鑾峰彇蹇呰鐨勭粍浠�
- protected virtual void InitComponent()
- {
- // 鑾峰彇鎴栨坊鍔燙anvas缁勪欢
- canvas = GetComponent<Canvas>();
- if (canvas == null)
- {
- canvas = gameObject.AddComponent<Canvas>();
- }
-
- // 璁剧疆Canvas灞炴��
- canvas.overrideSorting = true;
-
- // 鑾峰彇鎴栨坊鍔燙anvasGroup缁勪欢
- canvasGroup = GetComponent<CanvasGroup>();
- if (canvasGroup == null)
- {
- canvasGroup = gameObject.AddComponent<CanvasGroup>();
- }
-
- // 娣诲姞GraphicRaycaster缁勪欢锛堝鏋滄病鏈夛級
- if (GetComponent<UnityEngine.UI.GraphicRaycaster>() == null)
- {
- gameObject.AddComponent<UnityEngine.UI.GraphicRaycaster>();
- }
-
- // 鑾峰彇RectTransform缁勪欢
- rectTransform = GetComponent<RectTransform>();
- }
-
- #endregion
-
- #region UI鎿嶄綔鏂规硶
-
- // 璁剧疆UI灞傜骇
- public void SetSortingOrder(int order)
- {
- if (canvas != null)
- {
- canvas.sortingOrder = order;
- }
- }
-
- protected virtual void OnPreOpen()
- {
- // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曡繘琛岄澶栫殑棰勬墦寮�鎿嶄綔
- }
-
- protected virtual void OnPreClose()
- {
- // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曡繘琛岄澶栫殑棰勫叧闂搷浣�
- }
-
- // 鎵撳紑UI
- public void HandleOpen()
- {
- OnPreOpen();
- // 濡傛灉姝e湪鎾斁鍔ㄧ敾锛屽厛鍋滄
- StopCurrentAnimation();
-
- // 閲嶇疆鍏抽棴鏍囪
- isClosing = false;
-
- gameObject.SetActive(true);
- isActive = true;
-
- // 鏍规嵁鍔ㄧ敾绫诲瀷鎾斁鎵撳紑鍔ㄧ敾
- PlayOpenAnimation();
-
- OnOpen();
- }
-
- // 鍏抽棴UI - 淇敼鍚庣殑鏂规硶
- public void HandleClose()
- {
- // 濡傛灉宸茬粡鍦ㄥ叧闂繃绋嬩腑锛岀洿鎺ヨ繑鍥�
- if (isClosing) return;
-
- OnPreClose();
-
- // 濡傛灉姝e湪鎾斁鍔ㄧ敾锛屽厛鍋滄
- StopCurrentAnimation();
-
- // 璁剧疆鍏抽棴鏍囪
- isClosing = true;
- isActive = false;
-
- // 绂佺敤浜や簰浣嗕繚鎸佸彲瑙�
- if (canvasGroup != null)
- {
- canvasGroup.interactable = false;
- canvasGroup.blocksRaycasts = false;
- }
-
- // 鏍规嵁鍔ㄧ敾绫诲瀷鎾斁鍏抽棴鍔ㄧ敾
- PlayCloseAnimation();
-
- // 璋冪敤鍏抽棴鍥炶皟
- OnClose();
-
- // 濡傛灉娌℃湁鍏抽棴鍔ㄧ敾锛岀洿鎺ョ鐢ㄦ父鎴忓璞�
- if (closeAnimationType == UIAnimationType.None)
- {
- CompleteClose();
- }
- // 鍚﹀垯鍦ㄥ姩鐢诲畬鎴愬悗绂佺敤娓告垙瀵硅薄锛堝湪PlayCloseAnimation涓鐞嗭級
- }
-
- // 瀹屾垚鍏抽棴杩囩▼ - 鏂板鏂规硶
- protected virtual void CompleteClose()
- {
- gameObject.SetActive(false);
- isClosing = false;
- }
-
- public virtual void CloseWindow()
- {
- UIManager.Instance.CloseWindow(this, false);
- }
-
- // 鍒锋柊UI
- public virtual void Refresh()
- {
- // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曞疄鐜癠I鍒锋柊閫昏緫
- }
-
- // 閿�姣乁I
- public virtual void Destroy()
- {
- // 鍋滄鎵�鏈夊姩鐢�
- StopCurrentAnimation();
-
- ClearChildrenUI();
-
- if (parentUI != null)
- {
- parentUI.RemoveChildUI(this);
- }
-
- Destroy(gameObject);
- }
-
- #endregion
-
- #region 鐗规晥鐩稿叧
-
- /// <summary>
- /// 鎾斁UI鐗规晥
- /// </summary>
- /// <param name="effectName">鐗规晥璧勬簮鍚嶇О</param>
- /// <param name="parent">鐗规晥鐖惰妭鐐癸紝榛樿涓哄綋鍓峌I</param>
- /// <param name="autoDestroy">鏄惁鑷姩閿�姣侊紝榛樿涓簍rue</param>
- /// <param name="destroyDelay">鑷姩閿�姣佸欢杩熸椂闂达紝榛樿涓�5绉�</param>
- /// <returns>鐗规晥娓告垙瀵硅薄</returns>
- public async UniTask<GameObject> PlayUIEffect(int id, Transform parent = null, bool autoDestroy = true, float destroyDelay = 5f)
- {
- // 浣跨敤榛樿鍊�
- if (parent == null) parent = transform;
-
- EffectConfig effectCfg = EffectConfig.Get(id);
-
- if (null == effectCfg)
- {
- return null;
- }
-
- // 鍔犺浇鐗规晥璧勬簮
- var effectPrefab = ResManager.Instance.LoadAsset<GameObject>("UIEffect/" + effectCfg.packageName, effectCfg.fxName);
- if (effectPrefab == null)
- {
- Debug.LogError($"鍔犺浇UI鐗规晥澶辫触: {effectCfg.packageName}");
- return null;
- }
-
- // 瀹炰緥鍖栫壒鏁�
- GameObject effectObj = Instantiate(effectPrefab, parent);
- effectObj.name = $"Effect_{effectCfg.packageName}";
-
- // 娣诲姞鐗规晥绌块�忛樆鎸″櫒
- EffectPenetrationBlocker blocker = effectObj.AddComponent<EffectPenetrationBlocker>();
- blocker.parentCanvas = canvas;
- blocker.UpdateSortingOrder();
-
- // 鑷姩閿�姣�
- if (autoDestroy)
- {
- Destroy(effectObj, destroyDelay);
- }
-
- return effectObj;
- }
-
- /// <summary>
- /// 鍦ㄤ袱涓猆I鍏冪礌涔嬮棿鎾斁鐗规晥锛堟寜鐓ortingOrder鐨勪腑闂村�硷級
- /// </summary>
- /// <param name="effectName">鐗规晥璧勬簮鍚嶇О</param>
- /// <param name="frontElement">鍓嶆櫙UI鍏冪礌锛圛mage鎴朢awImage锛�</param>
- /// <param name="backElement">鑳屾櫙UI鍏冪礌锛圛mage鎴朢awImage锛�</param>
- /// <param name="autoDestroy">鏄惁鑷姩閿�姣侊紝榛樿涓簍rue</param>
- /// <param name="destroyDelay">鑷姩閿�姣佸欢杩熸椂闂达紝榛樿涓�5绉�</param>
- /// <returns>鐗规晥娓告垙瀵硅薄</returns>
- public async UniTask<GameObject> PlayEffectBetweenUIElements(string effectName, Graphic frontElement, Graphic backElement, bool autoDestroy = true, float destroyDelay = 5f)
- {
- if (frontElement == null || backElement == null)
- {
- Debug.LogError("鍓嶆櫙鎴栬儗鏅疷I鍏冪礌涓虹┖");
- return null;
- }
-
- // 纭繚UI鍏冪礌鍦ㄥ綋鍓峌IBase鐨凜anvas涓�
- if (frontElement.canvas != canvas || backElement.canvas != canvas)
- {
- Debug.LogError("UI鍏冪礌涓嶅湪褰撳墠UIBase鐨凜anvas涓�");
- return null;
- }
-
- // 鍔犺浇鐗规晥璧勬簮
- GameObject effectPrefab = ResManager.Instance.LoadAsset<GameObject>("UIEffect", effectName);
- if (effectPrefab == null)
- {
- Debug.LogError($"鍔犺浇UI鐗规晥澶辫触: {effectName}");
- return null;
- }
-
- // 鍒涘缓涓�涓柊鐨凣ameObject浣滀负鐗规晥瀹瑰櫒
- GameObject container = new GameObject($"EffectContainer_{effectName}");
- container.transform.SetParent(transform, false);
-
- // 璁剧疆瀹瑰櫒浣嶇疆
- RectTransform containerRect = container.AddComponent<RectTransform>();
- containerRect.anchorMin = new Vector2(0.5f, 0.5f);
- containerRect.anchorMax = new Vector2(0.5f, 0.5f);
- containerRect.pivot = new Vector2(0.5f, 0.5f);
- containerRect.anchoredPosition = Vector2.zero;
- containerRect.sizeDelta = new Vector2(100, 100); // 榛樿澶у皬锛屽彲浠ユ牴鎹渶瑕佽皟鏁�
-
- // 鑾峰彇鍓嶆櫙鍜岃儗鏅厓绱犵殑siblingIndex
- int frontIndex = frontElement.transform.GetSiblingIndex();
- int backIndex = backElement.transform.GetSiblingIndex();
-
- // 璁剧疆鐗规晥瀹瑰櫒鐨剆iblingIndex鍦ㄤ袱鑰呬箣闂�
- if (frontIndex > backIndex)
- {
- // 鍓嶆櫙鍦ㄨ儗鏅箣鍚庯紝鐗规晥搴旇鍦ㄤ腑闂�
- container.transform.SetSiblingIndex((frontIndex + backIndex) / 2 + 1);
- }
- else
- {
- // 鑳屾櫙鍦ㄥ墠鏅箣鍚庯紝鐗规晥搴旇鍦ㄤ腑闂�
- container.transform.SetSiblingIndex((frontIndex + backIndex) / 2);
- }
-
- // 瀹炰緥鍖栫壒鏁�
- GameObject effectObj = Instantiate(effectPrefab, container.transform);
- effectObj.name = $"Effect_{effectName}";
-
- // 娣诲姞鐗规晥绌块�忛樆鎸″櫒
- EffectPenetrationBlocker blocker = effectObj.AddComponent<EffectPenetrationBlocker>();
-
- // 鐩存帴璁剧疆鐗规晥娓叉煋鍣ㄧ殑鎺掑簭椤哄簭
- Renderer[] renderers = effectObj.GetComponentsInChildren<Renderer>(true);
- foreach (Renderer renderer in renderers)
- {
- renderer.sortingOrder = canvas.sortingOrder;
- renderer.sortingLayerName = canvas.sortingLayerName;
- }
-
- // 璁剧疆绮掑瓙绯荤粺娓叉煋鍣ㄧ殑鎺掑簭椤哄簭
- ParticleSystem[] particleSystems = effectObj.GetComponentsInChildren<ParticleSystem>(true);
- foreach (ParticleSystem ps in particleSystems)
- {
- ParticleSystemRenderer psRenderer = ps.GetComponent<ParticleSystemRenderer>();
- if (psRenderer != null)
- {
- psRenderer.sortingOrder = canvas.sortingOrder;
- psRenderer.sortingLayerName = canvas.sortingLayerName;
- }
- }
-
- // 鑷姩閿�姣�
- if (autoDestroy)
- {
- Destroy(container, destroyDelay);
- }
-
- return effectObj;
- }
- #endregion
-
- public bool raycastTarget
- {
- get;
- set;
- } = true;
-
- public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
- {
- return raycastTarget;
- }
-
- #region 鍔ㄧ敾鏂规硶
-
- // 鍋滄褰撳墠姝e湪鎾斁鐨勫姩鐢�
- protected void StopCurrentAnimation()
- {
- if (currentAnimation != null && currentAnimation.IsActive() && !currentAnimation.IsComplete())
- {
- currentAnimation.Kill(false); // 涓嶈瀹屾垚鍔ㄧ敾锛岀洿鎺ュ仠姝�
- currentAnimation = null;
- }
- isAnimating = false;
- }
-
- // 鎾斁鎵撳紑鍔ㄧ敾
- protected virtual void PlayOpenAnimation()
- {
- if (openAnimationType == UIAnimationType.None)
- {
- // 鏃犲姩鐢伙紝鐩存帴鍚敤浜や簰
- if (canvasGroup != null)
- {
- canvasGroup.alpha = 1f;
- canvasGroup.interactable = true;
- canvasGroup.blocksRaycasts = true;
- }
- return;
- }
-
- isAnimating = true;
-
- // 鍒濆鍖栧姩鐢诲墠鐨勭姸鎬�
- switch (openAnimationType)
- {
- case UIAnimationType.FadeInOut:
- if (canvasGroup != null)
- {
- canvasGroup.alpha = 0f;
- canvasGroup.interactable = false;
- canvasGroup.blocksRaycasts = false;
- }
- break;
-
- case UIAnimationType.ScaleInOut:
- if (rectTransform != null)
- {
- rectTransform.localScale = Vector3.zero;
- }
- if (canvasGroup != null)
- {
- canvasGroup.alpha = 0f;
- canvasGroup.interactable = false;
- canvasGroup.blocksRaycasts = false;
- }
- break;
-
- case UIAnimationType.SlideFromTop:
- if (rectTransform != null)
- {
- Vector2 startPos = originalPosition;
- startPos.y = Screen.height;
- rectTransform.anchoredPosition = startPos;
- }
- if (canvasGroup != null)
- {
- canvasGroup.alpha = 0f;
- canvasGroup.interactable = false;
- canvasGroup.blocksRaycasts = false;
- }
- break;
-
- case UIAnimationType.SlideFromBottom:
- if (rectTransform != null)
- {
- Vector2 startPos = originalPosition;
- startPos.y = -Screen.height;
- rectTransform.anchoredPosition = startPos;
- }
- if (canvasGroup != null)
- {
- canvasGroup.alpha = 0f;
- canvasGroup.interactable = false;
- canvasGroup.blocksRaycasts = false;
- }
- break;
-
- case UIAnimationType.SlideFromLeft:
- if (rectTransform != null)
- {
- Vector2 startPos = originalPosition;
- startPos.x = -Screen.width;
- rectTransform.anchoredPosition = startPos;
- }
- if (canvasGroup != null)
- {
- canvasGroup.alpha = 0f;
- canvasGroup.interactable = false;
- canvasGroup.blocksRaycasts = false;
- }
- break;
-
- case UIAnimationType.SlideFromRight:
- if (rectTransform != null)
- {
- Vector2 startPos = originalPosition;
- startPos.x = Screen.width;
- rectTransform.anchoredPosition = startPos;
- }
- if (canvasGroup != null)
- {
- canvasGroup.alpha = 0f;
- canvasGroup.interactable = false;
- canvasGroup.blocksRaycasts = false;
- }
- break;
- }
-
- try
- {
- // 鍒涘缓鍔ㄧ敾搴忓垪
- currentAnimation = DOTween.Sequence();
-
- // 娣诲姞鍔ㄧ敾
- switch (openAnimationType)
- {
- case UIAnimationType.FadeInOut:
- if (canvasGroup != null)
- {
- currentAnimation.Append(canvasGroup.DOFade(1f, animationDuration).SetEase(animationEase));
- }
- break;
-
- case UIAnimationType.ScaleInOut:
- if (rectTransform != null)
- {
- currentAnimation.Append(rectTransform.DOScale(originalScale, animationDuration).SetEase(animationEase));
- }
- if (canvasGroup != null)
- {
- currentAnimation.Join(canvasGroup.DOFade(1f, animationDuration).SetEase(animationEase));
- }
- break;
-
- case UIAnimationType.SlideFromTop:
- case UIAnimationType.SlideFromBottom:
- case UIAnimationType.SlideFromLeft:
- case UIAnimationType.SlideFromRight:
- if (rectTransform != null)
- {
- currentAnimation.Append(rectTransform.DOAnchorPos(originalPosition, animationDuration).SetEase(animationEase));
- }
- if (canvasGroup != null)
- {
- currentAnimation.Join(canvasGroup.DOFade(1f, animationDuration).SetEase(animationEase));
- }
- break;
- }
-
- // 鍔ㄧ敾瀹屾垚鍚庣殑鍥炶皟
- currentAnimation.OnComplete(() =>
- {
- isAnimating = false;
-
- // 鍚敤浜や簰
- if (canvasGroup != null)
- {
- canvasGroup.interactable = true;
- canvasGroup.blocksRaycasts = true;
- }
- });
- }
- catch (System.Exception e)
- {
- Debug.LogError($"鎾斁鎵撳紑鍔ㄧ敾鏃跺嚭閿�: {e.Message}");
-
- // 鍑洪敊鏃剁‘淇漊I鍙骞跺彲浜や簰
- if (canvasGroup != null)
- {
- canvasGroup.alpha = 1f;
- canvasGroup.interactable = true;
- canvasGroup.blocksRaycasts = true;
- }
- isAnimating = false;
- }
- }
-
- // 鎾斁鍏抽棴鍔ㄧ敾 - 淇敼鍚庣殑鏂规硶
- protected virtual void PlayCloseAnimation()
- {
- if (closeAnimationType == UIAnimationType.None)
- {
- // 鏃犲姩鐢伙紝鐩存帴杩斿洖锛岃HandleClose鏂规硶澶勭悊
- return;
- }
-
- isAnimating = true;
-
- try
- {
- // 鍒涘缓鍔ㄧ敾搴忓垪
- currentAnimation = DOTween.Sequence();
-
- // 娣诲姞鍔ㄧ敾
- switch (closeAnimationType)
- {
- case UIAnimationType.FadeInOut:
- if (canvasGroup != null)
- {
- currentAnimation.Append(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
- }
- break;
-
- case UIAnimationType.ScaleInOut:
- if (rectTransform != null)
- {
- currentAnimation.Append(rectTransform.DOScale(Vector3.zero, animationDuration).SetEase(animationEase));
- }
- if (canvasGroup != null)
- {
- currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
- }
- break;
-
- case UIAnimationType.SlideFromTop:
- if (rectTransform != null)
- {
- Vector2 endPos = originalPosition;
- endPos.y = Screen.height;
- currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase));
- }
- if (canvasGroup != null)
- {
- currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
- }
- break;
-
- case UIAnimationType.SlideFromBottom:
- if (rectTransform != null)
- {
- Vector2 endPos = originalPosition;
- endPos.y = -Screen.height;
- currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase));
- }
- if (canvasGroup != null)
- {
- currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
- }
- break;
-
- case UIAnimationType.SlideFromLeft:
- if (rectTransform != null)
- {
- Vector2 endPos = originalPosition;
- endPos.x = -Screen.width;
- currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase));
- }
- if (canvasGroup != null)
- {
- currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
- }
- break;
-
- case UIAnimationType.SlideFromRight:
- if (rectTransform != null)
- {
- Vector2 endPos = originalPosition;
- endPos.x = Screen.width;
- currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase));
- }
- if (canvasGroup != null)
- {
- currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
- }
- break;
- }
-
- // 鍔ㄧ敾瀹屾垚鍚庣殑鍥炶皟 - 淇敼涓鸿皟鐢–ompleteClose
- currentAnimation.OnComplete(() =>
- {
- isAnimating = false;
-
- // 鍔ㄧ敾瀹屾垚鍚庯紝瀹屾垚鍏抽棴杩囩▼
- if (isClosing)
- {
- CompleteClose();
- }
- });
- }
- catch (System.Exception e)
- {
- Debug.LogError($"鎾斁鍏抽棴鍔ㄧ敾鏃跺嚭閿�: {e.Message}");
-
- // 鍑洪敊鏃剁洿鎺ュ畬鎴愬叧闂�
- isAnimating = false;
- CompleteClose();
- }
- }
-
- #endregion
-
- #region 瀛怳I绠$悊
-
- // 娣诲姞瀛怳I
- public void AddChildUI(UIBase childUI)
- {
- if (childUI != null && !childrenUI.Contains(childUI))
- {
- childrenUI.Add(childUI);
- childUI.parentUI = this;
- }
- }
-
- // 绉婚櫎瀛怳I
- public void RemoveChildUI(UIBase childUI)
- {
- if (childUI != null && childrenUI.Contains(childUI))
- {
- childrenUI.Remove(childUI);
- childUI.parentUI = null;
- }
- }
-
- // 娓呯┖鎵�鏈夊瓙UI
- public void ClearChildrenUI()
- {
- for (int i = childrenUI.Count - 1; i >= 0; i--)
- {
- if (childrenUI[i] != null)
- {
- childrenUI[i].parentUI = null;
- }
- }
-
- childrenUI.Clear();
- }
-
- public bool IsActive()
- {
- return isActive;
- }
-
- #endregion
-
- #region 鍥炶皟鏂规硶
-
- // UI鎵撳紑鏃剁殑鍥炶皟
- protected virtual void OnOpen()
- {
- // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曞疄鐜版墦寮�UI鏃剁殑閫昏緫
- }
-
- // UI鍏抽棴鏃剁殑鍥炶皟
- protected virtual void OnClose()
- {
- // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曞疄鐜板叧闂璘I鏃剁殑閫昏緫
- }
-
- #endregion
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using DG.Tweening;
+using UnityEngine.UI; // DOTween 鎻掍欢寮曠敤
+using Cysharp.Threading.Tasks;
+using System;
+
+public enum UILayer
+{
+ Static, // 闈欐�乁I 閫傚悎鍋� 甯搁┗鐢ㄧ殑濡� 涓荤晫闈�
+ Bottom, // 鏈�搴曞眰 閫傚悎鍋� 涓荤晫闈笂闈㈢殑 涓�绾х獥鍙� 涓�绾х晫闈�
+ Mid, // 閫傚悎鍋� 浜岀骇绐楀彛 浜岀骇鐣岄潰
+ Top, // 閫傚悎鍋氭彁绀哄脊绐�
+ System // 缃戠粶寮圭獥/鍏朵粬閲嶈寮圭獥/绯荤粺鍏憡
+}
+
+public enum UIAnimationType
+{
+ None, // 鏃犲姩鐢�
+ FadeInOut, // 娣″叆娣″嚭
+ ScaleInOut, // 缂╂斁
+ SlideFromTop, // 浠庨《閮ㄦ粦鍏�
+ SlideFromBottom, // 浠庡簳閮ㄦ粦鍏�
+ SlideFromLeft, // 浠庡乏渚ф粦鍏�
+ SlideFromRight // 浠庡彸渚ф粦鍏�
+}
+
+[RequireComponent(typeof(Canvas))]
+[RequireComponent(typeof(CanvasGroup))]
+[RequireComponent(typeof(CanvasScaler))]
+public class UIBase : MonoBehaviour
+{
+ #region 灞炴�у拰鍙橀噺
+
+ // UI鍩烘湰灞炴��
+ [SerializeField] public UILayer uiLayer = UILayer.Mid;
+ [SerializeField][HideInInspector] public string uiName;
+ [SerializeField] public bool isMainUI = false;
+ [SerializeField] public bool supportParentChildRelation = true; // 鏂板锛氭槸鍚︽敮鎸佺埗瀛愬叧绯�
+
+ // 鎸佷箙鍖栫浉鍏�
+ [SerializeField] public bool isPersistent = false;
+ [SerializeField][HideInInspector] public int maxIdleRounds = 20;
+
+ // 鍔ㄧ敾鐩稿叧
+ [SerializeField] public UIAnimationType openAnimationType = UIAnimationType.None;
+ [SerializeField] public UIAnimationType closeAnimationType = UIAnimationType.None;
+ [SerializeField][HideInInspector] public float animationDuration = 0.3f;
+ [SerializeField][HideInInspector] public Ease animationEase = Ease.OutQuad; // 纭繚浣跨敤 DG.Tweening.Ease
+
+ // 杩愯鏃剁姸鎬�
+ [HideInInspector] public int lastUsedRound = 0;
+ [HideInInspector] public UIBase parentUI;
+
+ // 瀛怳I绠$悊
+ [HideInInspector] public List<UIBase> childrenUI = new List<UIBase>();
+
+ // 鎵撳紑閬僵
+ [SerializeField] public bool openMask = false;
+
+ // 鐐瑰嚮绌虹櫧鍖哄煙鍏抽棴鐣岄潰
+ [SerializeField] public bool clickEmptySpaceClose = false;
+
+ private GameObject screenMask = null;
+
+ private Button btnClickEmptyClose;
+
+ protected int functionOrder = 0;
+
+ // 鍐呴儴鐘舵��
+ protected bool isActive = false;
+ protected bool isAnimating = false;
+ protected bool isClosing = false; // 鏂板锛氭爣璁版槸鍚︽鍦ㄥ叧闂�
+
+ // 缁勪欢寮曠敤
+ protected Canvas canvas;
+ protected CanvasGroup canvasGroup;
+ protected RectTransform rectTransform;
+
+ // 鍔ㄧ敾鐩稿叧
+ protected Vector3 originalScale;
+ protected Vector3 originalPosition;
+ protected Sequence currentAnimation;
+
+ #endregion
+
+ #region Unity鐢熷懡鍛ㄦ湡
+
+ protected virtual void Awake()
+ {
+ // 纭繚 DOTween 宸插垵濮嬪寲
+ DOTween.SetTweensCapacity(500, 50);
+
+ // 鍦ˋwake涓繘琛屽熀鏈垵濮嬪寲
+ InitComponent();
+
+ // 淇濆瓨鍘熷鍊肩敤浜庡姩鐢�
+ if (rectTransform != null)
+ {
+ originalScale = rectTransform.localScale;
+ originalPosition = rectTransform.anchoredPosition;
+ }
+
+ ApplySettings();
+
+ if (openMask)
+ {
+ screenMask = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/ScreenMask"), transform);
+ screenMask.transform.localScale = Vector3.one;
+ screenMask.transform.localPosition = Vector3.zero;
+ screenMask.transform.SetAsFirstSibling();
+ }
+ }
+
+ protected virtual void Start()
+ {
+ // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曡繘琛岄澶栧垵濮嬪寲
+ }
+
+ protected async UniTask ApplySettings()
+ {
+ await UniTask.DelayFrame(5);
+
+ if (null != transform)
+ {
+ if (clickEmptySpaceClose)
+ {
+ GameObject goBtnESC = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/ClickEmptyCloseMask"), transform);
+ // Load
+ btnClickEmptyClose = goBtnESC.GetComponent<Button>();
+ btnClickEmptyClose.AddListener(CloseWindow);
+ btnClickEmptyClose.transform.SetAsFirstSibling();
+ }
+ }
+ }
+
+ protected async void ExecuteNextFrame(Action _action)
+ {
+ await UniTask.DelayFrame(1);
+ _action?.Invoke();
+ }
+
+ protected virtual void OnDestroy()
+ {
+ // 纭繚鍔ㄧ敾琚纭竻鐞�
+ if (currentAnimation != null)
+ {
+ currentAnimation.Kill();
+ currentAnimation = null;
+ }
+ }
+
+ #endregion
+
+ #region 鍒濆鍖栨柟娉�
+
+ // 鑾峰彇蹇呰鐨勭粍浠�
+ protected virtual void InitComponent()
+ {
+ // 鑾峰彇鎴栨坊鍔燙anvas缁勪欢
+ canvas = GetComponent<Canvas>();
+ if (canvas == null)
+ {
+ canvas = gameObject.AddComponent<Canvas>();
+ }
+
+ // 璁剧疆Canvas灞炴��
+ canvas.overrideSorting = true;
+
+ // 鑾峰彇鎴栨坊鍔燙anvasGroup缁勪欢
+ canvasGroup = GetComponent<CanvasGroup>();
+ if (canvasGroup == null)
+ {
+ canvasGroup = gameObject.AddComponent<CanvasGroup>();
+ }
+
+ // 娣诲姞GraphicRaycaster缁勪欢锛堝鏋滄病鏈夛級
+ if (GetComponent<UnityEngine.UI.GraphicRaycaster>() == null)
+ {
+ gameObject.AddComponent<UnityEngine.UI.GraphicRaycaster>();
+ }
+
+ // 鑾峰彇RectTransform缁勪欢
+ rectTransform = GetComponent<RectTransform>();
+ }
+
+ #endregion
+
+ #region UI鎿嶄綔鏂规硶
+
+ // 璁剧疆UI灞傜骇
+ public void SetSortingOrder(int order)
+ {
+ if (canvas != null)
+ {
+ canvas.sortingOrder = order;
+ }
+ }
+
+ protected virtual void OnPreOpen()
+ {
+ // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曡繘琛岄澶栫殑棰勬墦寮�鎿嶄綔
+ }
+
+ protected virtual void OnPreClose()
+ {
+ // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曡繘琛岄澶栫殑棰勫叧闂搷浣�
+ }
+
+ // 鎵撳紑UI
+ public void HandleOpen()
+ {
+ OnPreOpen();
+ // 濡傛灉姝e湪鎾斁鍔ㄧ敾锛屽厛鍋滄
+ StopCurrentAnimation();
+
+ // 閲嶇疆鍏抽棴鏍囪
+ isClosing = false;
+
+ gameObject.SetActive(true);
+ isActive = true;
+
+ // 鏍规嵁鍔ㄧ敾绫诲瀷鎾斁鎵撳紑鍔ㄧ敾
+ PlayOpenAnimation();
+
+ OnOpen();
+ }
+
+ // 鍏抽棴UI - 淇敼鍚庣殑鏂规硶
+ public void HandleClose()
+ {
+ // 濡傛灉宸茬粡鍦ㄥ叧闂繃绋嬩腑锛岀洿鎺ヨ繑鍥�
+ if (isClosing) return;
+
+ OnPreClose();
+
+ // 濡傛灉姝e湪鎾斁鍔ㄧ敾锛屽厛鍋滄
+ StopCurrentAnimation();
+
+ // 璁剧疆鍏抽棴鏍囪
+ isClosing = true;
+ isActive = false;
+
+ // 绂佺敤浜や簰浣嗕繚鎸佸彲瑙�
+ if (canvasGroup != null)
+ {
+ canvasGroup.interactable = false;
+ canvasGroup.blocksRaycasts = false;
+ }
+
+ // 鏍规嵁鍔ㄧ敾绫诲瀷鎾斁鍏抽棴鍔ㄧ敾
+ PlayCloseAnimation();
+
+ // 璋冪敤鍏抽棴鍥炶皟
+ OnClose();
+
+ // 濡傛灉娌℃湁鍏抽棴鍔ㄧ敾锛岀洿鎺ョ鐢ㄦ父鎴忓璞�
+ if (closeAnimationType == UIAnimationType.None)
+ {
+ CompleteClose();
+ }
+ // 鍚﹀垯鍦ㄥ姩鐢诲畬鎴愬悗绂佺敤娓告垙瀵硅薄锛堝湪PlayCloseAnimation涓鐞嗭級
+ }
+
+ // 瀹屾垚鍏抽棴杩囩▼ - 鏂板鏂规硶
+ protected virtual void CompleteClose()
+ {
+ gameObject.SetActive(false);
+ isClosing = false;
+ }
+
+ public virtual void CloseWindow()
+ {
+ UIManager.Instance.CloseWindow(this, false);
+ }
+
+ // 鍒锋柊UI
+ public virtual void Refresh()
+ {
+ // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曞疄鐜癠I鍒锋柊閫昏緫
+ }
+
+ // 閿�姣乁I
+ public virtual void Destroy()
+ {
+ // 鍋滄鎵�鏈夊姩鐢�
+ StopCurrentAnimation();
+
+ ClearChildrenUI();
+
+ if (parentUI != null)
+ {
+ parentUI.RemoveChildUI(this);
+ }
+
+ Destroy(gameObject);
+ }
+
+ #endregion
+
+ #region 鐗规晥鐩稿叧
+
+ /// <summary>
+ /// 鎾斁UI鐗规晥
+ /// </summary>
+ /// <param name="effectName">鐗规晥璧勬簮鍚嶇О</param>
+ /// <param name="parent">鐗规晥鐖惰妭鐐癸紝榛樿涓哄綋鍓峌I</param>
+ /// <param name="autoDestroy">鏄惁鑷姩閿�姣侊紝榛樿涓簍rue</param>
+ /// <param name="destroyDelay">鑷姩閿�姣佸欢杩熸椂闂达紝榛樿涓�5绉�</param>
+ /// <returns>鐗规晥娓告垙瀵硅薄</returns>
+ public async UniTask<GameObject> PlayUIEffect(int id, Transform parent = null, bool autoDestroy = true, float destroyDelay = 5f)
+ {
+ // 浣跨敤榛樿鍊�
+ if (parent == null) parent = transform;
+
+ EffectConfig effectCfg = EffectConfig.Get(id);
+
+ if (null == effectCfg)
+ {
+ return null;
+ }
+
+ // 鍔犺浇鐗规晥璧勬簮
+ var effectPrefab = ResManager.Instance.LoadAsset<GameObject>("UIEffect/" + effectCfg.packageName, effectCfg.fxName);
+ if (effectPrefab == null)
+ {
+ Debug.LogError($"鍔犺浇UI鐗规晥澶辫触: {effectCfg.packageName}");
+ return null;
+ }
+
+ // 瀹炰緥鍖栫壒鏁�
+ GameObject effectObj = Instantiate(effectPrefab, parent);
+ effectObj.name = $"Effect_{effectCfg.packageName}";
+
+ // 娣诲姞鐗规晥绌块�忛樆鎸″櫒
+ EffectPenetrationBlocker blocker = effectObj.AddComponent<EffectPenetrationBlocker>();
+ blocker.parentCanvas = canvas;
+ blocker.UpdateSortingOrder();
+
+ // 鑷姩閿�姣�
+ if (autoDestroy)
+ {
+ Destroy(effectObj, destroyDelay);
+ }
+
+ return effectObj;
+ }
+
+ /// <summary>
+ /// 鍦ㄤ袱涓猆I鍏冪礌涔嬮棿鎾斁鐗规晥锛堟寜鐓ortingOrder鐨勪腑闂村�硷級
+ /// </summary>
+ /// <param name="effectName">鐗规晥璧勬簮鍚嶇О</param>
+ /// <param name="frontElement">鍓嶆櫙UI鍏冪礌锛圛mage鎴朢awImage锛�</param>
+ /// <param name="backElement">鑳屾櫙UI鍏冪礌锛圛mage鎴朢awImage锛�</param>
+ /// <param name="autoDestroy">鏄惁鑷姩閿�姣侊紝榛樿涓簍rue</param>
+ /// <param name="destroyDelay">鑷姩閿�姣佸欢杩熸椂闂达紝榛樿涓�5绉�</param>
+ /// <returns>鐗规晥娓告垙瀵硅薄</returns>
+ public async UniTask<GameObject> PlayEffectBetweenUIElements(string effectName, Graphic frontElement, Graphic backElement, bool autoDestroy = true, float destroyDelay = 5f)
+ {
+ if (frontElement == null || backElement == null)
+ {
+ Debug.LogError("鍓嶆櫙鎴栬儗鏅疷I鍏冪礌涓虹┖");
+ return null;
+ }
+
+ // 纭繚UI鍏冪礌鍦ㄥ綋鍓峌IBase鐨凜anvas涓�
+ if (frontElement.canvas != canvas || backElement.canvas != canvas)
+ {
+ Debug.LogError("UI鍏冪礌涓嶅湪褰撳墠UIBase鐨凜anvas涓�");
+ return null;
+ }
+
+ // 鍔犺浇鐗规晥璧勬簮
+ GameObject effectPrefab = ResManager.Instance.LoadAsset<GameObject>("UIEffect", effectName);
+ if (effectPrefab == null)
+ {
+ Debug.LogError($"鍔犺浇UI鐗规晥澶辫触: {effectName}");
+ return null;
+ }
+
+ // 鍒涘缓涓�涓柊鐨凣ameObject浣滀负鐗规晥瀹瑰櫒
+ GameObject container = new GameObject($"EffectContainer_{effectName}");
+ container.transform.SetParent(transform, false);
+
+ // 璁剧疆瀹瑰櫒浣嶇疆
+ RectTransform containerRect = container.AddComponent<RectTransform>();
+ containerRect.anchorMin = new Vector2(0.5f, 0.5f);
+ containerRect.anchorMax = new Vector2(0.5f, 0.5f);
+ containerRect.pivot = new Vector2(0.5f, 0.5f);
+ containerRect.anchoredPosition = Vector2.zero;
+ containerRect.sizeDelta = new Vector2(100, 100); // 榛樿澶у皬锛屽彲浠ユ牴鎹渶瑕佽皟鏁�
+
+ // 鑾峰彇鍓嶆櫙鍜岃儗鏅厓绱犵殑siblingIndex
+ int frontIndex = frontElement.transform.GetSiblingIndex();
+ int backIndex = backElement.transform.GetSiblingIndex();
+
+ // 璁剧疆鐗规晥瀹瑰櫒鐨剆iblingIndex鍦ㄤ袱鑰呬箣闂�
+ if (frontIndex > backIndex)
+ {
+ // 鍓嶆櫙鍦ㄨ儗鏅箣鍚庯紝鐗规晥搴旇鍦ㄤ腑闂�
+ container.transform.SetSiblingIndex((frontIndex + backIndex) / 2 + 1);
+ }
+ else
+ {
+ // 鑳屾櫙鍦ㄥ墠鏅箣鍚庯紝鐗规晥搴旇鍦ㄤ腑闂�
+ container.transform.SetSiblingIndex((frontIndex + backIndex) / 2);
+ }
+
+ // 瀹炰緥鍖栫壒鏁�
+ GameObject effectObj = Instantiate(effectPrefab, container.transform);
+ effectObj.name = $"Effect_{effectName}";
+
+ // 娣诲姞鐗规晥绌块�忛樆鎸″櫒
+ EffectPenetrationBlocker blocker = effectObj.AddComponent<EffectPenetrationBlocker>();
+
+ // 鐩存帴璁剧疆鐗规晥娓叉煋鍣ㄧ殑鎺掑簭椤哄簭
+ Renderer[] renderers = effectObj.GetComponentsInChildren<Renderer>(true);
+ foreach (Renderer renderer in renderers)
+ {
+ renderer.sortingOrder = canvas.sortingOrder;
+ renderer.sortingLayerName = canvas.sortingLayerName;
+ }
+
+ // 璁剧疆绮掑瓙绯荤粺娓叉煋鍣ㄧ殑鎺掑簭椤哄簭
+ ParticleSystem[] particleSystems = effectObj.GetComponentsInChildren<ParticleSystem>(true);
+ foreach (ParticleSystem ps in particleSystems)
+ {
+ ParticleSystemRenderer psRenderer = ps.GetComponent<ParticleSystemRenderer>();
+ if (psRenderer != null)
+ {
+ psRenderer.sortingOrder = canvas.sortingOrder;
+ psRenderer.sortingLayerName = canvas.sortingLayerName;
+ }
+ }
+
+ // 鑷姩閿�姣�
+ if (autoDestroy)
+ {
+ Destroy(container, destroyDelay);
+ }
+
+ return effectObj;
+ }
+ #endregion
+
+ public bool raycastTarget
+ {
+ get;
+ set;
+ } = true;
+
+ public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
+ {
+ return raycastTarget;
+ }
+
+ #region 鍔ㄧ敾鏂规硶
+
+ // 鍋滄褰撳墠姝e湪鎾斁鐨勫姩鐢�
+ protected void StopCurrentAnimation()
+ {
+ if (currentAnimation != null && currentAnimation.IsActive() && !currentAnimation.IsComplete())
+ {
+ currentAnimation.Kill(false); // 涓嶈瀹屾垚鍔ㄧ敾锛岀洿鎺ュ仠姝�
+ currentAnimation = null;
+ }
+ isAnimating = false;
+ }
+
+ // 鎾斁鎵撳紑鍔ㄧ敾
+ protected virtual void PlayOpenAnimation()
+ {
+ if (openAnimationType == UIAnimationType.None)
+ {
+ // 鏃犲姩鐢伙紝鐩存帴鍚敤浜や簰
+ if (canvasGroup != null)
+ {
+ canvasGroup.alpha = 1f;
+ canvasGroup.interactable = true;
+ canvasGroup.blocksRaycasts = true;
+ }
+ return;
+ }
+
+ isAnimating = true;
+
+ // 鍒濆鍖栧姩鐢诲墠鐨勭姸鎬�
+ switch (openAnimationType)
+ {
+ case UIAnimationType.FadeInOut:
+ if (canvasGroup != null)
+ {
+ canvasGroup.alpha = 0f;
+ canvasGroup.interactable = false;
+ canvasGroup.blocksRaycasts = false;
+ }
+ break;
+
+ case UIAnimationType.ScaleInOut:
+ if (rectTransform != null)
+ {
+ rectTransform.localScale = Vector3.zero;
+ }
+ if (canvasGroup != null)
+ {
+ canvasGroup.alpha = 0f;
+ canvasGroup.interactable = false;
+ canvasGroup.blocksRaycasts = false;
+ }
+ break;
+
+ case UIAnimationType.SlideFromTop:
+ if (rectTransform != null)
+ {
+ Vector2 startPos = originalPosition;
+ startPos.y = Screen.height;
+ rectTransform.anchoredPosition = startPos;
+ }
+ if (canvasGroup != null)
+ {
+ canvasGroup.alpha = 0f;
+ canvasGroup.interactable = false;
+ canvasGroup.blocksRaycasts = false;
+ }
+ break;
+
+ case UIAnimationType.SlideFromBottom:
+ if (rectTransform != null)
+ {
+ Vector2 startPos = originalPosition;
+ startPos.y = -Screen.height;
+ rectTransform.anchoredPosition = startPos;
+ }
+ if (canvasGroup != null)
+ {
+ canvasGroup.alpha = 0f;
+ canvasGroup.interactable = false;
+ canvasGroup.blocksRaycasts = false;
+ }
+ break;
+
+ case UIAnimationType.SlideFromLeft:
+ if (rectTransform != null)
+ {
+ Vector2 startPos = originalPosition;
+ startPos.x = -Screen.width;
+ rectTransform.anchoredPosition = startPos;
+ }
+ if (canvasGroup != null)
+ {
+ canvasGroup.alpha = 0f;
+ canvasGroup.interactable = false;
+ canvasGroup.blocksRaycasts = false;
+ }
+ break;
+
+ case UIAnimationType.SlideFromRight:
+ if (rectTransform != null)
+ {
+ Vector2 startPos = originalPosition;
+ startPos.x = Screen.width;
+ rectTransform.anchoredPosition = startPos;
+ }
+ if (canvasGroup != null)
+ {
+ canvasGroup.alpha = 0f;
+ canvasGroup.interactable = false;
+ canvasGroup.blocksRaycasts = false;
+ }
+ break;
+ }
+
+ try
+ {
+ // 鍒涘缓鍔ㄧ敾搴忓垪
+ currentAnimation = DOTween.Sequence();
+
+ // 娣诲姞鍔ㄧ敾
+ switch (openAnimationType)
+ {
+ case UIAnimationType.FadeInOut:
+ if (canvasGroup != null)
+ {
+ currentAnimation.Append(canvasGroup.DOFade(1f, animationDuration).SetEase(animationEase));
+ }
+ break;
+
+ case UIAnimationType.ScaleInOut:
+ if (rectTransform != null)
+ {
+ currentAnimation.Append(rectTransform.DOScale(originalScale, animationDuration).SetEase(animationEase));
+ }
+ if (canvasGroup != null)
+ {
+ currentAnimation.Join(canvasGroup.DOFade(1f, animationDuration).SetEase(animationEase));
+ }
+ break;
+
+ case UIAnimationType.SlideFromTop:
+ case UIAnimationType.SlideFromBottom:
+ case UIAnimationType.SlideFromLeft:
+ case UIAnimationType.SlideFromRight:
+ if (rectTransform != null)
+ {
+ currentAnimation.Append(rectTransform.DOAnchorPos(originalPosition, animationDuration).SetEase(animationEase));
+ }
+ if (canvasGroup != null)
+ {
+ currentAnimation.Join(canvasGroup.DOFade(1f, animationDuration).SetEase(animationEase));
+ }
+ break;
+ }
+
+ // 鍔ㄧ敾瀹屾垚鍚庣殑鍥炶皟
+ currentAnimation.OnComplete(() =>
+ {
+ isAnimating = false;
+
+ // 鍚敤浜や簰
+ if (canvasGroup != null)
+ {
+ canvasGroup.interactable = true;
+ canvasGroup.blocksRaycasts = true;
+ }
+ });
+ }
+ catch (System.Exception e)
+ {
+ Debug.LogError($"鎾斁鎵撳紑鍔ㄧ敾鏃跺嚭閿�: {e.Message}");
+
+ // 鍑洪敊鏃剁‘淇漊I鍙骞跺彲浜や簰
+ if (canvasGroup != null)
+ {
+ canvasGroup.alpha = 1f;
+ canvasGroup.interactable = true;
+ canvasGroup.blocksRaycasts = true;
+ }
+ isAnimating = false;
+ }
+ }
+
+ // 鎾斁鍏抽棴鍔ㄧ敾 - 淇敼鍚庣殑鏂规硶
+ protected virtual void PlayCloseAnimation()
+ {
+ if (closeAnimationType == UIAnimationType.None)
+ {
+ // 鏃犲姩鐢伙紝鐩存帴杩斿洖锛岃HandleClose鏂规硶澶勭悊
+ return;
+ }
+
+ isAnimating = true;
+
+ try
+ {
+ // 鍒涘缓鍔ㄧ敾搴忓垪
+ currentAnimation = DOTween.Sequence();
+
+ // 娣诲姞鍔ㄧ敾
+ switch (closeAnimationType)
+ {
+ case UIAnimationType.FadeInOut:
+ if (canvasGroup != null)
+ {
+ currentAnimation.Append(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
+ }
+ break;
+
+ case UIAnimationType.ScaleInOut:
+ if (rectTransform != null)
+ {
+ currentAnimation.Append(rectTransform.DOScale(Vector3.zero, animationDuration).SetEase(animationEase));
+ }
+ if (canvasGroup != null)
+ {
+ currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
+ }
+ break;
+
+ case UIAnimationType.SlideFromTop:
+ if (rectTransform != null)
+ {
+ Vector2 endPos = originalPosition;
+ endPos.y = Screen.height;
+ currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase));
+ }
+ if (canvasGroup != null)
+ {
+ currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
+ }
+ break;
+
+ case UIAnimationType.SlideFromBottom:
+ if (rectTransform != null)
+ {
+ Vector2 endPos = originalPosition;
+ endPos.y = -Screen.height;
+ currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase));
+ }
+ if (canvasGroup != null)
+ {
+ currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
+ }
+ break;
+
+ case UIAnimationType.SlideFromLeft:
+ if (rectTransform != null)
+ {
+ Vector2 endPos = originalPosition;
+ endPos.x = -Screen.width;
+ currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase));
+ }
+ if (canvasGroup != null)
+ {
+ currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
+ }
+ break;
+
+ case UIAnimationType.SlideFromRight:
+ if (rectTransform != null)
+ {
+ Vector2 endPos = originalPosition;
+ endPos.x = Screen.width;
+ currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase));
+ }
+ if (canvasGroup != null)
+ {
+ currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase));
+ }
+ break;
+ }
+
+ // 鍔ㄧ敾瀹屾垚鍚庣殑鍥炶皟 - 淇敼涓鸿皟鐢–ompleteClose
+ currentAnimation.OnComplete(() =>
+ {
+ isAnimating = false;
+
+ // 鍔ㄧ敾瀹屾垚鍚庯紝瀹屾垚鍏抽棴杩囩▼
+ if (isClosing)
+ {
+ CompleteClose();
+ }
+ });
+ }
+ catch (System.Exception e)
+ {
+ Debug.LogError($"鎾斁鍏抽棴鍔ㄧ敾鏃跺嚭閿�: {e.Message}");
+
+ // 鍑洪敊鏃剁洿鎺ュ畬鎴愬叧闂�
+ isAnimating = false;
+ CompleteClose();
+ }
+ }
+
+ #endregion
+
+ #region 瀛怳I绠$悊
+
+ // 娣诲姞瀛怳I
+ public void AddChildUI(UIBase childUI)
+ {
+ if (childUI != null && !childrenUI.Contains(childUI))
+ {
+ childrenUI.Add(childUI);
+ childUI.parentUI = this;
+ }
+ }
+
+ // 绉婚櫎瀛怳I
+ public void RemoveChildUI(UIBase childUI)
+ {
+ if (childUI != null && childrenUI.Contains(childUI))
+ {
+ childrenUI.Remove(childUI);
+ childUI.parentUI = null;
+ }
+ }
+
+ // 娓呯┖鎵�鏈夊瓙UI
+ public void ClearChildrenUI()
+ {
+ for (int i = childrenUI.Count - 1; i >= 0; i--)
+ {
+ if (childrenUI[i] != null)
+ {
+ childrenUI[i].parentUI = null;
+ }
+ }
+
+ childrenUI.Clear();
+ }
+
+ public bool IsActive()
+ {
+ return isActive;
+ }
+
+ #endregion
+
+ #region 鍥炶皟鏂规硶
+
+ // UI鎵撳紑鏃剁殑鍥炶皟
+ protected virtual void OnOpen()
+ {
+ // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曞疄鐜版墦寮�UI鏃剁殑閫昏緫
+ }
+
+ // UI鍏抽棴鏃剁殑鍥炶皟
+ protected virtual void OnClose()
+ {
+ // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曞疄鐜板叧闂璘I鏃剁殑閫昏緫
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/Main/UI/UIBase.cs.meta b/Main/System/UIBase/UIBase.cs.meta
similarity index 100%
rename from Main/UI/UIBase.cs.meta
rename to Main/System/UIBase/UIBase.cs.meta
diff --git a/Main/Temp.meta b/Main/Temp.meta
deleted file mode 100644
index c4c42e3..0000000
--- a/Main/Temp.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: ba254324c9fe0e34b903c9012234905e
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/Temp/ConfigBase.cs b/Main/Temp/ConfigBase.cs
deleted file mode 100644
index 5ba7369..0000000
--- a/Main/Temp/ConfigBase.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-锘�
-public interface IConfigPostProcess
-{
- void OnConfigParseCompleted();
-}
-
diff --git a/Main/Temp/ConfigBase.cs.meta b/Main/Temp/ConfigBase.cs.meta
deleted file mode 100644
index 7319dcd..0000000
--- a/Main/Temp/ConfigBase.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: ec8cb09f9a7ce5140bcc76dfc232bc0a
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/Tools.meta b/Main/Tools.meta
deleted file mode 100644
index 25ae303..0000000
--- a/Main/Tools.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: ed19de39701d6f34ca1ccc9485b759bd
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/Tools/UI.meta b/Main/Tools/UI.meta
deleted file mode 100644
index 6aee1f9..0000000
--- a/Main/Tools/UI.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: e68e1dc0a519c794a9e1f8203e8f6b2a
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/UI.meta b/Main/UI.meta
deleted file mode 100644
index ced7062..0000000
--- a/Main/UI.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 723c0b1daebf8d34eac4b16d94dd88bb
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/UI/Decorate.meta b/Main/UI/Decorate.meta
deleted file mode 100644
index 3910d07..0000000
--- a/Main/UI/Decorate.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 7afe0dfa12d3fb54d95a2563bc0e019e
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/UI/Main.meta b/Main/UI/Main.meta
deleted file mode 100644
index 0efa991..0000000
--- a/Main/UI/Main.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 35cec4a6bce278e4b9c8efc66988e0e2
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Main/Tools/UI/EffectPenetrationBlocker.cs b/Main/Utility/EffectPenetrationBlocker.cs
similarity index 100%
rename from Main/Tools/UI/EffectPenetrationBlocker.cs
rename to Main/Utility/EffectPenetrationBlocker.cs
diff --git a/Main/Tools/UI/EffectPenetrationBlocker.cs.meta b/Main/Utility/EffectPenetrationBlocker.cs.meta
similarity index 100%
rename from Main/Tools/UI/EffectPenetrationBlocker.cs.meta
rename to Main/Utility/EffectPenetrationBlocker.cs.meta
diff --git a/Main/VersionCheck.cs b/Main/VersionCheck.cs
deleted file mode 100644
index 78d970d..0000000
--- a/Main/VersionCheck.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using UnityEngine;
-using Cysharp.Threading.Tasks;
-
-/// <summary>
-/// 鐗堟湰妫�鏌ョ被锛岀敤浜庤幏鍙栧綋鍓嶅簲鐢ㄧ増鏈俊鎭�
-/// </summary>
-public class VersionCheck
-{
- /// <summary>
- /// 鑾峰彇鏈湴鐗堟湰淇℃伅
- /// 閫傜敤浜庡畨鍗撱�乮OS銆乄ebGL鍜孭C骞冲彴
- /// </summary>
- /// <returns>鐗堟湰瀛楃涓诧紝鏍煎紡涓� x.y.z</returns>
- public static async UniTask<string> GetLocalVersionAsync()
- {
- try
- {
- // 棣栧厛灏濊瘯浠嶳esources鍔犺浇鐗堟湰鏂囦欢
- TextAsset versionAsset = Resources.Load<TextAsset>("version");
-
- if (versionAsset != null)
- {
- string versionText = versionAsset.text.Trim();
- Debug.Log($"浠嶳esources鍔犺浇鐗堟湰淇℃伅: {versionText}");
- return versionText;
- }
-
- // 濡傛灉Resources涓病鏈夌増鏈枃浠讹紝鍒欎娇鐢ㄥ簲鐢ㄧ▼搴忕増鏈�
- string appVersion = Application.version;
- Debug.Log($"浣跨敤搴旂敤绋嬪簭鐗堟湰: {appVersion}");
-
- // 纭繚鐗堟湰鍙锋牸寮忔纭�
- if (string.IsNullOrEmpty(appVersion))
- {
- Debug.LogWarning("搴旂敤绋嬪簭鐗堟湰涓虹┖锛屼娇鐢ㄩ粯璁ょ増鏈� 1.0.0");
- appVersion = "1.0.0";
- }
-
- return appVersion;
- }
- catch (Exception e)
- {
- Debug.LogError($"鑾峰彇鏈湴鐗堟湰淇℃伅澶辫触: {e.Message}");
- return "1.0.0"; // 杩斿洖榛樿鐗堟湰
- }
- }
-}
\ No newline at end of file
diff --git a/Main/VersionCheck.cs.meta b/Main/VersionCheck.cs.meta
deleted file mode 100644
index 7f3c4fd..0000000
--- a/Main/VersionCheck.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: e39b0cc9263ecba46b308a67dbea5e9c
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
--
Gitblit v1.8.0