/// <summary> /// Attempts to open this <c>Gate</c>, if it has not been opened aready. /// </summary> public bool Open() { // check in gate storage if it's already open. if (GateStorage.IsOpen(this)) { return(true); } return(openInner()); }
/// <summary> /// Checks if this <c>Gate</c> meets its criteria for opening. /// </summary> /// <returns>If this <c>Gate</c> can be opened returns <c>true</c>; otherwise, <c>false</c>.</returns> public bool CanOpen() { // check in gate storage if the gate is open. // gates are only opened once if (GateStorage.IsOpen(this)) { return(false); } return(canOpenInner()); }
void ClearCurrentState() { List <String> allKeys = KeyValueStorage.GetEncryptedKeys(); if (allKeys != null) { foreach (string key in allKeys) { if (key.StartsWith(GateStorage.getKeyGatePrefix()) || key.StartsWith(LevelStorage.getKeyLevelPrefix()) || key.StartsWith(MissionStorage.getKeyMissionPrefix()) || key.StartsWith(ScoreStorage.getKeyScorePrefix()) || key.StartsWith(WorldStorage.getKeyWorldPrefix())) { KeyValueStorage.DeleteKeyValue(key); } } } }
/// <summary> /// Sets the <c>Gate</c> to open without checking if the <c>Gate</c> meets its criteria. /// </summary> /// <param name="open">If set to <c>true</c> open the <c>Gate</c>.</param> public void ForceOpen(bool open) { bool isOpen = IsOpen(); if (isOpen == open) { // if it's already open why open it again? return; } GateStorage.SetOpen(this, open); if (open) { unregisterEvents(); } else { // we can do this here ONLY because we check 'isOpen == open' a few lines above. registerEvents(); } }
/// <summary> /// Checks if this <c>Gate</c> meets its criteria for opening. /// </summary> /// <returns>If this <c>Gate</c> can be opened returns <c>true</c>; otherwise <c>false</c>.</returns> protected override bool canOpenInner() { // Gates don't have activation times, they can only be activated once. // We are kind of ignoring the activation limit of Schedule here. return(Schedule.Approve(GateStorage.IsOpen(this) ? 1 : 0)); }
/// <summary> /// Determines whether this <c>Gate</c> is open. /// </summary> /// <returns>If this <c>Gate</c> is open returns <c>true</c>; otherwise, <c>false</c>.</returns> public bool IsOpen() { return(GateStorage.IsOpen(this)); }