Update minigames to start unlocked
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user