diff --git a/Forest/Assets/AddressableAssetsData/AddressableAssetSettings.asset b/Forest/Assets/AddressableAssetsData/AddressableAssetSettings.asset index a018fef..c65f636 100644 --- a/Forest/Assets/AddressableAssetsData/AddressableAssetSettings.asset +++ b/Forest/Assets/AddressableAssetsData/AddressableAssetSettings.asset @@ -15,7 +15,7 @@ MonoBehaviour: m_DefaultGroup: d58d9f3a3b49b264e94d9dd1182e2910 m_currentHash: serializedVersion: 2 - Hash: 055613adb1a6e9184deaa9c262f9202f + Hash: 3980b428a3d1445ac52889f7249df15d m_OptimizeCatalogSize: 0 m_BuildRemoteCatalog: 0 m_BundleLocalCatalog: 0 diff --git a/Forest/Assets/AddressableAssetsData/AssetGroups/Build.asset b/Forest/Assets/AddressableAssetsData/AssetGroups/Build.asset index 6f0a3cc..7086dc4 100644 --- a/Forest/Assets/AddressableAssetsData/AssetGroups/Build.asset +++ b/Forest/Assets/AddressableAssetsData/AssetGroups/Build.asset @@ -27,6 +27,11 @@ MonoBehaviour: m_ReadOnly: 0 m_SerializedLabels: [] FlaggedDuringContentUpdateRestriction: 0 + - m_GUID: b5b08b0ba867e46bd90a825d41b818c9 + m_Address: Assets/Config/Build + m_ReadOnly: 0 + m_SerializedLabels: [] + FlaggedDuringContentUpdateRestriction: 0 m_ReadOnly: 0 m_Settings: {fileID: 11400000, guid: ed93b85c5b1133d4c93abe6c976cf739, type: 2} m_SchemaSet: diff --git a/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs b/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs index 3a0a47e..c679723 100644 --- a/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs +++ b/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs @@ -184,26 +184,33 @@ namespace Framework.Manager /// private void InitNodesInfo() { - foreach (var node in _curBuildData.NodeInfos) + try { - var nodeInfo = new NodeInfo + foreach (var node in _curBuildData.NodeInfos) { - Name = node.Name, - Options = new Dictionary(), - IconPath = node.IconPath - }; - - foreach (var option in node.Options) - { - var optionInfo = new OptionInfo() + var nodeInfo = new NodeInfo { - Name = option + Name = node.Name, + Options = new Dictionary(), + IconPath = node.IconPath }; - nodeInfo.Options.Add(option, optionInfo); - } + foreach (var option in node.Options) + { + var optionInfo = new OptionInfo() + { + Name = option + }; - NodeInfos.Add(nodeInfo.Name, nodeInfo); + nodeInfo.Options.Add(option, optionInfo); + } + + NodeInfos.Add(nodeInfo.Name, nodeInfo); + } + } + catch (Exception e) + { + DebugUtil.LogError("BuildManager.InitNodesInfo 初始化节点错误 :{0}", e); } } @@ -212,63 +219,48 @@ namespace Framework.Manager /// private void InitUserBuildInfo(UserBuildInfo userBuildInfo) { - //游戏中传入数据 - if (userBuildInfo != null) + try { - _userBuildInfo = userBuildInfo; - } - else - { - StorageManager.Instance.Init(); - _userBuildInfo = StorageManager.Instance.GetStorage(GlobalConstants.UserBuildSaveKey); - if (_userBuildInfo == null) + //游戏中传入数据 + if (userBuildInfo != null) { - var buildId = _curBuildData.buildID; - _userBuildInfo = new UserBuildInfo(buildId); + _userBuildInfo = userBuildInfo; } - } - - foreach (var nodeInfo in NodeInfos) - { - if (_userBuildInfo.ChooseNodeInfo.TryGetValue(nodeInfo.Key, out var option)) + else { - continue; + StorageManager.Instance.Init(); + _userBuildInfo = + StorageManager.Instance.GetStorage(GlobalConstants.UserBuildSaveKey); + if (_userBuildInfo == null) + { + var buildId = _curBuildData.buildID; + _userBuildInfo = new UserBuildInfo(buildId); + } } - var optionInfo = nodeInfo.Value.GetOptionInfo(); - if (optionInfo == null) return; - - _userBuildInfo.ChooseNodeInfo.TryAdd(nodeInfo.Key, optionInfo.Name); - } - - //打印Debug玩家Build信息 - /*foreach (var infos in _userBuildInfo.ChooseNodeInfo) - { - DebugUtil.LogError("节点 {0} 选择的的是 {1}", infos.Key, infos.Value); - }*/ - } - - /// - /// 异步加载该建造物品图标 - /// - private async UniTask InitIcon() - { - foreach (var nodeInfo in NodeInfos.Values) - { - foreach (var optionInfo in nodeInfo.Options.Values) + foreach (var nodeInfo in NodeInfos) { - var index = GameBuildUtils.ExtractNumber(optionInfo.Name); + if (_userBuildInfo.ChooseNodeInfo.TryGetValue(nodeInfo.Key, out var option)) + { + continue; + } - optionInfo.IconName = await InitOptionIcon(nodeInfo.IconPath, index); + var optionInfo = nodeInfo.Value.GetOptionInfo(); + if (optionInfo == null) return; + + _userBuildInfo.ChooseNodeInfo.TryAdd(nodeInfo.Key, optionInfo.Name); } - } - } - private async void InitBlueprint() - { - var path = string.Format(Constants.Constants.BuildBlueprint, _curBuildData.buildID); - DebugUtil.LogError("加载蓝图的路径:{0}", path); - CurBlueprint = await AssetManager.Instance.LoadAssetAsync(path); + //打印Debug玩家Build信息 + /*foreach (var infos in _userBuildInfo.ChooseNodeInfo) + { + DebugUtil.LogError("节点 {0} 选择的的是 {1}", infos.Key, infos.Value); + }*/ + } + catch (Exception e) + { + DebugUtil.LogError("BuildManager.InitUserBuildInfo 初始玩家信息错误 :{0}", e); + } } /// @@ -276,41 +268,71 @@ namespace Framework.Manager /// private void InitCondition() { - switch (_curBuildData.unlockType) + try { - case UnlockType.ForGroup: + switch (_curBuildData.unlockType) { - foreach (var unlockInfo in _curBuildData.unlockInfos) + case UnlockType.ForGroup: { - var nodeName = string.Format(NodeName, unlockInfo.conditionGroup); - if (NodeInfos.TryGetValue(nodeName, out var nodeInfo)) + foreach (var unlockInfo in _curBuildData.unlockInfos) { - nodeInfo.Condition = unlockInfo.condition; - //DebugUtil.LogError("挂点解锁:节点{0}的解锁条件是:{1}", nodeInfo.Name, unlockInfo.condition); - } - } - - break; - } - case UnlockType.ForThematic: - { - foreach (var unlockInfo in _curBuildData.unlockInfos) - { - var optionName = string.Format(OptionName, unlockInfo.conditionGroup); - foreach (var nodeInfo in NodeInfos.Values) - { - if (nodeInfo.Options.TryGetValue(optionName, out var optionInfo)) + var nodeName = string.Format(NodeName, unlockInfo.conditionGroup); + if (NodeInfos.TryGetValue(nodeName, out var nodeInfo)) { - optionInfo.Condition = unlockInfo.condition; - DebugUtil.LogError("主题解锁:节点{0}的选项{1}的解锁条件是:{2}", nodeInfo.Name, optionInfo.Name, - unlockInfo.condition); + nodeInfo.Condition = unlockInfo.condition; + //DebugUtil.LogError("挂点解锁:节点{0}的解锁条件是:{1}", nodeInfo.Name, unlockInfo.condition); } } - } - break; + break; + } + case UnlockType.ForThematic: + { + foreach (var unlockInfo in _curBuildData.unlockInfos) + { + var optionName = string.Format(OptionName, unlockInfo.conditionGroup); + foreach (var nodeInfo in NodeInfos.Values) + { + if (nodeInfo.Options.TryGetValue(optionName, out var optionInfo)) + { + optionInfo.Condition = unlockInfo.condition; + DebugUtil.LogError("主题解锁:节点{0}的选项{1}的解锁条件是:{2}", nodeInfo.Name, optionInfo.Name, + unlockInfo.condition); + } + } + } + + break; + } } } + catch (Exception e) + { + DebugUtil.LogError("BuildManager.InitCondition 初始化条件错误 :{0}", e); + } + } + + /// + /// 异步加载该建造物品图标 + /// + private async UniTask InitIcon() + { + try + { + foreach (var nodeInfo in NodeInfos.Values) + { + foreach (var optionInfo in nodeInfo.Options.Values) + { + var index = GameBuildUtils.ExtractNumber(optionInfo.Name); + + optionInfo.IconName = await InitOptionIcon(nodeInfo.IconPath, index); + } + } + } + catch (Exception e) + { + DebugUtil.LogError("BuildManager.InitIcon 初始化图标数据错误 :{0}", e); + } } /// @@ -318,21 +340,45 @@ namespace Framework.Manager /// private async UniTask InitOptionIcon(string iconsPath, int index) { - var fileEntries = Directory.GetFiles(iconsPath, "*.png"); - foreach (var filePath in fileEntries) + try { - var fileName = Path.GetFileName(filePath); - var name = fileName.Replace(".png", ""); - if (GameBuildUtils.ExtractNumber(name) == index) + var fileEntries = Directory.GetFiles(iconsPath, "*.png"); + foreach (var filePath in fileEntries) { - var assetPath = filePath.Replace(Application.dataPath, "").Replace('\\', '/'); - var sprite = await AssetManager.Instance.LoadAssetAsync(assetPath); - _iconSprites.TryAdd(name, sprite); - return name; + var fileName = Path.GetFileName(filePath); + var name = fileName.Replace(".png", ""); + if (GameBuildUtils.ExtractNumber(name) == index) + { + var assetPath = filePath.Replace(Application.dataPath, "").Replace('\\', '/'); + var sprite = await AssetManager.Instance.LoadAssetAsync(assetPath); + _iconSprites.TryAdd(name, sprite); + return name; + } } - } - return null; + return null; + } + catch (Exception e) + { + DebugUtil.LogError("BuildManager.InitOptionIcon 加载选项图标错误, 路径: {0}, Error: {1}", iconsPath, e); + return null; + } + } + + /// + /// 加载当前场景蓝图 + /// + private async void InitBlueprint() + { + try + { + var path = string.Format(Constants.Constants.BuildBlueprint, _curBuildData.buildID); + CurBlueprint = await AssetManager.Instance.LoadAssetAsync(path); + } + catch (Exception e) + { + DebugUtil.LogError("BuildManager.InitBlueprint 加载蓝图错误 :{0}", e); + } } /// diff --git a/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs b/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs index 7176288..8b622d6 100644 --- a/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs +++ b/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs @@ -63,6 +63,13 @@ namespace Gameplay.LoadingExecutor var buildPath = string.Format(Framework.Constants.Constants.SceneBuildPath, buildId); var buildConfig = string.Format(Framework.Constants.Constants.BuildConfigPath, buildId); var buildData = await JsonHelper.LoadFromAddressable(buildConfig); + //Debug TODO 删除 + DebugUtil.LogError("当前buildID: {0}", buildData.buildID); + foreach (var nodeInfo in buildData.NodeInfos) + { + DebugUtil.LogError("加载{0}图标路径:{1}", nodeInfo.Name, nodeInfo.IconPath); + } + await BuildManager.Instance.Init(buildData, true, buildInfo); await Addressables.LoadSceneAsync(buildPath).ToUniTask(); }