From 2923def2499cb37c7f16075c5f34a9a532318373 Mon Sep 17 00:00:00 2001 From: zhangaotian <8474238@qq.com> Date: Thu, 22 Aug 2024 15:05:59 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=AD=98=E7=9B=98=E3=80=91=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=89=93=E5=BC=80=E6=B2=A1=E6=9C=89=E8=A7=A3=E9=94=81?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Framework/Game/Forest_Main.cs | 5 +++ .../Assets/Scripts/Framework/Game/MyGame.cs | 1 - .../Scripts/Framework/State/GameStateStart.cs | 2 +- .../UI/Other/UISelectBuildController.cs | 2 +- .../UI/StartPanel/UIStartMainController.cs | 4 +- .../Scripts/Gameplay/Debug/SROptions.Level.cs | 11 +++-- .../Assets/Scripts/Gameplay2/BuildManager.cs | 44 +++++++++++++++---- .../Scripts/Gameplay2/BuildSelectManager.cs | 21 ++++++--- .../Scripts/Gameplay2/GameBuild/BuildBoot.cs | 2 +- .../Gameplay2/GameBuild/BuildEditor.cs | 2 +- 10 files changed, 69 insertions(+), 25 deletions(-) diff --git a/Forest/Assets/Scripts/Framework/Game/Forest_Main.cs b/Forest/Assets/Scripts/Framework/Game/Forest_Main.cs index a41c50e..6760bff 100644 --- a/Forest/Assets/Scripts/Framework/Game/Forest_Main.cs +++ b/Forest/Assets/Scripts/Framework/Game/Forest_Main.cs @@ -1,4 +1,5 @@ using Gameplay.Manager; +using Framework.Manager; using Framework.BI; using UnityEngine; using PhxhSDK; @@ -60,6 +61,10 @@ namespace Gameplay.Game { ADManager.Instance.Release(); _game.Release(); + + //建造释放 + BuildSelectManager.Instance.Release(); + BuildManager.Instance.Release(); } } } \ No newline at end of file diff --git a/Forest/Assets/Scripts/Framework/Game/MyGame.cs b/Forest/Assets/Scripts/Framework/Game/MyGame.cs index 3aa428d..6413fdd 100644 --- a/Forest/Assets/Scripts/Framework/Game/MyGame.cs +++ b/Forest/Assets/Scripts/Framework/Game/MyGame.cs @@ -26,7 +26,6 @@ namespace Gameplay _Register(); _Register(); _Register(); - _Register(); _Register(); SDKManager.Instance.Init(); diff --git a/Forest/Assets/Scripts/Framework/State/GameStateStart.cs b/Forest/Assets/Scripts/Framework/State/GameStateStart.cs index 820686c..69bc926 100644 --- a/Forest/Assets/Scripts/Framework/State/GameStateStart.cs +++ b/Forest/Assets/Scripts/Framework/State/GameStateStart.cs @@ -28,7 +28,7 @@ namespace Gameplay.Game public void OnExit() { - BuildManager.Instance.Release(); + BuildManager.Instance.CurBuildRelease(); UIManager.Instance.CloseAllUI(true); GfxManager.Instance.ReturnGfxObj("Effect_SelectSequin", true); GfxManager.Instance.ReturnGfxObj("Effect_Sequin", true); diff --git a/Forest/Assets/Scripts/Framework/UI/Other/UISelectBuildController.cs b/Forest/Assets/Scripts/Framework/UI/Other/UISelectBuildController.cs index de712dd..efbafbf 100644 --- a/Forest/Assets/Scripts/Framework/UI/Other/UISelectBuildController.cs +++ b/Forest/Assets/Scripts/Framework/UI/Other/UISelectBuildController.cs @@ -82,7 +82,7 @@ public class UISelectBuildController : UIWindow private void GoBuild() { - if (!_curBuildID.Equals(BuildManager.Instance.UserBuildInfo.CurBuildId)) + if (!_curBuildID.Equals(BuildManager.Instance.CurBuildInfo.BuildSceneID)) { BuildManager.Instance.ChangeBuildSceneID = true; GameStateManager.Instance.ChangeState(new GameStateStart(buildID: _curBuildID)); diff --git a/Forest/Assets/Scripts/Framework/UI/StartPanel/UIStartMainController.cs b/Forest/Assets/Scripts/Framework/UI/StartPanel/UIStartMainController.cs index 2681b55..d686c89 100644 --- a/Forest/Assets/Scripts/Framework/UI/StartPanel/UIStartMainController.cs +++ b/Forest/Assets/Scripts/Framework/UI/StartPanel/UIStartMainController.cs @@ -39,7 +39,7 @@ public class UIStartMainController : UIWindow { OnStart(); } - + private void InitBlueprint() { _blueprint = FindObj("ResultPanel"); @@ -87,7 +87,7 @@ public class UIStartMainController : UIWindow private async void ChangeBuildScene() { - await UIManager.Instance.OpenWindow(UIConstants.UISelectBuild, BuildManager.Instance.UserBuildInfo.CurBuildId); + await UIManager.Instance.OpenWindow(UIConstants.UISelectBuild, BuildManager.Instance.CurBuildInfo.BuildSceneID); } /// diff --git a/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Level.cs b/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Level.cs index d46a74e..5975d02 100644 --- a/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Level.cs +++ b/Forest/Assets/Scripts/Gameplay/Debug/SROptions.Level.cs @@ -1,12 +1,12 @@ using System.ComponentModel; +using Gameplay.ForestLevel; using Framework.Constants; using LC.Newtonsoft.Json; +using Framework.Manager; using Gameplay.Manager; using Framework.Event; -using Framework.Manager; -using Gameplay.Level; +using Gameplay.Game; using Framework.UI; -using Gameplay.ForestLevel; using PhxhSDK; public partial class SROptions @@ -39,6 +39,9 @@ public partial class SROptions public void PassAllLevel() { LevelSelectManager.Instance.PassAllLevel(); + BuildManager.Instance.ChangeBuildSceneID = true; + GameStateManager.Instance.ChangeState( + new GameStateStart(buildID: BuildManager.Instance.CurBuildInfo.BuildSceneID)); } [Category("关卡相关"), DisplayName("开启新手引导")] @@ -78,7 +81,7 @@ public partial class SROptions { LevelSelectManager.Instance.ClearFile(); } - + [Category("存档相关"), DisplayName("清除当前场景所有选择节点")] public void ClearBuildOption() { diff --git a/Forest/Assets/Scripts/Gameplay2/BuildManager.cs b/Forest/Assets/Scripts/Gameplay2/BuildManager.cs index 4737627..13e9a72 100644 --- a/Forest/Assets/Scripts/Gameplay2/BuildManager.cs +++ b/Forest/Assets/Scripts/Gameplay2/BuildManager.cs @@ -2,13 +2,12 @@ using System; using PhxhSDK; using UnityEngine; using System.Linq; +using PhxhSDK.Phxh; using LC.Newtonsoft.Json; using Framework.Constants; using Sirenix.OdinInspector; using Cysharp.Threading.Tasks; using System.Collections.Generic; -using cfg.Build; -using PhxhSDK.Phxh; using UnityEngine.AddressableAssets; namespace Framework.Manager @@ -124,8 +123,12 @@ namespace Framework.Manager public class BuildInfo { public string BuildSceneID; + public Dictionary ChooseNodeInfo; + //当前节点 + public bool Complete; + public BuildInfo() { ChooseNodeInfo = new Dictionary(); @@ -192,9 +195,9 @@ namespace Framework.Manager private UserBuildInfo _userBuildInfo; /// - /// 当前主题玩家选择情况 + /// 当前玩家选择主题 /// - public BuildInfo BuildInfo + public BuildInfo CurBuildInfo { get => _curBuildInfo; private set => _curBuildInfo = value; @@ -245,6 +248,7 @@ namespace Framework.Manager { InitForStorage(); + var lastBuildID = _curBuildInfo; var buildConfigId = !string.IsNullOrEmpty(buildID) ? buildID : _userBuildInfo.CurBuildId; if (!TableManager.Instance.Tables.BuildConfig.DataMap.TryGetValue(buildConfigId, out var buildConfig)) @@ -267,8 +271,12 @@ namespace Framework.Manager await Init(buildData, true); await Addressables.LoadSceneAsync(buildConfig.Path).ToUniTask(); - _userBuildInfo.CurBuildId = buildConfigId; - StorageManager.Instance.SaveWithoutUpdate(); + + if (lastBuildID is { Complete: true } && !_curBuildInfo.Complete) + { + _userBuildInfo.CurBuildId = buildConfigId; + StorageManager.Instance.SaveWithoutUpdate(); + } } /// @@ -546,7 +554,7 @@ namespace Framework.Manager if (_curBuildInfo.ChooseNodeInfo.TryGetValue(node, out var oldOption)) { _curBuildInfo.ChooseNodeInfo[node] = option; - DebugUtil.LogY($"场景{_userBuildInfo.CurBuildId}中的节点{node}保存了{option}选择"); + DebugUtil.LogY($"场景{_curBuildInfo.BuildSceneID}中的节点{node}保存了{option}选择"); } else { @@ -554,6 +562,19 @@ namespace Framework.Manager _curBuildInfo.ChooseNodeInfo.Add(node, option); } + var complete = true; + foreach (var chooseNode in _curBuildInfo.ChooseNodeInfo) + { + if (string.IsNullOrEmpty(chooseNode.Value)) + { + complete = false; + break; + } + } + + if (complete) + _curBuildInfo.Complete = true; + StorageManager.Instance.SaveWithoutUpdate(); } @@ -643,13 +664,13 @@ namespace Framework.Manager private void DebugUserChooseNode() { - foreach (var infos in BuildInfo.ChooseNodeInfo) + foreach (var infos in CurBuildInfo.ChooseNodeInfo) { DebugUtil.LogError("节点 {0} 选择的的是 {1}", infos.Key, infos.Value); } } - public void Release() + public void CurBuildRelease() { foreach (var icon in _iconSprites) { @@ -659,5 +680,10 @@ namespace Framework.Manager CurBlueprint = null; CurTopBuildUI = null; } + + public void Release() + { + CurBuildRelease(); + } } } \ No newline at end of file diff --git a/Forest/Assets/Scripts/Gameplay2/BuildSelectManager.cs b/Forest/Assets/Scripts/Gameplay2/BuildSelectManager.cs index 8809507..a0eba17 100644 --- a/Forest/Assets/Scripts/Gameplay2/BuildSelectManager.cs +++ b/Forest/Assets/Scripts/Gameplay2/BuildSelectManager.cs @@ -7,7 +7,7 @@ using Framework.Constants; using Cysharp.Threading.Tasks; using System.Collections.Generic; -public class BuildSelectManager : Singlenton, IInitable +public class BuildSelectManager { public class BuildSelectItem { @@ -17,6 +17,21 @@ public class BuildSelectManager : Singlenton, IInitable public int Index; } + private static BuildSelectManager _instance; + + public static BuildSelectManager Instance + { + get + { + if (_instance == null) + { + _instance = new BuildSelectManager(); + } + + return _instance; + } + } + public Dictionary BuildSelectItems; private bool _isInit; @@ -81,10 +96,6 @@ public class BuildSelectManager : Singlenton, IInitable return BuildSelectItems.Values.FirstOrDefault(item => item.Index == index - 1); } - public void Init() - { - } - public void Release() { foreach (var buildSelectItem in BuildSelectItems) diff --git a/Forest/Assets/Scripts/Gameplay2/GameBuild/BuildBoot.cs b/Forest/Assets/Scripts/Gameplay2/GameBuild/BuildBoot.cs index c72b0ce..ec43f21 100644 --- a/Forest/Assets/Scripts/Gameplay2/GameBuild/BuildBoot.cs +++ b/Forest/Assets/Scripts/Gameplay2/GameBuild/BuildBoot.cs @@ -321,7 +321,7 @@ public class BuildBoot : MonoBehaviour /// private void UpdateBuildDisplay() { - var chooseNodeInfo = BuildManager.Instance.BuildInfo.ChooseNodeInfo; + var chooseNodeInfo = BuildManager.Instance.CurBuildInfo.ChooseNodeInfo; if (chooseNodeInfo == null || chooseNodeInfo.Count <= 0) { DebugUtil.LogError("Build Boot: 玩家在该场景的建造信息获取错误"); diff --git a/Forest/Assets/Scripts/Gameplay2/GameBuild/BuildEditor.cs b/Forest/Assets/Scripts/Gameplay2/GameBuild/BuildEditor.cs index 8c6b366..b3696b5 100644 --- a/Forest/Assets/Scripts/Gameplay2/GameBuild/BuildEditor.cs +++ b/Forest/Assets/Scripts/Gameplay2/GameBuild/BuildEditor.cs @@ -52,7 +52,7 @@ namespace Framework.GameBuild { if (!BuildManager.Instance.BuildInGame) { - BuildManager.Instance.Release(); + BuildManager.Instance.CurBuildRelease(); } }