diff --git a/Forest/Assets/Scripts/Framework/GameBuild/BuildBoot.cs b/Forest/Assets/Scripts/Framework/GameBuild/BuildBoot.cs index 3c8596c..db92a66 100644 --- a/Forest/Assets/Scripts/Framework/GameBuild/BuildBoot.cs +++ b/Forest/Assets/Scripts/Framework/GameBuild/BuildBoot.cs @@ -1,15 +1,14 @@ using TMPro; using System; +using PhxhSDK; using UnityEngine; using UnityEngine.UI; using Gameplay.Level; +using Framework.Event; using Gameplay.Manager; using Framework.Manager; using Sirenix.OdinInspector; using System.Collections.Generic; -using Framework.Event; -using PhxhSDK; -using UnityEngine.Rendering.Universal; public class BuildBoot : MonoBehaviour { @@ -307,27 +306,44 @@ public class BuildBoot : MonoBehaviour return; } + CurCondition = BuildManager.Instance.ReachCondition < 0 + ? CurCondition + : BuildManager.Instance.ReachCondition; var nextLockNode = BuildManager.Instance.GetNextLockNode(CurCondition); - foreach (var chooseNode in chooseNodeInfo) + if (string.IsNullOrEmpty(nextLockNode)) { - if (_nodes.TryGetValue(chooseNode.Key, out var node)) + foreach (var chooseNode in chooseNodeInfo) { - var option = node.GetOption(chooseNode.Value); - var condition = BuildManager.Instance.GetCondition(chooseNode.Key); - if (CurCondition >= condition) + if (_nodes.TryGetValue(chooseNode.Key, out var node)) { + var option = node.GetOption(chooseNode.Value); node.OptionDisplay(option); } - else + } + } + else + { + foreach (var chooseNode in chooseNodeInfo) + { + if (_nodes.TryGetValue(chooseNode.Key, out var node)) { - if (node.Name.Equals(nextLockNode)) + var option = node.GetOption(chooseNode.Value); + var condition = BuildManager.Instance.GetCondition(chooseNode.Key); + if (CurCondition >= condition) { - _curBubble = node.BubbleObj; - node.CloseAllOptionButBubble(true); + node.OptionDisplay(option); } else { - node.CloseAllOptionButBubble(false); + if (node.Name.Equals(nextLockNode)) + { + _curBubble = node.BubbleObj; + node.CloseAllOptionButBubble(true); + } + else + { + node.CloseAllOptionButBubble(false); + } } } } @@ -503,13 +519,15 @@ public class BuildBoot : MonoBehaviour private void ShowUI() { _uiMainBuild.SetActive(true); - _curBubble.SetActive(true); + if (_curBubble != null) + _curBubble.SetActive(false); } private void HideUI() { _uiMainBuild.SetActive(false); - _curBubble.SetActive(false); + if (_curBubble != null) + _curBubble.SetActive(false); } #endregion diff --git a/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs b/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs index 6a70210..6266062 100644 --- a/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs +++ b/Forest/Assets/Scripts/Framework/Manager/BuildManager.cs @@ -1,10 +1,8 @@ using System; using PhxhSDK; -using System.IO; using UnityEngine; using System.Linq; using LC.Newtonsoft.Json; -using Framework.GameBuild; using Sirenix.OdinInspector; using Cysharp.Threading.Tasks; using System.Collections.Generic; @@ -161,7 +159,13 @@ namespace Framework.Manager } //已达到的条件 - public int ReachCondition; + public int ReachCondition + { + get => _reachCondition; + private set => _reachCondition = value; + } + + private int _reachCondition = -1; //动态加载的图标 private Dictionary _iconSprites; @@ -442,6 +446,9 @@ namespace Framework.Manager { var nodeList = NodeInfos.Values.Where(node => node.Condition > condition).ToList(); + if (nodeList.Count <= 0) + return null; + nodeName = nodeList[0].Name; int minCondition = nodeList[0].Condition; @@ -471,7 +478,8 @@ namespace Framework.Manager /// public void UpdateReachCondition(int condition) { - ReachCondition = condition; + //TODO 分场景 、解锁类型、解锁条件 + _reachCondition = condition; } public void Release() diff --git a/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Level.cs b/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Level.cs index 47545d0..fb011f8 100644 --- a/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Level.cs +++ b/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Level.cs @@ -6,17 +6,9 @@ using Framework.Event; using Gameplay.Level; using Framework.UI; using PhxhSDK; -using UnityEngine; public partial class SROptions { - [Category("临时测试"), DisplayName("读取文件")] - public async void ReadFile() - { - var iconPath = "Assets/Art/GameBuild/Texture/Series_Spring/Node1/Icon/Grass_1.png"; - var sprite = await AssetManager.Instance.LoadAssetAsync(iconPath); - DebugUtil.LogError("加载失败:{0}", sprite == null); - } [Category("关卡相关"), DisplayName("增加10s")] public void IncreaseTime() diff --git a/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs b/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs index 7176288..43fe33d 100644 --- a/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs +++ b/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs @@ -63,6 +63,8 @@ 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); + var reachCondition = LevelSelectManager.Instance.CurPassLevelIndex; + BuildManager.Instance.UpdateReachCondition(reachCondition); await BuildManager.Instance.Init(buildData, true, buildInfo); await Addressables.LoadSceneAsync(buildPath).ToUniTask(); } diff --git a/Forest/Assets/Scripts/Gameplay/UI/StartPanel/UIStartMainController.cs b/Forest/Assets/Scripts/Gameplay/UI/StartPanel/UIStartMainController.cs index d68929b..d747a43 100644 --- a/Forest/Assets/Scripts/Gameplay/UI/StartPanel/UIStartMainController.cs +++ b/Forest/Assets/Scripts/Gameplay/UI/StartPanel/UIStartMainController.cs @@ -21,7 +21,7 @@ public class UIStartMainController : UIWindow InitBlueprint(); _mask = FindObj("MaskPanel").gameObject; - BindButton("MaskPanel", ShowUI); + BindButton("MaskPanel", ShowAllUI); BindButton("UI_LiuHaiBottom/Btn_Game", OnEnterLevel); BindButton("UI_LiuHaiBottom/Btn_Level", OnSelectLevel); BindButton("UI_LiuHaiTop/Btn_Setting", OpenSettingPanel); @@ -49,12 +49,17 @@ public class UIStartMainController : UIWindow EventManager.Instance.Send(EventManager.EventName.HideBuildUI); } + private void ShowAllUI() + { + ShowUI(); + EventManager.Instance.Send(EventManager.EventName.ShowBuildUI); + } + private void ShowUI() { FindObj("UI_LiuHaiBottom").SetActive(true); FindObj("UI_LiuHaiTop").SetActive(true); _mask.SetActive(false); - EventManager.Instance.Send(EventManager.EventName.ShowBuildUI); } private void HideUI()