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(); } } } }