Fix issues with puzzle loading order and add saving state when using Menu
This commit is contained in:
committed by
Michal Pikulski
parent
c527ba334d
commit
717deee0cd
@@ -255,9 +255,9 @@ namespace Levels
|
||||
if (_switchData == null)
|
||||
return;
|
||||
|
||||
var data = SaveLoadManager.Instance?.currentSaveData;
|
||||
// Use the new public API to check unlock status
|
||||
string minigameName = _switchData.targetMinigameSceneName;
|
||||
bool unlocked = data?.unlockedMinigames != null && !string.IsNullOrEmpty(minigameName) && data.unlockedMinigames.Contains(minigameName);
|
||||
bool unlocked = SaveLoadManager.Instance != null && SaveLoadManager.Instance.IsMinigameUnlocked(minigameName);
|
||||
|
||||
// Show/hide padlock
|
||||
if (padlockImage) padlockImage.gameObject.SetActive(!unlocked);
|
||||
|
||||
@@ -102,7 +102,13 @@ namespace Levels
|
||||
isUnlocked = true;
|
||||
gameObject.SetActive(true);
|
||||
|
||||
// Save will happen automatically on next save cycle via ISaveParticipant
|
||||
// Add to global unlocked minigames list
|
||||
if (switchData != null && !string.IsNullOrEmpty(switchData.targetLevelSceneName))
|
||||
{
|
||||
Core.SaveLoad.SaveLoadManager.Instance?.UnlockMinigame(switchData.targetLevelSceneName);
|
||||
}
|
||||
|
||||
// Save will happen automatically on next save cycle via SaveableInteractable
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
@@ -231,6 +237,12 @@ namespace Levels
|
||||
|
||||
isUnlocked = data.isUnlocked;
|
||||
|
||||
// Sync with global unlocked minigames list
|
||||
if (isUnlocked && switchData != null && !string.IsNullOrEmpty(switchData.targetLevelSceneName))
|
||||
{
|
||||
Core.SaveLoad.SaveLoadManager.Instance?.UnlockMinigame(switchData.targetLevelSceneName);
|
||||
}
|
||||
|
||||
// Show/hide based on unlock state
|
||||
gameObject.SetActive(isUnlocked);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user