diff --git a/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs b/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs index e322834..94612ca 100644 --- a/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs +++ b/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs @@ -1,10 +1,9 @@ using System; using System.Collections.Generic; using System.IO; -using System.Text.RegularExpressions; +using Framework.GameBuild; +using PhxhSDK; using UnityEngine; -using cfg.Build; -using Cysharp.Threading.Tasks; using Sirenix.OdinInspector; using UnityEditor; @@ -64,6 +63,9 @@ namespace Framework.Manager } } + /// + /// 节点信息类 + /// public class NodeInfo { public string Name; @@ -76,6 +78,9 @@ namespace Framework.Manager public string IconPath; } + /// + /// 节点选项类 + /// public class OptionInfo { public int ID; @@ -107,9 +112,10 @@ namespace Framework.Manager } } - public BuildData CurBuildData { get; private set; } - public int CurCondition; + public Dictionary NodeInfos; + + private BuildData _curBuildData; private bool _isInit; private bool _isInGame; @@ -117,7 +123,7 @@ namespace Framework.Manager { if (_isInit) return; NodeInfos = new Dictionary(); - CurBuildData = buildData; + _curBuildData = buildData; foreach (var node in buildData.nodeInfos) { var nodeInfo = new NodeInfo @@ -129,7 +135,7 @@ namespace Framework.Manager foreach (var option in node.options) { - var index = ExtractNumber(option); + var index = GameBuildUtils.ExtractNumber(option); var optionInfo = new OptionInfo() { ID = index, @@ -146,13 +152,16 @@ namespace Framework.Manager _isInit = true; } + /// + /// 初始化条件 + /// private void InitCondition() { - switch (CurBuildData.unlockType) + switch (_curBuildData.unlockType) { case UnlockType.ForGroup: { - foreach (var unlockInfo in CurBuildData.unlockInfos) + foreach (var unlockInfo in _curBuildData.unlockInfos) { var nodeName = string.Format(NodeName, unlockInfo.conditionGroup); if (NodeInfos.TryGetValue(nodeName, out var nodeInfo)) @@ -166,7 +175,7 @@ namespace Framework.Manager } case UnlockType.ForThematic: { - foreach (var unlockInfo in CurBuildData.unlockInfos) + foreach (var unlockInfo in _curBuildData.unlockInfos) { var optionName = string.Format(OptionName, unlockInfo.conditionGroup); foreach (var nodeInfo in NodeInfos.Values) @@ -197,7 +206,7 @@ namespace Framework.Manager { var fileName = Path.GetFileName(filePath); var name = fileName.Replace(".png", ""); - if (ExtractNumber(name) == index) + if (GameBuildUtils.ExtractNumber(name) == index) { var assetPath = filePath.Replace(Application.dataPath, "").Replace('\\', '/'); return assetPath; @@ -207,32 +216,16 @@ namespace Framework.Manager return null; } - private int ExtractNumber(string input) - { - var str = input; - int lastIndex = input.LastIndexOf('_'); - if (lastIndex != -1 && lastIndex < input.Length - 1) - { - str = input.Substring(lastIndex + 1); - } - - Match match = Regex.Match(str, @"\d+"); - - if (match.Success) - { - return int.Parse(match.Value); - } - - return 0; - } - + /// + /// 获得选项Icon图标 + /// public Sprite GetOptionIcon(string nodeName, string optionName) { if (NodeInfos.TryGetValue(nodeName, out var nodeInfo)) { if (nodeInfo.Options.TryGetValue(optionName, out var optionInfo)) { - var sprite = AssetDatabase.LoadAssetAtPath(optionInfo.IconPath); + var sprite = AssetManager.Instance.LoadAsset(optionInfo.IconPath); if (sprite != null) return sprite; } @@ -241,6 +234,10 @@ namespace Framework.Manager return null; } + /// + /// 根据节点获得解锁条件 + /// + /// public int GetCondition(string nodeName) { var condition = 0; diff --git a/Forest/Assets/Scripts/Framework/Manager/EditorTableManager.cs b/Forest/Assets/Scripts/Framework/Manager/EditorTableManager.cs index ed6a6a5..c6c4d5f 100644 --- a/Forest/Assets/Scripts/Framework/Manager/EditorTableManager.cs +++ b/Forest/Assets/Scripts/Framework/Manager/EditorTableManager.cs @@ -5,6 +5,7 @@ using UnityEngine; namespace Framework.Manager { +#if UNITY_EDITOR public class EditorTableManager { private static EditorTableManager _instance; @@ -52,4 +53,5 @@ namespace Framework.Manager return getValue.ValueEn; } } +#endif } \ No newline at end of file