[Puzzles] Add basic framework for ScriptableObject puzzle steps and puzzle solving.
This commit is contained in:
55
Assets/Scripts/ObjectiveStepBehaviour.cs
Normal file
55
Assets/Scripts/ObjectiveStepBehaviour.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Interactable))]
|
||||
public class ObjectiveStepBehaviour : MonoBehaviour
|
||||
{
|
||||
public PuzzleStepSO stepData;
|
||||
private Interactable interactable;
|
||||
private bool isUnlocked = false;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
interactable = GetComponent<Interactable>();
|
||||
if (interactable != null)
|
||||
{
|
||||
interactable.Interacted += OnInteracted;
|
||||
}
|
||||
// Register with PuzzleManager
|
||||
PuzzleManager.Instance?.RegisterStepBehaviour(this);
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (interactable != null)
|
||||
{
|
||||
interactable.Interacted -= OnInteracted;
|
||||
}
|
||||
PuzzleManager.Instance?.UnregisterStepBehaviour(this);
|
||||
}
|
||||
|
||||
public void UnlockStep()
|
||||
{
|
||||
isUnlocked = true;
|
||||
Debug.Log($"[Puzzles] Step unlocked: {stepData?.stepId} on {gameObject.name}");
|
||||
// Optionally, show visual feedback for unlocked state
|
||||
}
|
||||
|
||||
public void LockStep()
|
||||
{
|
||||
isUnlocked = false;
|
||||
Debug.Log($"[Puzzles] Step locked: {stepData?.stepId} on {gameObject.name}");
|
||||
// Optionally, show visual feedback for locked state
|
||||
}
|
||||
|
||||
public bool IsStepUnlocked()
|
||||
{
|
||||
return isUnlocked;
|
||||
}
|
||||
|
||||
private void OnInteracted()
|
||||
{
|
||||
if (!isUnlocked) return;
|
||||
Debug.Log($"[Puzzles] Step interacted: {stepData?.stepId} on {gameObject.name}");
|
||||
PuzzleManager.Instance?.OnStepCompleted(stepData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user