Update minigames to start unlocked

This commit is contained in:
Michal Pikulski
2025-11-07 13:31:49 +01:00
parent 32a477b843
commit 5b70042005
2 changed files with 132 additions and 93 deletions

File diff suppressed because one or more lines are too long

View File

@@ -31,6 +31,12 @@ namespace Levels
/// Data for this level switch (target scene, icon, etc).
/// </summary>
public LevelSwitchData switchData;
/// <summary>
/// If true, skip save/load logic and start the game active (unlocked by default)
/// </summary>
[SerializeField] private bool startUnlocked = false;
private SpriteRenderer iconRenderer;
// Settings reference
@@ -52,6 +58,12 @@ namespace Levels
if (iconRenderer == null)
iconRenderer = GetComponent<SpriteRenderer>();
// If startUnlocked is true, set isUnlocked and skip save/load logic
if (startUnlocked)
{
isUnlocked = true;
}
// Initialize settings reference
interactionSettings = GameManager.GetSettingsObject<IInteractionSettings>();
ApplySwitchData();
@@ -61,7 +73,14 @@ namespace Levels
{
base.Start(); // Register with save system
// If not restoring from save, start inactive
// If startUnlocked is true, always start active
if (startUnlocked)
{
gameObject.SetActive(true);
return;
}
// Otherwise, if not restoring from save, start inactive
if (!IsRestoringFromSave && !isUnlocked)
{
gameObject.SetActive(false);
@@ -165,6 +184,10 @@ namespace Levels
protected override object GetSerializableState()
{
// Skip saving if startUnlocked is true
if (startUnlocked)
return null;
return new MinigameSwitchSaveData
{
isUnlocked = isUnlocked
@@ -173,6 +196,10 @@ namespace Levels
protected override void ApplySerializableState(string serializedData)
{
// Skip loading if startUnlocked is true
if (startUnlocked)
return;
MinigameSwitchSaveData data = JsonUtility.FromJson<MinigameSwitchSaveData>(serializedData);
if (data == null)
{