PuzzleGame/PuzzleGameProject/Assets/Scripts/Rooms/Locks/Lock.cs
2025-01-30 11:05:39 +01:00

34 lines
726 B
C#

using System;
using Unity.VisualScripting;
using UnityEngine;
using System.Collections.Generic;
public abstract class Lock : MonoBehaviour
{
// Room that must be explored before lock can be unlocked.
[SerializeField] protected Room blockingRoom;
public event Action Unlocked;
public virtual bool CheckIfKeyFits(DicePair dicePair)
{
if (blockingRoom == null || blockingRoom.GetRoomExplored())
{
return true;
}
return false;
}
public virtual void Unlock(DicePair dicePair)
{
if (CheckIfKeyFits(dicePair))
{
OnUnlock();
}
}
protected virtual void OnUnlock()
{
Unlocked?.Invoke();
}
}