Looking-Glass/Assets/scripts/Lockable.cs
2024-02-27 18:03:50 +00:00

34 lines
871 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// if locked is true, calling TryUnlock will call StartUnlock, otherwise it will call FailedUnlock.
public abstract class Lockable : MonoBehaviour
{
public bool looping = true;
public bool loopingAfterUnlock = false;
public bool locked = true;
private bool runBefore = false;
private bool unlockedBefore = false;
public abstract void StartUnlock();
public abstract void FailedUnlock();
public void TryUnlock(){
if((!runBefore) | looping){
runBefore = true;
if(!locked){
if((!unlockedBefore) | loopingAfterUnlock){
unlockedBefore = true;
StartUnlock();
}
}
else{
FailedUnlock();
}
}
}
}