From 43779c560ed64e977ac384f22f78d6161c4a1092 Mon Sep 17 00:00:00 2001 From: Michal Pikulski Date: Tue, 28 Oct 2025 14:31:17 +0100 Subject: [PATCH] Cleanup compile warnings, cleanup logs, spruce up level selection menu --- Assets/AppleHillsRenderPipeline.asset | 2 +- Assets/Data/SubLevels/Quarry.asset | 1 + Assets/Editor/CardSystem/CardEditorWindow.cs | 12 +- .../Editor/PuzzleSystem/PuzzleEditorWindow.cs | 10 +- .../Editor/Settings/EditorSettingsProvider.cs | 13 +- .../AstarPathfindingProject/Core/AstarPath.cs | 24 +- Assets/External/Placeholders/padlock.png | Bin 0 -> 4035 bytes Assets/External/Placeholders/padlock.png.meta | 195 +++ Assets/Prefabs/UI/LevelConfirmMenu.prefab | 1474 ++++++++++++++++- Assets/Resources/PerformanceTestRunInfo.json | 1 + .../PerformanceTestRunInfo.json.meta | 7 + .../Resources/PerformanceTestRunSettings.json | 1 + .../PerformanceTestRunSettings.json.meta | 7 + .../Scenes/Levels/AppleHillsOverworld.unity | 45 - Assets/Scenes/Levels/Sublevel_1.unity | 218 --- Assets/Scenes/Levels/Sublevel_2.unity | 218 --- Assets/Scenes/MiniGames/BirdPoop.unity | 493 ++++++ ...igame_2.unity.meta => BirdPoop.unity.meta} | 2 +- .../Scenes/MiniGames/CardQualityControl.unity | 493 ++++++ .../CardQualityControl.unity.meta} | 2 +- Assets/Scenes/MiniGames/FortFight.unity | 493 ++++++ .../FortFight.unity.meta} | 2 +- Assets/Scenes/MiniGames/Minigame_2.unity | 218 --- .../Scenes/MiniGames/StatueDecoration.unity | 493 ++++++ .../MiniGames/StatueDecoration.unity.meta | 7 + .../MiniGames/ValentineNoteDelivery.unity | 493 ++++++ .../ValentineNoteDelivery.unity.meta | 7 + Assets/Scenes/TestingStuff/UIAuthoring.unity | 178 ++ .../Bootstrap/BootCompletionService.cs | 25 +- .../Scripts/Bootstrap/BootSceneController.cs | 32 +- Assets/Scripts/Bootstrap/CustomBoot.cs | 17 +- .../Scripts/Bootstrap/InitialLoadingScreen.cs | 36 +- .../Scripts/Cinematics/CinematicsManager.cs | 2 - Assets/Scripts/Core/GameManager.cs | 50 +- Assets/Scripts/Core/ItemManager.cs | 6 - Assets/Scripts/Core/QuickAccess.cs | 5 - Assets/Scripts/Core/SceneManagerService.cs | 35 +- .../Scripts/Core/SceneOrientationEnforcer.cs | 41 +- .../Core/Settings/Developer/DebugSettings.cs | 29 +- .../Core/Settings/DivingMinigameSettings.cs | 4 - .../Scripts/Core/Settings/ServiceLocator.cs | 27 +- Assets/Scripts/Core/SettingsAccess.cs | 5 + .../Data/CardSystem/CardSystemManager.cs | 6 - Assets/Scripts/Dialogue/DialogueComponent.cs | 2 - Assets/Scripts/Input/InputManager.cs | 60 +- Assets/Scripts/Input/PlayerTouchController.cs | 20 +- Assets/Scripts/Interactions/Interactable.cs | 7 +- Assets/Scripts/LevelS/LevelSwitchData.cs | 24 - Assets/Scripts/LevelS/LevelSwitchMenu.cs | 53 - Assets/Scripts/{LevelS.meta => Levels.meta} | 0 .../Scripts/{LevelS => Levels}/LevelSwitch.cs | 24 +- .../{LevelS => Levels}/LevelSwitch.cs.meta | 0 Assets/Scripts/Levels/LevelSwitchData.cs | 32 + .../LevelSwitchData.cs.meta | 0 Assets/Scripts/Levels/LevelSwitchMenu.cs | 110 ++ .../LevelSwitchMenu.cs.meta | 0 .../Bubbles/BubbleSpawner.cs | 19 +- .../DivingForPictures/DivingGameManager.cs | 7 +- .../PictureCamera/CameraViewfinderManager.cs | 9 +- .../Player/TileBumpCollision.cs | 4 - .../Tiles/TrenchTileSpawner.cs | 30 - Assets/Scripts/PuzzleS/PuzzleManager.cs | 6 - .../UI/CardSystem/BoosterOpeningPage.cs | 3 +- .../CardSystem/CardSystemSceneVisibility.cs | 7 +- Assets/Scripts/UI/LoadingScreenController.cs | 1 - Assets/Settings/Developer/DebugSettings.asset | 2 + ProjectSettings/EditorBuildSettings.asset | 15 + 67 files changed, 4814 insertions(+), 1050 deletions(-) create mode 100644 Assets/External/Placeholders/padlock.png create mode 100644 Assets/External/Placeholders/padlock.png.meta create mode 100644 Assets/Resources/PerformanceTestRunInfo.json create mode 100644 Assets/Resources/PerformanceTestRunInfo.json.meta create mode 100644 Assets/Resources/PerformanceTestRunSettings.json create mode 100644 Assets/Resources/PerformanceTestRunSettings.json.meta delete mode 100644 Assets/Scenes/Levels/Sublevel_1.unity delete mode 100644 Assets/Scenes/Levels/Sublevel_2.unity create mode 100644 Assets/Scenes/MiniGames/BirdPoop.unity rename Assets/Scenes/MiniGames/{Minigame_2.unity.meta => BirdPoop.unity.meta} (74%) create mode 100644 Assets/Scenes/MiniGames/CardQualityControl.unity rename Assets/Scenes/{Levels/Sublevel_1.unity.meta => MiniGames/CardQualityControl.unity.meta} (74%) create mode 100644 Assets/Scenes/MiniGames/FortFight.unity rename Assets/Scenes/{Levels/Sublevel_2.unity.meta => MiniGames/FortFight.unity.meta} (74%) delete mode 100644 Assets/Scenes/MiniGames/Minigame_2.unity create mode 100644 Assets/Scenes/MiniGames/StatueDecoration.unity create mode 100644 Assets/Scenes/MiniGames/StatueDecoration.unity.meta create mode 100644 Assets/Scenes/MiniGames/ValentineNoteDelivery.unity create mode 100644 Assets/Scenes/MiniGames/ValentineNoteDelivery.unity.meta delete mode 100644 Assets/Scripts/LevelS/LevelSwitchData.cs delete mode 100644 Assets/Scripts/LevelS/LevelSwitchMenu.cs rename Assets/Scripts/{LevelS.meta => Levels.meta} (100%) rename Assets/Scripts/{LevelS => Levels}/LevelSwitch.cs (84%) rename Assets/Scripts/{LevelS => Levels}/LevelSwitch.cs.meta (100%) create mode 100644 Assets/Scripts/Levels/LevelSwitchData.cs rename Assets/Scripts/{LevelS => Levels}/LevelSwitchData.cs.meta (100%) create mode 100644 Assets/Scripts/Levels/LevelSwitchMenu.cs rename Assets/Scripts/{LevelS => Levels}/LevelSwitchMenu.cs.meta (100%) diff --git a/Assets/AppleHillsRenderPipeline.asset b/Assets/AppleHillsRenderPipeline.asset index afeed58f..0ab5069b 100644 --- a/Assets/AppleHillsRenderPipeline.asset +++ b/Assets/AppleHillsRenderPipeline.asset @@ -101,7 +101,7 @@ MonoBehaviour: m_Keys: [] m_Values: m_PrefilteringModeMainLightShadows: 0 - m_PrefilteringModeAdditionalLight: 4 + m_PrefilteringModeAdditionalLight: 0 m_PrefilteringModeAdditionalLightShadows: 0 m_PrefilterXRKeywords: 1 m_PrefilteringModeForwardPlus: 0 diff --git a/Assets/Data/SubLevels/Quarry.asset b/Assets/Data/SubLevels/Quarry.asset index c5e0666a..78885e40 100644 --- a/Assets/Data/SubLevels/Quarry.asset +++ b/Assets/Data/SubLevels/Quarry.asset @@ -13,5 +13,6 @@ MonoBehaviour: m_Name: Quarry m_EditorClassIdentifier: targetLevelSceneName: Quarry + targetMinigameSceneName: DivingForPictures description: Level loading for Quarry mapSprite: {fileID: -3645797367086948227, guid: fea1a8662ef819746b8073c9ba0d9047, type: 3} diff --git a/Assets/Editor/CardSystem/CardEditorWindow.cs b/Assets/Editor/CardSystem/CardEditorWindow.cs index fa912f1c..7974b169 100644 --- a/Assets/Editor/CardSystem/CardEditorWindow.cs +++ b/Assets/Editor/CardSystem/CardEditorWindow.cs @@ -2,14 +2,13 @@ using System.IO; using System.Linq; using AppleHills.Data.CardSystem; -using UnityEditor; -using UnityEditor.AddressableAssets.Settings; -using UnityEngine; -using UnityEngine.UI; using AppleHills.Editor.Utilities; using UI.CardSystem; +using UnityEditor; +using UnityEngine; +using UnityEngine.UI; -namespace AppleHills.Editor.CardSystem +namespace Editor.CardSystem { /// /// Editor utility for managing card definitions without directly editing scriptable objects. @@ -45,11 +44,8 @@ namespace AppleHills.Editor.CardSystem private bool _previewNeedsUpdate = true; // Preview settings - private float _previewZoom = 1.0f; - private Vector2 _previewOffset = Vector2.zero; private bool _debugMode = false; private float _zoomMultiplier = 1.5f; // Default multiplier (no zoom) - private const float DEFAULT_ZOOM = 1.5f; // Store default zoom as a constant private const float BASE_ORTHO_SIZE = 400.0f; // Increased from 0.8f to 8.0f for a much wider view // PreviewRenderUtility for rendering the card in a hidden scene diff --git a/Assets/Editor/PuzzleSystem/PuzzleEditorWindow.cs b/Assets/Editor/PuzzleSystem/PuzzleEditorWindow.cs index cbbef1d6..dac05fa0 100644 --- a/Assets/Editor/PuzzleSystem/PuzzleEditorWindow.cs +++ b/Assets/Editor/PuzzleSystem/PuzzleEditorWindow.cs @@ -139,7 +139,7 @@ namespace AppleHills.Editor.PuzzleSystem // Apply any pending changes if (_isDirty) { - SaveChanges(); + SavePuzzleChanges(); _isDirty = false; } } @@ -686,7 +686,7 @@ namespace AppleHills.Editor.PuzzleSystem _isDirty = false; } - private void SaveChanges() + private void SavePuzzleChanges() { AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); @@ -782,7 +782,7 @@ namespace AppleHills.Editor.PuzzleSystem if (!_isPlaying) return; // Find PuzzleManager instance - PuzzleManager puzzleManager = Object.FindObjectOfType(); + PuzzleManager puzzleManager = Object.FindFirstObjectByType(); if (puzzleManager == null) { @@ -816,7 +816,7 @@ namespace AppleHills.Editor.PuzzleSystem { if (!_isPlaying || step == null) return; - PuzzleManager puzzleManager = Object.FindObjectOfType(); + PuzzleManager puzzleManager = Object.FindFirstObjectByType(); if (puzzleManager == null) return; // Get current unlock state @@ -860,7 +860,7 @@ namespace AppleHills.Editor.PuzzleSystem { if (!_isPlaying || step == null) return; - PuzzleManager puzzleManager = Object.FindObjectOfType(); + PuzzleManager puzzleManager = Object.FindFirstObjectByType(); if (puzzleManager == null) return; // Complete the step diff --git a/Assets/Editor/Settings/EditorSettingsProvider.cs b/Assets/Editor/Settings/EditorSettingsProvider.cs index 8e1ffec4..8237ec7b 100644 --- a/Assets/Editor/Settings/EditorSettingsProvider.cs +++ b/Assets/Editor/Settings/EditorSettingsProvider.cs @@ -1,6 +1,8 @@ using UnityEditor; using AppleHills.Core.Settings; +using Core; using UnityEngine; +using UnityEngine.Rendering.VirtualTexturing; namespace AppleHills.Editor { @@ -63,7 +65,7 @@ namespace AppleHills.Editor GetPuzzlePromptRange ); - Debug.Log("Editor settings loaded for Scene View use"); + LogDebugMessage("Editor settings loaded for Scene View use"); } public static void RefreshSceneViews() @@ -100,5 +102,14 @@ namespace AppleHills.Editor return null; } + + private static void LogDebugMessage(string message) + { + if (Application.isPlaying && + DeveloperSettingsProvider.Instance.GetSettings().settingsLogVerbosity <= LogVerbosity.Debug) + { + Logging.Debug($"[EditorSettingsProvider] {message}"); + } + } } } diff --git a/Assets/External/AstarPathfindingProject/Core/AstarPath.cs b/Assets/External/AstarPathfindingProject/Core/AstarPath.cs index a1eb673b..a62e934d 100644 --- a/Assets/External/AstarPathfindingProject/Core/AstarPath.cs +++ b/Assets/External/AstarPathfindingProject/Core/AstarPath.cs @@ -834,7 +834,7 @@ public class AstarPath : VersionedMonoBehaviour { } else if (path.error) { Debug.LogWarning(debug); } else { - Debug.Log(debug); + // Debug.Log(debug); } } } @@ -1379,7 +1379,9 @@ public class AstarPath : VersionedMonoBehaviour { if (!Application.isPlaying) return; if (logPathResults == PathLog.Heavy) - Debug.Log("+++ AstarPath Component Destroyed - Cleaning Up Pathfinding Data +++"); + { + // Debug.Log("+++ AstarPath Component Destroyed - Cleaning Up Pathfinding Data +++"); + } if (active != this) return; @@ -1397,7 +1399,9 @@ public class AstarPath : VersionedMonoBehaviour { pathProcessor.queue.TerminateReceivers(); if (logPathResults == PathLog.Heavy) - Debug.Log("Processing Possible Work Items"); + { + // Debug.Log("Processing Possible Work Items"); + } // Stop the graph update thread (if it is running) graphUpdates.DisableMultithreading(); @@ -1406,21 +1410,27 @@ public class AstarPath : VersionedMonoBehaviour { pathProcessor.JoinThreads(); if (logPathResults == PathLog.Heavy) - Debug.Log("Returning Paths"); + { + // Debug.Log("Returning Paths"); + } // Return all paths pathReturnQueue.ReturnPaths(false); if (logPathResults == PathLog.Heavy) - Debug.Log("Destroying Graphs"); + { + // Debug.Log("Destroying Graphs"); + } // Clean up graph data data.OnDestroy(); if (logPathResults == PathLog.Heavy) - Debug.Log("Cleaning up variables"); + { + // Debug.Log("Cleaning up variables"); + } // Clear variables up, static variables are good to clean up, otherwise the next scene might get weird data @@ -1781,7 +1791,7 @@ public class AstarPath : VersionedMonoBehaviour { System.GC.Collect(); if (logPathResults != PathLog.None && logPathResults != PathLog.OnlyErrors) { - Debug.Log("Scanning - Process took "+(lastScanTime*1000).ToString("0")+" ms to complete"); + // Debug.Log("Scanning - Process took "+(lastScanTime*1000).ToString("0")+" ms to complete"); } } diff --git a/Assets/External/Placeholders/padlock.png b/Assets/External/Placeholders/padlock.png new file mode 100644 index 0000000000000000000000000000000000000000..4658048339c33b58ef9a63ff025117fc9538edd9 GIT binary patch literal 4035 zcmZu!2UJr_x1JM15-E}hXb37HAWi92iUg!ZkZKnxf)r8V3P?a8p(;`ZDROB_0O@c6 z1*8NN5J8#QERh2sJM@RCdn ztO0=7w-7)f*puzu7cRdkZ);d$6y>sM|k@Ho~?>jUL&_GSsiF5fZK%XSp)NeD?jl@Z^1+5xiu8cqYGACqiAl z>sq2#Rh3pR2O3@YdUU2caCNilyV!5#|F;q4rNm{gk_AL=@R!Y;lLQ(AO)T5=%!wJo zv}FvyUrM_tVvb;l;BM~9)4f8)S*lA>ptFf%0*>hU^b?jPFx7mHU*kk$(`Y0S-ltV0 zvD_W2D3oc`8(Oe^ITyc4o4yIxSat=A{zAoT6FD-}%BpdQ6r$-)I z1ch}Pf(pcM?5^ZCxQpb^OLTwc=M+%kR;3DD4v3-XS1sA{tqF2khzA)g;z6N;H&WW4 zQcSR{Nl#ET;Yu)=Uk!L6{bAsyj)Qf7{viAzNbK5)k5S}vPnUX3e@f$X6N2ND8?yU! z8&Daf`nq+@pHT@gpHSgoIqXBL+BpU?s~Qjb|2WOk(q50Y=1cPrPdN#rfy`NEW7^cX z*XYXan7^V|m41?gFYpn7l|JjT{W{aq$iC$%?S3Uebcly7?LdU)s)Yhm{mT=Ts-djp zqnbXN`1lTag|h@|!mbp<=+PL3J8ax{IJ3Tr>p9IR%Y-ULMd49h=cnXPkBRd%tAt9l z>&o*wmveg7U7YlqL_eWT<>OtR1@PcYNsNlB|X& znzKfbvv$u9FM$vRf`PL6g?TLdrxRpT^;&zdVlRv)}4n^IT?pH4tz8O=>bz(A#W(dVn>qpH%z`J4sW6V zMPvG^29LTNW)2(L?>r8Vlx{^)Y44QZzL#!Zp?3#y7e{AY7X_3#Fu?Pj(1>t+ zMu@!vt&C=yMEn>oqP5ygV_>LzIE()LO+Vxh{>Y?r7${;Mxkzd=;d}u#O!`hV>lO+n zoaArVZ#{G`p9Vt_1$z&y1=d-U3Hj)FxMY1m8Hf9&eAvXj-O!b@GF-n1eZDLH1Z4yK zX$UWFaWx@qsmt;)mx7kUX^1={gss$Yl=9z_Za36!8xwKcZh%kJ(KfGN>;4X(5Q|Jq zE!V1Fkxf4(4{7*}J+R9(e)xCHL{jJwoj;`8np)OMxx|0MP{916EzgJSLO@h9xUaHM z$PsA%eNGgF2Us4{;5@4o2q~yO!#ju0RlD9)6+#iKw^$YT?~JwlbT_T1;((8_6@MkC z;9(-b%bw!SK%gN4NKjDMtd)rP3UPzz;DI^c>BX&=Jg4CZ8IU~?+sW_ie(xy)KAwLV zG700T$7mBK0s?#ZyK@lqm$pENn|(R~U?&A<%fVEd%jg4O{YF{ZE&GBVz{}fxWGCF| zF6DIgX$Rl{paCHM9zSE9K6|}1t}Qm?PKQIEqxQe72|ZHZ<=dZdxU5hO^1P;`mN=5rZyW!JJ0$|)PeX6;?hrjz6ZqQFG( zhPpw{o`A#jzNlf`oqtGjLnH3756xa{^R{D^k4qx$MZ&f6H~~Z5?qD9%)g+?3}R!DdeE}sI;~Q+kwZ#tA_NalHF6Z z3nq!g;*)bTAp2{>+{!YRIsBFfKSq#Bt;N&(Op^BVQ9b5Q{R|4RMsY5z%VL^#a_J$@g1t-y2J z*nhYBadq=-$HBx~ZDSkg)Izy(D2+yd-OjwsOr{|ZdB!-}48Tem%O zk9(nD=*nde3pZal7}&QJWJj^X?PTk)E|Lu#Ek0P}o;*>`jRHR1hXf;=V?$2eg*%pf zf4*Ee=ju8%BK=`p(*_RIzA;~A#*c1vdy^ z*B%T{2h!l}CUb>`AqD8R=5fcP4yUx~Ex_3Fr}vz!&rKKg&Zi7rmI+aYp{W~BCGary z(wg%5M?XzDP@p7|HN_RSL^$BJI-|oCRvNu^3I-NiS#rF0%8I`u$(j|>uPxR{#H+9h zFKwYPXRQ^9iM@;dgG5?RNA)p~qBo$~5fxdgEl30nlLWY0L!6X$Ay|waopibh`jA$> zHX%Xv1<5{733#GQpw?Rf0F=tuvHq{Us-f3gFj#_OZurU#MuUBy4hn=9m~1qixE2P8 zJGIJ7)@fFZM}3M9V(|b?9jLIrYW#Qrc8mxR@-Ti2<~4C23Yh{2nm=1B$&-;RA5IvU zY%Gx+!q zyjkBNNa+AIbQX?h*ZcpMDF0v9WE0dZZh9VrUV;QBf4+PLKknnt3l<^R_0l89nNfP| zN+@mB{cBFl!gB?x9OuNi${&`qJv$vE!B#_|vj!l?m>jn_GCtWGbS9det>tgQ9|2%; zJ?I<`_bYPNs({iOa{9x5Vwgy-Jl+lNAmj!9)arVMqGtqi zu91yA7Bgn>YzqW@J%It#JGHulIQCB(FYBL zOmiF%5@wlZu6{}=1r-L^yQ<8>o>%Wo?R48hDTEDU8qhSlI>}yBhee5e_8nW7XOgDb(|sKP-AsLc=2E%*!Z-VD#|Kt z!Ziy}2$rHR_dQ?=vur;_EZN1b%BjKY2(YZJ0Z@ozU7CAPyv;)?=kuq?JbQmrXQCVH zoixcACCv1@+tZlfBhIk0Z@!ocTN5Fr#$*-15^grxW7d0<=i%9>P;?WfQ_-=w($H#N z3c7u~2K=%P(L^I23a(r{S)feXR7vHmT+g>b2EPOw@2RsjxqSw ubytxF;lo6GP8ZliAp{>g1pix05NB~H @@ -90,21 +92,21 @@ namespace Bootstrap if (IsBootComplete) { // If boot is already complete, execute immediately - Debug.Log($"[BootCompletionService] Executing late registration: {name} (Priority: {priority})"); + LogDebugMessage($"Executing late registration: {name} (Priority: {priority})"); try { action(); } catch (Exception ex) { - Debug.LogError($"[BootCompletionService] Error executing init action '{name}': {ex}"); + LogDebugMessage($"Error executing init action '{name}': {ex}"); } } else { // Otherwise add to the queue _initializationActions.Add(initAction); - Debug.Log($"[BootCompletionService] Registered init action: {name} (Priority: {priority})"); + LogDebugMessage($"Registered init action: {name} (Priority: {priority})"); } } @@ -134,17 +136,26 @@ namespace Bootstrap { try { - Debug.Log($"[BootCompletionService] Executing: {action.Name} (Priority: {action.Priority})"); + LogDebugMessage($"Executing: {action.Name} (Priority: {action.Priority})"); action.Action(); } catch (Exception ex) { - Debug.LogError($"[BootCompletionService] Error executing init action '{action.Name}': {ex}"); + LogDebugMessage($"Error executing init action '{action.Name}': {ex}"); } } // Clear the list after execution _initializationActions.Clear(); } + + private static void LogDebugMessage(string message) + { + if (DeveloperSettingsProvider.Instance.GetSettings().bootstrapLogVerbosity <= + LogVerbosity.Debug) + { + Logging.Debug($"[BootCompletionService] {message}"); + } + } } } diff --git a/Assets/Scripts/Bootstrap/BootSceneController.cs b/Assets/Scripts/Bootstrap/BootSceneController.cs index 87273aed..7fc05ac4 100644 --- a/Assets/Scripts/Bootstrap/BootSceneController.cs +++ b/Assets/Scripts/Bootstrap/BootSceneController.cs @@ -1,4 +1,5 @@ using System; +using AppleHills.Core.Settings; using UnityEngine; using UI; using Core; @@ -27,10 +28,11 @@ namespace Bootstrap private bool _bootComplete = false; private bool _hasStartedLoading = false; private float _sceneLoadingProgress = 0f; + private LogVerbosity _logVerbosity = LogVerbosity.Warning; private void Start() { - Debug.Log("[BootSceneController] Boot scene started"); + LogDebugMessage("Boot scene started"); // Ensure the initial loading screen exists if (initialLoadingScreen == null) @@ -56,6 +58,8 @@ namespace Bootstrap 50, // Higher priority (lower number) "BootSceneController.OnBootCompleted" ); + + _logVerbosity = DeveloperSettingsProvider.Instance.GetSettings().bootstrapLogVerbosity; // In debug mode, log additional information if (debugMode) @@ -69,12 +73,12 @@ namespace Bootstrap /// private void OnInitialLoadingComplete() { - Debug.Log("[BootSceneController] Initial loading screen fully hidden, boot sequence completed"); + LogDebugMessage("Initial loading screen fully hidden, boot sequence completed"); // Play the intro cinematic if available if (CinematicsManager.Instance != null) { - Debug.Log("[BootSceneController] Attempting to play intro cinematic"); + LogDebugMessage("Attempting to play intro cinematic"); // Use LoadAndPlayCinematic to play the intro sequence CinematicsManager.Instance.LoadAndPlayCinematic("IntroSequence"); @@ -131,13 +135,13 @@ namespace Bootstrap { if (debugMode) { - Debug.Log($"[BootSceneController] Bootstrap progress: {progress:P0}, Combined: {GetCombinedProgress():P0}"); + LogDebugMessage($"Bootstrap progress: {progress:P0}, Combined: {GetCombinedProgress():P0}"); } } private void LogDebugInfo() { - Debug.Log($"[BootSceneController] Debug - Phase: {_currentPhase}, Bootstrap: {CustomBoot.CurrentProgress:P0}, " + + LogDebugMessage($"Debug - Phase: {_currentPhase}, Bootstrap: {CustomBoot.CurrentProgress:P0}, " + $"Scene: {_sceneLoadingProgress:P0}, Combined: {GetCombinedProgress():P0}, Boot Complete: {_bootComplete}"); } @@ -146,7 +150,7 @@ namespace Bootstrap // Unsubscribe to prevent duplicate calls CustomBoot.OnBootCompleted -= OnBootCompleted; - Debug.Log("[BootSceneController] Boot process completed"); + LogDebugMessage("Boot process completed"); _bootComplete = true; // After a small delay, start loading the main menu @@ -166,7 +170,7 @@ namespace Bootstrap private async void LoadMainScene() { - Debug.Log($"[BootSceneController] Loading main menu scene: {mainSceneName}"); + LogDebugMessage($"Loading main menu scene: {mainSceneName}"); try { @@ -180,7 +184,7 @@ namespace Bootstrap if (debugMode) { - Debug.Log($"[BootSceneController] Scene loading raw: {value:P0}, Combined: {GetCombinedProgress():P0}"); + LogDebugMessage($"Scene loading raw: {value:P0}, Combined: {GetCombinedProgress():P0}"); } }); @@ -229,7 +233,7 @@ namespace Bootstrap Scene currentScene = SceneManager.GetActiveScene(); string startingSceneName = currentScene.name; - Debug.Log($"[BootSceneController] Unloading StartingScene: {startingSceneName}"); + LogDebugMessage($"Unloading StartingScene: {startingSceneName}"); // Unload the StartingScene await SceneManager.UnloadSceneAsync(startingSceneName); @@ -238,7 +242,7 @@ namespace Bootstrap Scene mainMenuScene = SceneManager.GetSceneByName(mainSceneName); SceneManager.SetActiveScene(mainMenuScene); - Debug.Log($"[BootSceneController] Transition complete: {startingSceneName} unloaded, {mainSceneName} is now active"); + LogDebugMessage($"Transition complete: {startingSceneName} unloaded, {mainSceneName} is now active"); // Destroy the boot scene controller since its job is done Destroy(gameObject); @@ -266,5 +270,13 @@ namespace Bootstrap _progressAction?.Invoke(value); } } + + private void LogDebugMessage(string message) + { + if ( _logVerbosity <= LogVerbosity.Debug) + { + Logging.Debug($"[BootSceneController] {message}"); + } + } } } diff --git a/Assets/Scripts/Bootstrap/CustomBoot.cs b/Assets/Scripts/Bootstrap/CustomBoot.cs index 6ff31ccc..72591eac 100644 --- a/Assets/Scripts/Bootstrap/CustomBoot.cs +++ b/Assets/Scripts/Bootstrap/CustomBoot.cs @@ -1,5 +1,7 @@ using System; using System.Threading.Tasks; +using AppleHills.Core.Settings; +using Core; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; @@ -99,7 +101,7 @@ namespace Bootstrap if (Application.isPlaying) { // Direct call to boot completion service - Debug.Log("[CustomBoot] Calling BootCompletionService.HandleBootCompleted()"); + LogDebugMessage("Calling BootCompletionService.HandleBootCompleted()"); BootCompletionService.HandleBootCompleted(); } } @@ -119,7 +121,7 @@ namespace Bootstrap if (Application.isPlaying) { // Direct call to boot completion service - Debug.Log("[CustomBoot] Calling BootCompletionService.HandleBootCompleted()"); + LogDebugMessage("Calling BootCompletionService.HandleBootCompleted()"); BootCompletionService.HandleBootCompleted(); } } @@ -227,7 +229,16 @@ namespace Bootstrap { CurrentProgress = Mathf.Clamp01(progress); OnBootProgressChanged?.Invoke(CurrentProgress); - Debug.Log($"[CustomBoot] Progress: {CurrentProgress:P0}"); + LogDebugMessage($"Progress: {CurrentProgress:P0}"); + } + + private static void LogDebugMessage(string message) + { + if (DeveloperSettingsProvider.Instance.GetSettings().bootstrapLogVerbosity <= + LogVerbosity.Debug) + { + Logging.Debug($"[CustomBoot] {message}"); + } } } } \ No newline at end of file diff --git a/Assets/Scripts/Bootstrap/InitialLoadingScreen.cs b/Assets/Scripts/Bootstrap/InitialLoadingScreen.cs index bebe4d9b..1c7430ef 100644 --- a/Assets/Scripts/Bootstrap/InitialLoadingScreen.cs +++ b/Assets/Scripts/Bootstrap/InitialLoadingScreen.cs @@ -1,8 +1,9 @@ using System; using System.Collections; +using AppleHills.Core.Settings; +using Core; using UnityEngine; using UnityEngine.UI; -using Core; namespace Bootstrap { @@ -40,7 +41,9 @@ namespace Bootstrap /// Current progress provider being used for the loading screen /// private ProgressProvider _currentProgressProvider; - + + private LogVerbosity _logVerbosity = LogVerbosity.Warning; + /// /// Default progress provider that returns 0 (or 1 if loading is complete) /// @@ -62,7 +65,12 @@ namespace Bootstrap loadingScreenContainer.SetActive(false); } } - + + private void Start() + { + _logVerbosity = DeveloperSettingsProvider.Instance.GetSettings().bootstrapLogVerbosity; + } + /// /// Shows the loading screen and resets the progress bar to zero /// @@ -130,7 +138,7 @@ namespace Bootstrap float displayProgress = Mathf.Min(steadyProgress, actualProgress); // Log the progress values for debugging - Debug.Log($"[InitialLoadingScreen] Progress - Default: {steadyProgress:F2}, Actual: {actualProgress:F2}, Display: {displayProgress:F2}"); + LogDebugMessage($"Progress - Default: {steadyProgress:F2}, Actual: {actualProgress:F2}, Display: {displayProgress:F2}"); // Directly set the progress bar fill amount without smoothing if (progressBarImage != null) @@ -143,7 +151,7 @@ namespace Bootstrap if (steadyProgress >= 1.0f && displayProgress >= 1.0f) { _animationComplete = true; - Debug.Log("[InitialLoadingScreen] Animation complete"); + LogDebugMessage("Animation complete"); break; } @@ -155,7 +163,7 @@ namespace Bootstrap if (progressBarImage != null) { progressBarImage.fillAmount = 1.0f; - Debug.Log("[InitialLoadingScreen] Final progress set to 1.0"); + LogDebugMessage("Final progress set to 1.0"); } // Hide the screen if loading is also complete @@ -164,7 +172,7 @@ namespace Bootstrap if (loadingScreenContainer != null) { loadingScreenContainer.SetActive(false); - Debug.Log("[InitialLoadingScreen] Animation AND loading complete, hiding screen"); + LogDebugMessage("Animation AND loading complete, hiding screen"); // Invoke the callback when fully hidden _onLoadingScreenFullyHidden?.Invoke(); @@ -181,7 +189,7 @@ namespace Bootstrap /// public void HideLoadingScreen() { - Debug.Log("[InitialLoadingScreen] Loading complete, marking loading as finished"); + LogDebugMessage("Loading complete, marking loading as finished"); // Mark that loading is complete _loadingComplete = true; @@ -192,7 +200,7 @@ namespace Bootstrap if (loadingScreenContainer != null) { loadingScreenContainer.SetActive(false); - Debug.Log("[InitialLoadingScreen] Animation already complete, hiding screen immediately"); + LogDebugMessage("Animation already complete, hiding screen immediately"); // Invoke the callback when fully hidden _onLoadingScreenFullyHidden?.Invoke(); @@ -202,7 +210,7 @@ namespace Bootstrap } else { - Debug.Log("[InitialLoadingScreen] Animation still in progress, waiting for it to complete"); + LogDebugMessage("Animation still in progress, waiting for it to complete"); // The coroutine will handle hiding when animation completes } } @@ -236,5 +244,13 @@ namespace Bootstrap return tcs.Task; } + + private void LogDebugMessage(string message) + { + if ( _logVerbosity <= LogVerbosity.Debug) + { + Logging.Debug($"[InitialLoadingScreen] {message}"); + } + } } } diff --git a/Assets/Scripts/Cinematics/CinematicsManager.cs b/Assets/Scripts/Cinematics/CinematicsManager.cs index 9bd85c00..9d62850c 100644 --- a/Assets/Scripts/Cinematics/CinematicsManager.cs +++ b/Assets/Scripts/Cinematics/CinematicsManager.cs @@ -19,7 +19,6 @@ namespace Cinematics public event System.Action OnCinematicStarted; public event System.Action OnCinematicStopped; private static CinematicsManager _instance; - private static bool _isQuitting; private Image _cinematicSprites; public GameObject cinematicSpritesGameObject; private bool _isCinematicPlaying = false; @@ -70,7 +69,6 @@ namespace Cinematics private void OnApplicationQuit() { - _isQuitting = true; ReleaseAllHandles(); } diff --git a/Assets/Scripts/Core/GameManager.cs b/Assets/Scripts/Core/GameManager.cs index f7e26347..21a2ef83 100644 --- a/Assets/Scripts/Core/GameManager.cs +++ b/Assets/Scripts/Core/GameManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using AppleHills.Core.Interfaces; using AppleHills.Core.Settings; using Bootstrap; +using Core.Settings; using Input; using UnityEngine; @@ -26,7 +27,9 @@ namespace Core // List of pausable components that have registered with the GameManager private List _pausableComponents = new List(); - + private LogVerbosity _settingsLogVerbosity = LogVerbosity.Warning; + private LogVerbosity _managerLogVerbosity = LogVerbosity.Warning; + // Events for pause state changes public event Action OnGamePaused; public event Action OnGameResumed; @@ -48,7 +51,13 @@ namespace Core // DontDestroyOnLoad(gameObject); } - + + private void Start() + { + _settingsLogVerbosity = DeveloperSettingsProvider.Instance.GetSettings().settingsLogVerbosity; + _managerLogVerbosity = DeveloperSettingsProvider.Instance.GetSettings().gameManagerLogVerbosity; + } + private void InitializePostBoot() { // For post-boot correct initialization order @@ -70,7 +79,7 @@ namespace Core component.Pause(); } - Logging.Debug($"[GameManager] Registered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}"); + LogDebugMessage($"Registered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}"); } } @@ -83,7 +92,7 @@ namespace Core if (component != null && _pausableComponents.Contains(component)) { _pausableComponents.Remove(component); - Logging.Debug($"[GameManager] Unregistered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}"); + LogDebugMessage($"Unregistered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}"); } } @@ -99,7 +108,7 @@ namespace Core ApplyPause(true); } - Logging.Debug($"[GameManager] Pause requested by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}"); + LogDebugMessage($"Pause requested by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}"); } /// @@ -114,7 +123,7 @@ namespace Core ApplyPause(false); } - Logging.Debug($"[GameManager] Pause released by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}"); + LogDebugMessage($"Pause released by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}"); } /// @@ -153,12 +162,12 @@ namespace Core OnGameResumed?.Invoke(); } - Logging.Debug($"[GameManager] Game {(shouldPause ? "paused" : "resumed")}. Paused {_pausableComponents.Count} components."); + LogDebugMessage($"Game {(shouldPause ? "paused" : "resumed")}. Paused {_pausableComponents.Count} components."); } private void InitializeSettings() { - Logging.Debug("Starting settings initialization..."); + LogDebugMessage("Starting settings initialization...", "SettingsInitialization", _settingsLogVerbosity); // Load settings synchronously var playerSettings = SettingsProvider.Instance.LoadSettingsSynchronous(); @@ -169,7 +178,7 @@ namespace Core if (playerSettings != null) { ServiceLocator.Register(playerSettings); - Logging.Debug("PlayerFollowerSettings registered successfully"); + LogDebugMessage("PlayerFollowerSettings registered successfully", "SettingsInitialization", _settingsLogVerbosity); } else { @@ -179,7 +188,7 @@ namespace Core if (interactionSettings != null) { ServiceLocator.Register(interactionSettings); - Logging.Debug("InteractionSettings registered successfully"); + LogDebugMessage("InteractionSettings registered successfully", "SettingsInitialization", _settingsLogVerbosity); } else { @@ -189,7 +198,7 @@ namespace Core if (minigameSettings != null) { ServiceLocator.Register(minigameSettings); - Logging.Debug("MinigameSettings registered successfully"); + LogDebugMessage("MinigameSettings registered successfully", "SettingsInitialization", _settingsLogVerbosity); } else { @@ -200,7 +209,7 @@ namespace Core _settingsLoaded = playerSettings != null && interactionSettings != null && minigameSettings != null; if (_settingsLoaded) { - Logging.Debug("All settings loaded and registered with ServiceLocator"); + LogDebugMessage("All settings loaded and registered with ServiceLocator", "SettingsInitialization", _settingsLogVerbosity); } else { @@ -213,7 +222,7 @@ namespace Core /// private void InitializeDeveloperSettings() { - Logging.Debug("Starting developer settings initialization..."); + LogDebugMessage("Starting developer settings initialization...", "SettingsInitialization", _settingsLogVerbosity); // Load developer settings var divingDevSettings = DeveloperSettingsProvider.Instance.GetSettings(); @@ -223,7 +232,7 @@ namespace Core if (_developerSettingsLoaded) { - Logging.Debug("All developer settings loaded successfully"); + LogDebugMessage("All developer settings loaded successfully", "SettingsInitialization", _settingsLogVerbosity); } else { @@ -258,6 +267,19 @@ namespace Core return DeveloperSettingsProvider.Instance?.GetSettings(); } + private void LogDebugMessage(string message, string prefix = "GameManager", LogVerbosity verbosity = LogVerbosity.None) + { + if (verbosity == LogVerbosity.None) + { + verbosity = _managerLogVerbosity; + } + + if ( verbosity <= LogVerbosity.Debug) + { + Logging.Debug($"[{prefix}] {message}"); + } + } + // LEFTOVER LEGACY SETTINGS public float PlayerStopDistance => GetSettings()?.PlayerStopDistance ?? 6.0f; public float PlayerStopDistanceDirectInteraction => GetSettings()?.PlayerStopDistanceDirectInteraction ?? 2.0f; diff --git a/Assets/Scripts/Core/ItemManager.cs b/Assets/Scripts/Core/ItemManager.cs index fab7930b..f6d794b0 100644 --- a/Assets/Scripts/Core/ItemManager.cs +++ b/Assets/Scripts/Core/ItemManager.cs @@ -13,7 +13,6 @@ namespace Core public class ItemManager : MonoBehaviour { private static ItemManager _instance; - private static bool _isQuitting; /// /// Singleton instance of the ItemManager. No longer creates an instance if one doesn't exist. @@ -73,11 +72,6 @@ namespace Core ClearAllRegistrations(); } - void OnApplicationQuit() - { - _isQuitting = true; - } - private void OnSceneLoadStarted(string sceneName) { // Clear all registrations when a new scene is loaded, so no stale references persist diff --git a/Assets/Scripts/Core/QuickAccess.cs b/Assets/Scripts/Core/QuickAccess.cs index 944e6217..85657aba 100644 --- a/Assets/Scripts/Core/QuickAccess.cs +++ b/Assets/Scripts/Core/QuickAccess.cs @@ -16,17 +16,12 @@ namespace AppleHills.Core { #region Singleton Setup private static QuickAccess _instance; - private static bool _isQuitting = false; /// /// Singleton instance of QuickAccess. No longer creates an instance if one doesn't exist. /// public static QuickAccess Instance => _instance; - void OnApplicationQuit() - { - _isQuitting = true; - } #endregion Singleton Setup #region Manager Instances diff --git a/Assets/Scripts/Core/SceneManagerService.cs b/Assets/Scripts/Core/SceneManagerService.cs index f45031f1..592d529d 100644 --- a/Assets/Scripts/Core/SceneManagerService.cs +++ b/Assets/Scripts/Core/SceneManagerService.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using AppleHills.Core.Settings; using UI; using UnityEngine; using UnityEngine.SceneManagement; @@ -15,7 +16,6 @@ namespace Core { private LoadingScreenController _loadingScreen; private static SceneManagerService _instance; - private static bool _isQuitting = false; /// /// Singleton instance of the SceneManagerService. No longer creates an instance if one doesn't exist. @@ -32,6 +32,7 @@ namespace Core private readonly Dictionary _activeLoads = new(); private readonly Dictionary _activeUnloads = new(); + private LogVerbosity _logVerbosity = LogVerbosity.Debug; private const string BootstrapSceneName = "BootstrapScene"; void Awake() @@ -52,7 +53,12 @@ namespace Core SceneManager.LoadScene(BootstrapSceneName, LoadSceneMode.Additive); } } - + + private void Start() + { + _logVerbosity = DeveloperSettingsProvider.Instance.GetSettings().sceneLogVerbosity; + } + /// /// Initialize current scene tracking immediately in Awake /// This ensures scene management works correctly regardless of boot timing @@ -68,19 +74,19 @@ namespace Core if (activeScene.name != BootstrapSceneName) { CurrentGameplayScene = activeScene.name; - Logging.Debug($"[SceneManagerService] Initialized with current scene: {CurrentGameplayScene}"); + LogDebugMessage($"Initialized with current scene: {CurrentGameplayScene}"); } // Otherwise default to MainMenu else { CurrentGameplayScene = "AppleHillsOverworld"; - Logging.Debug($"[SceneManagerService] Initialized with default scene: {CurrentGameplayScene}"); + LogDebugMessage($"Initialized with default scene: {CurrentGameplayScene}"); } } else { CurrentGameplayScene = "AppleHillsOverworld"; - Logging.Debug($"[SceneManagerService] No valid active scene, defaulting to: {CurrentGameplayScene}"); + LogDebugMessage($"No valid active scene, defaulting to: {CurrentGameplayScene}"); } } @@ -92,7 +98,7 @@ namespace Core // Set up loading screen event handlers if available SetupLoadingScreenEvents(); - Logging.Debug($"[SceneManagerService] Post-boot initialization complete, current scene is: {CurrentGameplayScene}"); + LogDebugMessage($"Post-boot initialization complete, current scene is: {CurrentGameplayScene}"); } private void SetupLoadingScreenEvents() @@ -103,11 +109,6 @@ namespace Core SceneLoadCompleted += _ => _loadingScreen.HideLoadingScreen(); } - void OnApplicationQuit() - { - _isQuitting = true; - } - /// /// Load a single scene asynchronously (additive). /// @@ -138,7 +139,7 @@ namespace Core var scene = SceneManager.GetSceneByName(sceneName); if (!scene.isLoaded) { - Logging.Warning($"SceneManagerService: Attempted to unload scene '{sceneName}', but it is not loaded."); + Logging.Warning($"[SceneManagerService] Attempted to unload scene '{sceneName}', but it is not loaded."); return; } SceneUnloadStarted?.Invoke(sceneName); @@ -317,7 +318,7 @@ namespace Core } else { - Logging.Warning($"SceneManagerService: Previous scene '{CurrentGameplayScene}' is not loaded, skipping unload."); + Logging.Warning($"[SceneManagerService] Previous scene '{CurrentGameplayScene}' is not loaded, skipping unload."); } } // Ensure BootstrapScene is loaded before loading new scene @@ -337,5 +338,13 @@ namespace Core _loadingScreen.HideLoadingScreen(); } } + + private void LogDebugMessage(string message) + { + if (_logVerbosity <= LogVerbosity.Debug) + { + Logging.Debug($"[SceneManagerService] {message}"); + } + } } } diff --git a/Assets/Scripts/Core/SceneOrientationEnforcer.cs b/Assets/Scripts/Core/SceneOrientationEnforcer.cs index 3964613a..822f0262 100644 --- a/Assets/Scripts/Core/SceneOrientationEnforcer.cs +++ b/Assets/Scripts/Core/SceneOrientationEnforcer.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using AppleHills.Core.Settings; using Bootstrap; using Input; using Settings; @@ -17,6 +18,7 @@ namespace Core [Header("Config")] public SceneOrientationConfig orientationConfig; public GameObject orientationPromptPrefab; + private LogVerbosity _logVerbosity = LogVerbosity.Warning; void Awake() { @@ -33,11 +35,16 @@ namespace Core } #endif } - + + private void Start() + { + _logVerbosity = DeveloperSettingsProvider.Instance.GetSettings().sceneLogVerbosity; + } + private void InitializePostBoot() { // Initialize any dependencies that require other services to be ready - Logging.Debug("[SceneOrientationEnforcer] Post-boot initialization complete"); + LogDebugMessage("Post-boot initialization complete"); // Subscribe to sceneLoaded event SceneManager.sceneLoaded += OnSceneLoaded; @@ -52,7 +59,7 @@ namespace Core if (sceneName.ToLower().Contains("bootstrap")) { // Bootstrap being loaded additively, don't do anything - Logging.Debug($"[SceneOrientationEnforcer] Detected bootstrapped scene: '{sceneName}'. Skipping orientation enforcement."); + LogDebugMessage($"Detected bootstrapped scene: '{sceneName}'. Skipping orientation enforcement."); return; } @@ -62,23 +69,23 @@ namespace Core } else { - Logging.Debug($"[SceneOrientationEnforcer] No orientationConfig assigned. Defaulting to Landscape for scene '{sceneName}'"); + LogDebugMessage($"No orientationConfig assigned. Defaulting to Landscape for scene '{sceneName}'"); } switch (requirement) { case ScreenOrientationRequirement.Portrait: - Logging.Debug($"[SceneOrientationEnforcer] Forcing Portrait for scene '{sceneName}'"); + LogDebugMessage($"Forcing Portrait for scene '{sceneName}'"); StartCoroutine(ForcePortrait()); break; case ScreenOrientationRequirement.Landscape: - Logging.Debug($"[SceneOrientationEnforcer] Forcing Landscape for scene '{sceneName}'"); + LogDebugMessage($"Forcing Landscape for scene '{sceneName}'"); StartCoroutine(ForceLandscape()); break; case ScreenOrientationRequirement.NotApplicable: default: // Default to landscape when no specific requirement is found - Logging.Debug($"[SceneOrientationEnforcer] No specific orientation for scene '{sceneName}'. Defaulting to Landscape"); + LogDebugMessage($"No specific orientation for scene '{sceneName}'. Defaulting to Landscape"); StartCoroutine(ForceLandscape()); break; } @@ -92,7 +99,7 @@ namespace Core /// /// Forces the game into landscape mode, allowing both LandscapeLeft and LandscapeRight. /// - public static IEnumerator ForceLandscape() + public IEnumerator ForceLandscape() { // If we're already in a landscape orientation, nothing to do. bool currentlyLandscape = Screen.orientation == ScreenOrientation.LandscapeLeft @@ -100,12 +107,12 @@ namespace Core if (!currentlyLandscape) { // Lock it to portrait and allow the device to orient itself - Logging.Debug($"[SceneOrientationEnforcer] Actually forcing Portrait from previous: {Screen.orientation}"); + LogDebugMessage($"Actually forcing Portrait from previous: {Screen.orientation}"); Screen.orientation = ScreenOrientation.LandscapeRight; } else { - Logging.Debug($"[SceneOrientationEnforcer] Skipping Landscape enforcement, device already in: {Screen.orientation}"); + LogDebugMessage($"Skipping Landscape enforcement, device already in: {Screen.orientation}"); } yield return null; @@ -125,7 +132,7 @@ namespace Core /// /// Forces the game into portrait mode, allowing both Portrait and PortraitUpsideDown. /// - public static IEnumerator ForcePortrait() + public IEnumerator ForcePortrait() { // If we're already in a portrait orientation, nothing to do. bool currentlyPortrait = Screen.orientation == ScreenOrientation.Portrait @@ -133,12 +140,12 @@ namespace Core if (!currentlyPortrait) { // Lock it to portrait and allow the device to orient itself - Logging.Debug($"[SceneOrientationEnforcer] Actually forcing Portrait from previous: {Screen.orientation}"); + LogDebugMessage($"Actually forcing Portrait from previous: {Screen.orientation}"); Screen.orientation = ScreenOrientation.PortraitUpsideDown; } else { - Logging.Debug($"[SceneOrientationEnforcer] Skipping Portrait enforcement, device already in: {Screen.orientation}"); + LogDebugMessage($"Skipping Portrait enforcement, device already in: {Screen.orientation}"); } yield return null; @@ -154,5 +161,13 @@ namespace Core // Allow device to auto-rotate to correct portrait orientation Screen.orientation = ScreenOrientation.AutoRotation; } + + private void LogDebugMessage(string message) + { + if (_logVerbosity <= LogVerbosity.Debug) + { + Logging.Debug($"[SceneOrientationEnforcer] {message}"); + } + } } } diff --git a/Assets/Scripts/Core/Settings/Developer/DebugSettings.cs b/Assets/Scripts/Core/Settings/Developer/DebugSettings.cs index 9f270d36..94d55203 100644 --- a/Assets/Scripts/Core/Settings/Developer/DebugSettings.cs +++ b/Assets/Scripts/Core/Settings/Developer/DebugSettings.cs @@ -7,11 +7,10 @@ namespace AppleHills.Core.Settings /// public enum LogVerbosity { - None = 0, - Errors = 1, - Warnings = 2, - Info = 3, - Verbose = 4 + None = -1, + Debug = 0, + Warning = 1, + Error = 2 } /// @@ -23,12 +22,26 @@ namespace AppleHills.Core.Settings { [Header("Visual Debugging Options")] [Tooltip("Should debug messages be show on screen in Editor")] - [SerializeField] private bool showDebugUiMessages = false; + [SerializeField] public bool showDebugUiMessages = false; [Header("Game Behavior Options")] [Tooltip("Should Time.timeScale be set to 0 when the game is paused")] - [SerializeField] private bool pauseTimeOnPauseGame = true; - + [SerializeField] public bool pauseTimeOnPauseGame = true; + + [Header("Logging Options")] + [Tooltip("Logging level for bootstrap services")] + [SerializeField] public LogVerbosity bootstrapLogVerbosity = LogVerbosity.Warning; + [Tooltip("Logging level for settings-related services")] + [SerializeField] public LogVerbosity settingsLogVerbosity = LogVerbosity.Warning; + [Tooltip("Logging level for Game Manager")] + [SerializeField] public LogVerbosity gameManagerLogVerbosity = LogVerbosity.Warning; + [Tooltip("Logging level for Scene management services - orientation, loading etc.")] + [SerializeField] public LogVerbosity sceneLogVerbosity = LogVerbosity.Warning; + [Tooltip("Logging level for Scene Orientation Enforcer")] + [SerializeField] public LogVerbosity saveLoadLogVerbosity = LogVerbosity.Warning; + [Tooltip("Logging level for Input management services")] + [SerializeField] public LogVerbosity inputLogVerbosity = LogVerbosity.Warning; + // Property getters public bool ShowDebugUiMessages => showDebugUiMessages; public bool PauseTimeOnPauseGame => pauseTimeOnPauseGame; diff --git a/Assets/Scripts/Core/Settings/DivingMinigameSettings.cs b/Assets/Scripts/Core/Settings/DivingMinigameSettings.cs index 58bd63ee..d377b511 100644 --- a/Assets/Scripts/Core/Settings/DivingMinigameSettings.cs +++ b/Assets/Scripts/Core/Settings/DivingMinigameSettings.cs @@ -87,10 +87,6 @@ namespace AppleHills.Core.Settings [Tooltip("Maximum normalized movement speed allowed for tiles")] [SerializeField] private float maxNormalizedTileMoveSpeed = 1.2f; - // Legacy settings - keeping for backward compatibility - [HideInInspector] [SerializeField] private float moveSpeed = 3f; - [HideInInspector] [SerializeField] private float maxMoveSpeed = 12f; - [Tooltip("Interval for velocity calculations (seconds)")] [SerializeField] private float velocityCalculationInterval = 0.5f; diff --git a/Assets/Scripts/Core/Settings/ServiceLocator.cs b/Assets/Scripts/Core/Settings/ServiceLocator.cs index 222dd2f0..9efcfbf9 100644 --- a/Assets/Scripts/Core/Settings/ServiceLocator.cs +++ b/Assets/Scripts/Core/Settings/ServiceLocator.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; -using Core; +using AppleHills.Core.Settings; using UnityEngine; -namespace AppleHills.Core.Settings +namespace Core.Settings { /// /// Service Locator implementation for managing settings services. @@ -11,7 +11,7 @@ namespace AppleHills.Core.Settings /// public static class ServiceLocator { - private static readonly Dictionary _services = new Dictionary(); + private static readonly Dictionary Services = new Dictionary(); /// /// Register a service with the service locator. @@ -20,8 +20,8 @@ namespace AppleHills.Core.Settings /// The service implementation public static void Register(T service) where T : class { - _services[typeof(T)] = service; - Logging.Debug($"Service registered: {typeof(T).Name}"); + Services[typeof(T)] = service; + LogDebugMessage($"Service registered: {typeof(T).Name}"); } /// @@ -31,12 +31,12 @@ namespace AppleHills.Core.Settings /// The service implementation, or null if not found public static T Get() where T : class { - if (_services.TryGetValue(typeof(T), out object service)) + if (Services.TryGetValue(typeof(T), out object service)) { return service as T; } - Logging.Warning($"Service of type {typeof(T).Name} not found!"); + Logging.Warning($"[ServiceLocator] Service of type {typeof(T).Name} not found!"); return null; } @@ -45,8 +45,17 @@ namespace AppleHills.Core.Settings /// public static void Clear() { - _services.Clear(); - Logging.Debug("All services cleared"); + Services.Clear(); + LogDebugMessage("All services cleared"); + } + + private static void LogDebugMessage(string message) + { + if (DeveloperSettingsProvider.Instance.GetSettings().settingsLogVerbosity <= + LogVerbosity.Debug) + { + Logging.Debug($"[ServiceLocator] {message}"); + } } } } diff --git a/Assets/Scripts/Core/SettingsAccess.cs b/Assets/Scripts/Core/SettingsAccess.cs index f5d12c18..f2c9d4d2 100644 --- a/Assets/Scripts/Core/SettingsAccess.cs +++ b/Assets/Scripts/Core/SettingsAccess.cs @@ -35,6 +35,11 @@ namespace AppleHills public static float GetPlayerStopDistance() { #if UNITY_EDITOR + if (getPlayerStopDistanceProvider == null) + { + return 0.0f; + } + if (!Application.isPlaying && getPlayerStopDistanceProvider != null) { return getPlayerStopDistanceProvider(); diff --git a/Assets/Scripts/Data/CardSystem/CardSystemManager.cs b/Assets/Scripts/Data/CardSystem/CardSystemManager.cs index faa891a6..1f5394d8 100644 --- a/Assets/Scripts/Data/CardSystem/CardSystemManager.cs +++ b/Assets/Scripts/Data/CardSystem/CardSystemManager.cs @@ -19,7 +19,6 @@ namespace Data.CardSystem public class CardSystemManager : MonoBehaviour { private static CardSystemManager _instance; - private static bool _isQuitting = false; public static CardSystemManager Instance => _instance; [Header("Card Collection")] @@ -56,11 +55,6 @@ namespace Data.CardSystem Logging.Debug("[CardSystemManager] Post-boot initialization complete"); } - private void OnApplicationQuit() - { - _isQuitting = true; - } - /// /// Loads all card definitions from Addressables using the "BlokkemonCard" label /// diff --git a/Assets/Scripts/Dialogue/DialogueComponent.cs b/Assets/Scripts/Dialogue/DialogueComponent.cs index 7ef34822..937d958f 100644 --- a/Assets/Scripts/Dialogue/DialogueComponent.cs +++ b/Assets/Scripts/Dialogue/DialogueComponent.cs @@ -33,8 +33,6 @@ namespace Dialogue public bool IsCompleted { get; private set; } public string CurrentSpeakerName => dialogueGraph?.speakerName; - // Event for UI updates if needed - public event Action OnDialogueChanged; private void Start() { diff --git a/Assets/Scripts/Input/InputManager.cs b/Assets/Scripts/Input/InputManager.cs index 1cd117d3..a0306a5c 100644 --- a/Assets/Scripts/Input/InputManager.cs +++ b/Assets/Scripts/Input/InputManager.cs @@ -28,7 +28,6 @@ namespace Input private const string GameActions = "PlayerTouch"; private static InputManager _instance; - private static bool _isQuitting = false; // Override consumer stack - using a list to support multiple overrides that can be removed in LIFO order private readonly List _overrideConsumers = new List(); @@ -50,6 +49,7 @@ namespace Input private InputAction positionAction; private ITouchInputConsumer defaultConsumer; private bool isHoldActive; + private LogVerbosity _logVerbosity = LogVerbosity.Warning; void Awake() { @@ -58,7 +58,12 @@ namespace Input // Register for post-boot initialization BootCompletionService.RegisterInitAction(InitializePostBoot); } - + + private void Start() + { + _logVerbosity = DeveloperSettingsProvider.Instance.GetSettings().inputLogVerbosity; + } + private void InitializePostBoot() { // Subscribe to scene load completed events now that boot is complete @@ -86,8 +91,6 @@ namespace Input } SwitchInputOnSceneLoaded(SceneManager.GetActiveScene().name); - - Logging.Debug("[InputManager] Subscribed to SceneManagerService events"); } private void OnDestroy() @@ -101,12 +104,10 @@ namespace Input { if (sceneName.ToLower().Contains("mainmenu")) { - Logging.Debug("[InputManager] SwitchInputOnSceneLoaded - Setting InputMode to UI for MainMenu"); SetInputMode(InputMode.GameAndUI); } else { - Logging.Debug("[InputManager] SwitchInputOnSceneLoaded - Setting InputMode to PlayerTouch"); SetInputMode(InputMode.GameAndUI); } } @@ -144,11 +145,6 @@ namespace Input holdMoveAction.canceled -= OnHoldMoveCanceled; } } - - void OnApplicationQuit() - { - _isQuitting = true; - } /// /// Sets the default ITouchInputConsumer to receive input events. @@ -166,24 +162,24 @@ namespace Input Vector2 screenPos = positionAction.ReadValue(); Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos); Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y); - Logging.Debug($"[InputManager] TapMove performed at {worldPos2D}"); + LogDebugMessage($"TapMove performed at {worldPos2D}"); // First try to delegate to an override consumer if available if (TryDelegateToOverrideConsumer(screenPos, worldPos2D)) { - Logging.Debug("[InputManager] Tap delegated to override consumer"); + LogDebugMessage("Tap delegated to override consumer"); return; } // Then try to delegate to any ITouchInputConsumer (UI or world interactable) if (!TryDelegateToAnyInputConsumer(screenPos, worldPos2D)) { - Logging.Debug("[InputManager] No input consumer found, forwarding tap to default consumer"); + LogDebugMessage("No input consumer found, forwarding tap to default consumer"); defaultConsumer?.OnTap(worldPos2D); } else { - Logging.Debug("[InputManager] Tap delegated to input consumer"); + LogDebugMessage("Tap delegated to input consumer"); } } @@ -196,13 +192,13 @@ namespace Input Vector2 screenPos = positionAction.ReadValue(); Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos); Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y); - Logging.Debug($"[InputManager] HoldMove started at {worldPos2D}"); + LogDebugMessage($"HoldMove started at {worldPos2D}"); // First check for override consumers if (_overrideConsumers.Count > 0) { _activeHoldConsumer = _overrideConsumers[_overrideConsumers.Count - 1]; - Logging.Debug($"[InputManager] Hold delegated to override consumer: {_activeHoldConsumer}"); + LogDebugMessage($"Hold delegated to override consumer: {_activeHoldConsumer}"); _activeHoldConsumer.OnHoldStart(worldPos2D); return; } @@ -222,7 +218,7 @@ namespace Input Vector2 screenPos = positionAction.ReadValue(); Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos); Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y); - Logging.Debug($"[InputManager] HoldMove canceled at {worldPos2D}"); + LogDebugMessage($"HoldMove canceled at {worldPos2D}"); // Notify the active hold consumer that the hold has ended _activeHoldConsumer?.OnHoldEnd(worldPos2D); @@ -239,7 +235,7 @@ namespace Input Vector2 screenPos = positionAction.ReadValue(); Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos); Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y); - // Logging.Debug($"[InputManager] HoldMove update at {worldPos2D}"); + // LogDebugMessage($"HoldMove update at {worldPos2D}"); // Send hold move updates to the active hold consumer _activeHoldConsumer?.OnHoldMove(worldPos2D); @@ -286,7 +282,7 @@ namespace Input } if (consumer != null) { - Logging.Debug($"[InputManager] Delegating tap to UI consumer at {screenPos} (GameObject: {result.gameObject.name})"); + LogDebugMessage($"Delegating tap to UI consumer at {screenPos} (GameObject: {result.gameObject.name})"); consumer.OnTap(screenPos); return true; } @@ -315,7 +311,7 @@ namespace Input } if (consumer != null) { - Logging.Debug($"[InputManager] Delegating tap to consumer at {worldPos} (GameObject: {hitWithMask.gameObject.name})"); + LogDebugMessage($"Delegating tap to consumer at {worldPos} (GameObject: {hitWithMask.gameObject.name})"); consumer.OnTap(worldPos); return true; } @@ -329,15 +325,15 @@ namespace Input var consumer = hit.GetComponent(); if (consumer != null) { - Logging.Debug($"[InputManager] Delegating tap to consumer at {worldPos} (GameObject: {hit.gameObject.name})"); + LogDebugMessage($"Delegating tap to consumer at {worldPos} (GameObject: {hit.gameObject.name})"); consumer.OnTap(worldPos); return true; } - Logging.Debug($"[InputManager] Collider2D hit at {worldPos} (GameObject: {hit.gameObject.name}), but no ITouchInputConsumer found."); + LogDebugMessage($"Collider2D hit at {worldPos} (GameObject: {hit.gameObject.name}), but no ITouchInputConsumer found."); } else { - Logging.Debug($"[InputManager] No Collider2D found at {worldPos} for interactable delegation."); + LogDebugMessage($"No Collider2D found at {worldPos} for interactable delegation."); } return false; } @@ -352,7 +348,7 @@ namespace Input return; _overrideConsumers.Add(consumer); - Logging.Debug($"[InputManager] Override consumer registered: {consumer}"); + LogDebugMessage($"Override consumer registered: {consumer}"); } /// @@ -370,7 +366,7 @@ namespace Input } _overrideConsumers.Remove(consumer); - Logging.Debug($"[InputManager] Override consumer unregistered: {consumer}"); + LogDebugMessage($"Override consumer unregistered: {consumer}"); } /// @@ -380,7 +376,7 @@ namespace Input { _activeHoldConsumer = null; _overrideConsumers.Clear(); - Logging.Debug("[InputManager] All override consumers cleared."); + LogDebugMessage("All override consumers cleared."); } /// @@ -393,9 +389,17 @@ namespace Input // Get the topmost override consumer (last registered) var consumer = _overrideConsumers[_overrideConsumers.Count - 1]; - Logging.Debug($"[InputManager] Delegating tap to override consumer at {worldPos} (GameObject: {consumer})"); + LogDebugMessage($"Delegating tap to override consumer at {worldPos} (GameObject: {consumer})"); consumer.OnTap(worldPos); return true; } + + private void LogDebugMessage(string message) + { + if (_logVerbosity <= LogVerbosity.Debug) + { + Logging.Debug($"[InputManager] {message}"); + } + } } } diff --git a/Assets/Scripts/Input/PlayerTouchController.cs b/Assets/Scripts/Input/PlayerTouchController.cs index 5b3af21b..805907ec 100644 --- a/Assets/Scripts/Input/PlayerTouchController.cs +++ b/Assets/Scripts/Input/PlayerTouchController.cs @@ -53,6 +53,7 @@ namespace Input public event ArrivedAtTargetHandler OnArrivedAtTarget; public event System.Action OnMoveToCancelled; private bool interruptMoveTo; + private LogVerbosity _logVerbosity = LogVerbosity.Warning; void Awake() { @@ -75,6 +76,7 @@ namespace Input void Start() { InputManager.Instance?.SetDefaultConsumer(this); + _logVerbosity = DeveloperSettingsProvider.Instance.GetSettings().inputLogVerbosity; } /// @@ -84,7 +86,7 @@ namespace Input public void OnTap(Vector2 worldPosition) { InterruptMoveTo(); - Logging.Debug($"[PlayerTouchController] OnTap at {worldPosition}"); + LogDebugMessage($"OnTap at {worldPosition}"); if (aiPath != null) { aiPath.enabled = true; @@ -103,7 +105,7 @@ namespace Input public void OnHoldStart(Vector2 worldPosition) { InterruptMoveTo(); - Logging.Debug($"[PlayerTouchController] OnHoldStart at {worldPosition}"); + LogDebugMessage($"OnHoldStart at {worldPosition}"); lastHoldPosition = worldPosition; isHolding = true; if (_settings.DefaultHoldMovementMode == HoldMovementMode.Pathfinding && @@ -140,7 +142,7 @@ namespace Input /// public void OnHoldEnd(Vector2 worldPosition) { - Logging.Debug($"[PlayerTouchController] OnHoldEnd at {worldPosition}"); + LogDebugMessage($"OnHoldEnd at {worldPosition}"); isHolding = false; directMoveVelocity = Vector3.zero; if (aiPath != null && _settings.DefaultHoldMovementMode == @@ -316,13 +318,13 @@ namespace Input { _isMoving = true; OnMovementStarted?.Invoke(); - Logging.Debug("[PlayerTouchController] Movement started"); + LogDebugMessage("Movement started"); } else if (!isCurrentlyMoving && _isMoving) { _isMoving = false; OnMovementStopped?.Invoke(); - Logging.Debug("[PlayerTouchController] Movement stopped"); + LogDebugMessage("Movement stopped"); } } @@ -405,5 +407,13 @@ namespace Input OnArrivedAtTarget?.Invoke(); } } + + private void LogDebugMessage(string message) + { + if (_logVerbosity <= LogVerbosity.Debug) + { + Logging.Debug($"[PlayerTouchController] {message}"); + } + } } } diff --git a/Assets/Scripts/Interactions/Interactable.cs b/Assets/Scripts/Interactions/Interactable.cs index e21cec6a..165544d9 100644 --- a/Assets/Scripts/Interactions/Interactable.cs +++ b/Assets/Scripts/Interactions/Interactable.cs @@ -378,14 +378,12 @@ namespace Interactions Logging.Debug("[Interactable] All InteractingCharacterArrived actions completed, proceeding with interaction"); // Check if we have any components that might have paused the interaction flow - bool hasTimelineActions = false; foreach (var action in _registeredActions) { if (action is InteractionTimelineAction timelineAction && timelineAction.respondToEvents.Contains(InteractionEventType.InteractingCharacterArrived) && timelineAction.pauseInteractionFlow) { - hasTimelineActions = true; break; } } @@ -414,7 +412,7 @@ namespace Interactions _ = OnPlayerMoveCancelledAsync(); } - private async Task BroadcastCharacterArrivedAsync() + private Task BroadcastCharacterArrivedAsync() { // Check for ObjectiveStepBehaviour and lock state var step = GetComponent(); @@ -427,7 +425,7 @@ namespace Interactions _interactionInProgress = false; _playerRef = null; _followerController = null; - return; + return Task.CompletedTask; } // Dispatch CharacterArrived event @@ -440,6 +438,7 @@ namespace Interactions _interactionInProgress = false; _playerRef = null; _followerController = null; + return Task.CompletedTask; } private async void OnInteractionComplete(bool success) diff --git a/Assets/Scripts/LevelS/LevelSwitchData.cs b/Assets/Scripts/LevelS/LevelSwitchData.cs deleted file mode 100644 index f709e5e3..00000000 --- a/Assets/Scripts/LevelS/LevelSwitchData.cs +++ /dev/null @@ -1,24 +0,0 @@ -using UnityEngine; - -/// -/// ScriptableObject holding data for a level switch (scene name, description, icon). -/// -[CreateAssetMenu(fileName = "LevelSwitchData", menuName = "AppleHills/Items & Puzzles/Level Switch Data")] -public class LevelSwitchData : ScriptableObject -{ - /// - /// The name of the target scene to switch to. - /// - public string targetLevelSceneName; - - /// - /// Description of the level switch. - /// - [TextArea] - public string description; - - /// - /// Icon to display for this level switch. - /// - public Sprite mapSprite; -} diff --git a/Assets/Scripts/LevelS/LevelSwitchMenu.cs b/Assets/Scripts/LevelS/LevelSwitchMenu.cs deleted file mode 100644 index 03995b90..00000000 --- a/Assets/Scripts/LevelS/LevelSwitchMenu.cs +++ /dev/null @@ -1,53 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; -using TMPro; -using System; - -/// -/// UI overlay for confirming a level switch. Displays level info and handles confirm/cancel actions. -/// -public class LevelSwitchMenu : MonoBehaviour -{ - [Header("UI References")] - public Image iconImage; - public TMP_Text levelNameText; - public Button confirmButton; - public Button cancelButton; - - private Action _onConfirm; - private Action _onCancel; - private LevelSwitchData _switchData; - - /// - /// Initialize the menu with data and callbacks. - /// - public void Setup(LevelSwitchData switchData, Action onConfirm, Action onCancel) - { - _switchData = switchData; - _onConfirm = onConfirm; - _onCancel = onCancel; - if (iconImage) iconImage.sprite = switchData?.mapSprite; - if (levelNameText) levelNameText.text = switchData?.targetLevelSceneName ?? ""; - if (confirmButton) confirmButton.onClick.AddListener(OnConfirmClicked); - if (cancelButton) cancelButton.onClick.AddListener(OnCancelClicked); - } - - private void OnDestroy() - { - if (confirmButton) confirmButton.onClick.RemoveListener(OnConfirmClicked); - if (cancelButton) cancelButton.onClick.RemoveListener(OnCancelClicked); - } - - private void OnConfirmClicked() - { - _onConfirm?.Invoke(); - Destroy(gameObject); - } - - private void OnCancelClicked() - { - _onCancel?.Invoke(); - Destroy(gameObject); - } -} - diff --git a/Assets/Scripts/LevelS.meta b/Assets/Scripts/Levels.meta similarity index 100% rename from Assets/Scripts/LevelS.meta rename to Assets/Scripts/Levels.meta diff --git a/Assets/Scripts/LevelS/LevelSwitch.cs b/Assets/Scripts/Levels/LevelSwitch.cs similarity index 84% rename from Assets/Scripts/LevelS/LevelSwitch.cs rename to Assets/Scripts/Levels/LevelSwitch.cs index a3f257dd..6116bebf 100644 --- a/Assets/Scripts/LevelS/LevelSwitch.cs +++ b/Assets/Scripts/Levels/LevelSwitch.cs @@ -3,11 +3,12 @@ using AppleHills.Core.Settings; using Core; using Input; using Interactions; +using System.Threading.Tasks; using UnityEngine; // Added for IInteractionSettings -namespace LevelS +namespace Levels { /// /// Handles level switching when interacted with. Applies switch data and triggers scene transitions. @@ -107,18 +108,35 @@ namespace LevelS return; } // Setup menu with data and callbacks - menu.Setup(switchData, OnMenuConfirm, OnMenuCancel); + menu.Setup(switchData, OnLevelSelectedWrapper, OnMinigameSelected, OnMenuCancel, OnRestartSelected); _isActive = false; // Prevent re-triggering until menu is closed // Switch input mode to UI only InputManager.Instance.SetInputMode(InputMode.UI); } - private async void OnMenuConfirm() + private void OnLevelSelectedWrapper() + { + _ = OnLevelSelected(); + } + + private async Task OnLevelSelected() { var progress = new Progress(p => Logging.Debug($"Loading progress: {p * 100:F0}%")); await SceneManagerService.Instance.SwitchSceneAsync(switchData.targetLevelSceneName, progress); } + + private async void OnMinigameSelected() + { + var progress = new Progress(p => Logging.Debug($"Loading progress: {p * 100:F0}%")); + await SceneManagerService.Instance.SwitchSceneAsync(switchData.targetMinigameSceneName, progress); + } + + private async void OnRestartSelected() + { + // TODO: Restart level here + await OnLevelSelected(); + } private void OnMenuCancel() { diff --git a/Assets/Scripts/LevelS/LevelSwitch.cs.meta b/Assets/Scripts/Levels/LevelSwitch.cs.meta similarity index 100% rename from Assets/Scripts/LevelS/LevelSwitch.cs.meta rename to Assets/Scripts/Levels/LevelSwitch.cs.meta diff --git a/Assets/Scripts/Levels/LevelSwitchData.cs b/Assets/Scripts/Levels/LevelSwitchData.cs new file mode 100644 index 00000000..93aba9ae --- /dev/null +++ b/Assets/Scripts/Levels/LevelSwitchData.cs @@ -0,0 +1,32 @@ +using UnityEngine; + +namespace Levels +{ + /// + /// ScriptableObject holding data for a level switch (scene name, description, icon). + /// + [CreateAssetMenu(fileName = "LevelSwitchData", menuName = "AppleHills/Items & Puzzles/Level Switch Data")] + public class LevelSwitchData : ScriptableObject + { + /// + /// The name of the target scene to switch to. + /// + public string targetLevelSceneName; + + /// + /// The name of the minigame scene to switch to. + /// + public string targetMinigameSceneName; + + /// + /// Description of the level switch. + /// + [TextArea] + public string description; + + /// + /// Icon to display for this level switch. + /// + public Sprite mapSprite; + } +} diff --git a/Assets/Scripts/LevelS/LevelSwitchData.cs.meta b/Assets/Scripts/Levels/LevelSwitchData.cs.meta similarity index 100% rename from Assets/Scripts/LevelS/LevelSwitchData.cs.meta rename to Assets/Scripts/Levels/LevelSwitchData.cs.meta diff --git a/Assets/Scripts/Levels/LevelSwitchMenu.cs b/Assets/Scripts/Levels/LevelSwitchMenu.cs new file mode 100644 index 00000000..db90628a --- /dev/null +++ b/Assets/Scripts/Levels/LevelSwitchMenu.cs @@ -0,0 +1,110 @@ +using System; +using TMPro; +using UnityEngine; +using UnityEngine.UI; + +namespace Levels +{ + /// + /// UI overlay for confirming a level switch. Displays level info and handles confirm/cancel actions. + /// + public class LevelSwitchMenu : MonoBehaviour + { + [Header("UI References")] + public Image iconImage; + public TMP_Text levelNameText; + public Button confirmButton; + public Button cancelButton; + public Button minigameButton; + public GameObject padlockIcon; + public Button restartButton; + public GameObject popupConfirmMenu; + public Button popupConfirmButton; + public Button popupCancelButton; + public Image tintTargetImage; + public Color popupTintColor = new Color(0.5f, 0.5f, 0.5f, 1f); // grey by default + private Color _originalTintColor; + private Action _onRestart; + + private Action _onLevelConfirm; + private Action _onMinigameConfirm; + private Action _onCancel; + private LevelSwitchData _switchData; + + /// + /// Initialize the menu with data and callbacks. + /// + public void Setup(LevelSwitchData switchData, Action onLevelConfirm, Action onMinigameConfirm, Action onCancel, Action onRestart = null) + { + _switchData = switchData; + _onLevelConfirm = onLevelConfirm; + _onMinigameConfirm = onMinigameConfirm; + _onCancel = onCancel; + _onRestart = onRestart; + if (iconImage) iconImage.sprite = switchData?.mapSprite; + if (levelNameText) levelNameText.text = switchData?.targetLevelSceneName ?? ""; + if (confirmButton) confirmButton.onClick.AddListener(OnConfirmClicked); + if (cancelButton) cancelButton.onClick.AddListener(OnCancelClicked); + if (minigameButton) + { + minigameButton.onClick.AddListener(OnMinigameClicked); + + bool minigameUnlocked = true; + minigameButton.interactable = !minigameUnlocked; + padlockIcon.SetActive(!minigameUnlocked); + } + if (restartButton) restartButton.onClick.AddListener(OnRestartClicked); + if (popupConfirmMenu) popupConfirmMenu.SetActive(false); + if (tintTargetImage) _originalTintColor = tintTargetImage.color; + if (popupConfirmButton) popupConfirmButton.onClick.AddListener(OnPopupConfirmClicked); + if (popupCancelButton) popupCancelButton.onClick.AddListener(OnPopupCancelClicked); + } + + private void OnDestroy() + { + if (confirmButton) confirmButton.onClick.RemoveListener(OnConfirmClicked); + if (cancelButton) cancelButton.onClick.RemoveListener(OnCancelClicked); + if (minigameButton) minigameButton.onClick.RemoveListener(OnMinigameClicked); + if (restartButton) restartButton.onClick.RemoveListener(OnRestartClicked); + if (popupConfirmButton) popupConfirmButton.onClick.RemoveListener(OnPopupConfirmClicked); + if (popupCancelButton) popupCancelButton.onClick.RemoveListener(OnPopupCancelClicked); + } + + private void OnConfirmClicked() + { + _onLevelConfirm?.Invoke(); + Destroy(gameObject); + } + + private void OnMinigameClicked() + { + _onMinigameConfirm?.Invoke(); + Destroy(gameObject); + } + + private void OnCancelClicked() + { + _onCancel?.Invoke(); + Destroy(gameObject); + } + + private void OnRestartClicked() + { + if (popupConfirmMenu) popupConfirmMenu.SetActive(true); + if (tintTargetImage) tintTargetImage.color = popupTintColor; + } + + private void OnPopupCancelClicked() + { + if (popupConfirmMenu) popupConfirmMenu.SetActive(false); + if (tintTargetImage) tintTargetImage.color = _originalTintColor; + } + + private void OnPopupConfirmClicked() + { + _onRestart?.Invoke(); + if (popupConfirmMenu) popupConfirmMenu.SetActive(false); + if (tintTargetImage) tintTargetImage.color = _originalTintColor; + } + } +} diff --git a/Assets/Scripts/LevelS/LevelSwitchMenu.cs.meta b/Assets/Scripts/Levels/LevelSwitchMenu.cs.meta similarity index 100% rename from Assets/Scripts/LevelS/LevelSwitchMenu.cs.meta rename to Assets/Scripts/Levels/LevelSwitchMenu.cs.meta diff --git a/Assets/Scripts/Minigames/DivingForPictures/Bubbles/BubbleSpawner.cs b/Assets/Scripts/Minigames/DivingForPictures/Bubbles/BubbleSpawner.cs index 8d2b42c1..dcbc2c92 100644 --- a/Assets/Scripts/Minigames/DivingForPictures/Bubbles/BubbleSpawner.cs +++ b/Assets/Scripts/Minigames/DivingForPictures/Bubbles/BubbleSpawner.cs @@ -1,12 +1,11 @@ -using System; -using System.Collections; -using UnityEngine; -using AppleHills.Core.Settings; +using System.Collections; using AppleHills.Core.Interfaces; +using AppleHills.Core.Settings; using Core; +using UnityEngine; using Random = UnityEngine.Random; -namespace Minigames.DivingForPictures +namespace Minigames.DivingForPictures.Bubbles { /// /// Spawns bubbles at intervals, randomizing their properties and assigning a random sprite to each. @@ -45,9 +44,9 @@ namespace Minigames.DivingForPictures if (_devSettings.BubbleUseObjectPooling) { // Create the bubble pool - GameObject poolGO = new GameObject("BubblePool"); - poolGO.transform.SetParent(transform); - _bubblePool = poolGO.AddComponent(); + GameObject poolGo = new GameObject("BubblePool"); + poolGo.transform.SetParent(transform); + _bubblePool = poolGo.AddComponent(); _bubblePool.initialPoolSize = _devSettings.BubbleInitialPoolSize; _bubblePool.maxPoolSize = _devSettings.BubbleMaxPoolSize; _bubblePool.Initialize(bubblePrefab); @@ -89,7 +88,7 @@ namespace Minigames.DivingForPictures } // Pause all active bubbles - Bubble[] activeBubbles = FindObjectsOfType(); + Bubble[] activeBubbles = FindObjectsByType(FindObjectsSortMode.None); foreach (var bubble in activeBubbles) { if (bubble != null) @@ -110,7 +109,7 @@ namespace Minigames.DivingForPictures StartSpawningCoroutine(); // Resume all active bubbles - Bubble[] activeBubbles = FindObjectsOfType(); + Bubble[] activeBubbles = FindObjectsByType(FindObjectsSortMode.None); foreach (var bubble in activeBubbles) { if (bubble != null) diff --git a/Assets/Scripts/Minigames/DivingForPictures/DivingGameManager.cs b/Assets/Scripts/Minigames/DivingForPictures/DivingGameManager.cs index e013d69a..ed6422b9 100644 --- a/Assets/Scripts/Minigames/DivingForPictures/DivingGameManager.cs +++ b/Assets/Scripts/Minigames/DivingForPictures/DivingGameManager.cs @@ -8,6 +8,7 @@ using System; using System.Collections; using System.Collections.Generic; using Bootstrap; +using Minigames.DivingForPictures.Bubbles; using UI; using UI.Core; using UnityEngine; @@ -97,7 +98,6 @@ namespace Minigames.DivingForPictures public event Action OnPhotoSequenceCompleted; // Now includes proximity score private static DivingGameManager _instance = null; - private static bool _isQuitting = false; public AudioSource deathAudioPlayer; public CameraViewfinderManager cameraViewfinderManager; @@ -122,11 +122,6 @@ namespace Minigames.DivingForPictures _isGameOver = false; } - private void OnApplicationQuit() - { - _isQuitting = true; - } - private void Start() { // Register for post-boot initialization diff --git a/Assets/Scripts/Minigames/DivingForPictures/PictureCamera/CameraViewfinderManager.cs b/Assets/Scripts/Minigames/DivingForPictures/PictureCamera/CameraViewfinderManager.cs index 7bfe6fbb..1ef5be0a 100644 --- a/Assets/Scripts/Minigames/DivingForPictures/PictureCamera/CameraViewfinderManager.cs +++ b/Assets/Scripts/Minigames/DivingForPictures/PictureCamera/CameraViewfinderManager.cs @@ -15,13 +15,11 @@ namespace Minigames.DivingForPictures.PictureCamera { // Singleton instance private static CameraViewfinderManager _instance; - private static bool _isQuitting = false; - public static CameraViewfinderManager Instance { get { - if (_instance == null && Application.isPlaying && !_isQuitting) + if (_instance == null && Application.isPlaying) { _instance = FindAnyObjectByType(); if (_instance == null) @@ -89,11 +87,6 @@ namespace Minigames.DivingForPictures.PictureCamera } } - private void OnApplicationQuit() - { - _isQuitting = true; - } - private void Start() { settings = GameManager.GetSettingsObject(); diff --git a/Assets/Scripts/Minigames/DivingForPictures/Player/TileBumpCollision.cs b/Assets/Scripts/Minigames/DivingForPictures/Player/TileBumpCollision.cs index 7e3b0bc4..f3a2423b 100644 --- a/Assets/Scripts/Minigames/DivingForPictures/Player/TileBumpCollision.cs +++ b/Assets/Scripts/Minigames/DivingForPictures/Player/TileBumpCollision.cs @@ -11,7 +11,6 @@ namespace Minigames.DivingForPictures /// public class TileBumpCollision : PlayerCollisionBehavior { - private bool _isBumping; private Coroutine _bumpCoroutine; protected override void HandleCollisionResponse(Collider2D obstacle) @@ -98,8 +97,6 @@ namespace Minigames.DivingForPictures _bumpCoroutine = null; } - _isBumping = true; - // Start bump coroutine _bumpCoroutine = StartCoroutine(BumpCoroutine(startX, targetX, duration)); } @@ -142,7 +139,6 @@ namespace Minigames.DivingForPictures } // Bump finished - _isBumping = false; _bumpCoroutine = null; Logging.Debug("[TileBumpCollision] Bump movement completed"); diff --git a/Assets/Scripts/Minigames/DivingForPictures/Tiles/TrenchTileSpawner.cs b/Assets/Scripts/Minigames/DivingForPictures/Tiles/TrenchTileSpawner.cs index bc4950d4..75f20ae1 100644 --- a/Assets/Scripts/Minigames/DivingForPictures/Tiles/TrenchTileSpawner.cs +++ b/Assets/Scripts/Minigames/DivingForPictures/Tiles/TrenchTileSpawner.cs @@ -73,9 +73,6 @@ namespace Minigames.DivingForPictures // Screen normalization private float _screenNormalizationFactor = 1.0f; - // Tracks if a floating area in the middle is currently active - private bool isFloatingAreaActive = false; - // Current depth of the trench private int _currentDepth = 0; @@ -714,20 +711,6 @@ namespace Minigames.DivingForPictures _currentDepth++; Logging.Debug($"[TrenchTileSpawner] Current Depth: {_currentDepth}"); onTileSpawned?.Invoke(tile); - - // --- FLOATING AREA STATE MANAGEMENT --- - Tile spawnedTile = tile.GetComponent(); - if (spawnedTile != null) - { - if (spawnedTile.hasFloatingAreaMiddle || spawnedTile.continuesFloatingAreaMiddle) - { - isFloatingAreaActive = true; - } - if (spawnedTile.endsFloatingAreaMiddle) - { - isFloatingAreaActive = false; - } - } } /// @@ -776,19 +759,6 @@ namespace Minigames.DivingForPictures _currentDepth++; Logging.Debug($"[TrenchTileSpawner] Current Depth: {_currentDepth}"); onTileSpawned?.Invoke(tile); - // Optionally update floating area state if needed - Tile spawnedTile = tile.GetComponent(); - if (spawnedTile != null) - { - if (spawnedTile.hasFloatingAreaMiddle || spawnedTile.continuesFloatingAreaMiddle) - { - isFloatingAreaActive = true; - } - if (spawnedTile.endsFloatingAreaMiddle) - { - isFloatingAreaActive = false; - } - } } /// diff --git a/Assets/Scripts/PuzzleS/PuzzleManager.cs b/Assets/Scripts/PuzzleS/PuzzleManager.cs index 1c8f522f..ade6bf7f 100644 --- a/Assets/Scripts/PuzzleS/PuzzleManager.cs +++ b/Assets/Scripts/PuzzleS/PuzzleManager.cs @@ -19,7 +19,6 @@ namespace PuzzleS public class PuzzleManager : MonoBehaviour { private static PuzzleManager _instance; - private static bool _isQuitting; [SerializeField] private float proximityCheckInterval = 0.02f; @@ -496,10 +495,5 @@ namespace PuzzleS { return _isDataLoaded; } - - void OnApplicationQuit() - { - _isQuitting = true; - } } } diff --git a/Assets/Scripts/UI/CardSystem/BoosterOpeningPage.cs b/Assets/Scripts/UI/CardSystem/BoosterOpeningPage.cs index b340a8c4..d9bb4d4e 100644 --- a/Assets/Scripts/UI/CardSystem/BoosterOpeningPage.cs +++ b/Assets/Scripts/UI/CardSystem/BoosterOpeningPage.cs @@ -28,7 +28,6 @@ namespace UI.CardSystem [Header("Animation Settings")] [SerializeField] private float cardRevealDelay = 0.3f; - [SerializeField] private float cardMoveToBackpackDelay = 0.8f; [SerializeField] private float flipAnimationDuration = 0.5f; // State tracking @@ -616,7 +615,7 @@ namespace UI.CardSystem if (_cardAlbumUI == null) { - _cardAlbumUI = FindObjectOfType(); + _cardAlbumUI = FindFirstObjectByType(); } // Re-cache card backs in case they changed while disabled diff --git a/Assets/Scripts/UI/CardSystem/CardSystemSceneVisibility.cs b/Assets/Scripts/UI/CardSystem/CardSystemSceneVisibility.cs index f294acd3..5c9c8afc 100644 --- a/Assets/Scripts/UI/CardSystem/CardSystemSceneVisibility.cs +++ b/Assets/Scripts/UI/CardSystem/CardSystemSceneVisibility.cs @@ -17,12 +17,6 @@ namespace UI.CardSystem [Tooltip("The GameObject to show/hide. Defaults to this GameObject if not assigned.")] [SerializeField] private GameObject targetRoot; - [Header("Rules")] - [Tooltip("The scene name in which the Card System should be hidden.")] - [SerializeField] private string startingSceneName = "StartingScene"; - [Tooltip("Also hide when SceneManagerService reports the Bootstrap scene.")] - [SerializeField] private bool hideInBootstrapScene = true; - private void Awake() { if (targetRoot == null) @@ -64,6 +58,7 @@ namespace UI.CardSystem private void ApplyVisibility(string sceneName) { + // TODO: Implement actual visibility logic based on sceneName SetActiveSafe(true); // if (targetRoot == null) // return; diff --git a/Assets/Scripts/UI/LoadingScreenController.cs b/Assets/Scripts/UI/LoadingScreenController.cs index 045c9c23..e60436c6 100644 --- a/Assets/Scripts/UI/LoadingScreenController.cs +++ b/Assets/Scripts/UI/LoadingScreenController.cs @@ -27,7 +27,6 @@ namespace UI private Action _onLoadingScreenFullyHidden; private static LoadingScreenController _instance; - private static bool _isQuitting; /// /// Delegate for providing progress values from different sources diff --git a/Assets/Settings/Developer/DebugSettings.asset b/Assets/Settings/Developer/DebugSettings.asset index 19aa723c..3e9db0bb 100644 --- a/Assets/Settings/Developer/DebugSettings.asset +++ b/Assets/Settings/Developer/DebugSettings.asset @@ -14,3 +14,5 @@ MonoBehaviour: m_EditorClassIdentifier: AppleHillsScripts::AppleHills.Core.Settings.DebugSettings showDebugUiMessages: 1 pauseTimeOnPauseGame: 1 + bootstrapLogVerbosity: 1 + settingsLogVerbosity: 1 diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index ec45254d..59cc9d80 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -26,6 +26,21 @@ EditorBuildSettings: - enabled: 1 path: Assets/Scenes/Levels/CementFactory.unity guid: 42e997833238438408d2b96b63b92229 + - enabled: 1 + path: Assets/Scenes/MiniGames/BirdPoop.unity + guid: dd121162700d80c438a41c47576e2d1f + - enabled: 1 + path: Assets/Scenes/MiniGames/CardQualityControl.unity + guid: 6235a55306105814b88559e551b5e332 + - enabled: 1 + path: Assets/Scenes/MiniGames/FortFight.unity + guid: 5d5af1523a33f8a4e96006d9854e2d50 + - enabled: 1 + path: Assets/Scenes/MiniGames/StatueDecoration.unity + guid: da5190bbf76f09747a964378503f1d75 + - enabled: 1 + path: Assets/Scenes/MiniGames/ValentineNoteDelivery.unity + guid: 4c52eef4f28cd88489348042e53694d2 m_configObjects: com.unity.addressableassets: {fileID: 11400000, guid: ae6ab785ade6a78439b79df6808becd2, type: 2} com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}