Files
AppleHillsProduction/Assets/Scripts/PuzzleS/PuzzleLevelDataSO.cs

74 lines
2.5 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
namespace PuzzleS
{
/// <summary>
/// Represents all puzzle steps in a level.
/// This is automatically generated from folder structure during asset import.
/// </summary>
[CreateAssetMenu(fileName = "LevelPuzzleData", menuName = "AppleHills/Items & Puzzles/LevelPuzzleData")]
public class PuzzleLevelDataSO : ScriptableObject
{
/// <summary>
/// Unique identifier for this level, automatically set to match folder name
/// </summary>
public string levelId;
/// <summary>
/// Display name for this level
/// </summary>
public string displayName;
/// <summary>
/// All puzzle steps in this level
/// </summary>
public List<PuzzleStepSO> allSteps = new List<PuzzleStepSO>();
/// <summary>
/// Steps that should be unlocked at level start (no dependencies)
/// </summary>
public List<PuzzleStepSO> initialSteps = new List<PuzzleStepSO>();
/// <summary>
/// Pre-processed dependency data built at edit time.
/// Maps step IDs to arrays of dependency step IDs (which steps are required by each step)
/// </summary>
public Dictionary<string, string[]> stepDependencies = new Dictionary<string, string[]>();
/// <summary>
/// Check if all steps in the level are complete
/// </summary>
public bool IsLevelComplete(HashSet<PuzzleStepSO> completedSteps)
{
if (completedSteps == null) return false;
foreach (var step in allSteps)
{
if (step != null && !completedSteps.Contains(step))
{
return false;
}
}
return true;
}
/// <summary>
/// Gets all steps that will be unlocked by completing the given step
/// </summary>
public List<PuzzleStepSO> GetUnlockedSteps(PuzzleStepSO completedStep)
{
return completedStep != null ? completedStep.unlocks : new List<PuzzleStepSO>();
}
/// <summary>
/// Check if this step is an initial step (no dependencies)
/// </summary>
public bool IsInitialStep(PuzzleStepSO step)
{
return step != null && initialSteps.Contains(step);
}
}
}