/// <summary> /// Completes this <c>Mission</c>'s by opening its <c>Gate</c>. /// </summary> /// <returns>If <c>Schedule</c> doesn't approve, the mission cannot be completed /// and thus returns <c>false</c>; otherwise opens this <c>Mission</c>'s /// <c>Gate</c> and returns <c>true</c> if successful.</returns> public bool Complete() { if (!Schedule.Approve(MissionStorage.GetTimesCompleted(this))) { SoomlaUtils.LogDebug(TAG, "missions cannot be completed b/c Schedule doesn't approve."); return(false); } SoomlaUtils.LogDebug(TAG, "trying opening gate to complete mission: " + ID); return(Gate.Open()); }
/// <summary> /// Handles mission-revoked events. If the <c>Challenge</c> was completed before, but now /// one of its child <c>Mission</c>s is incomplete, the <c>Challenge</c> is revoked as well. /// </summary> /// <param name="mission">The <c>Mission</c> that triggered the event.</param> public void onMissionCompletionRevoked(Mission mission) { if (Missions.Contains(mission)) { if (MissionStorage.IsCompleted(this)) { setCompletedInner(false); } } }
/// <summary> /// Sets this <c>Mission</c> as completed and gives or takes <c>Reward</c>s according /// to the given <c>completed</c> value. /// </summary> /// <param name="completed">If set to <c>true</c> gives rewards.</param> protected void setCompletedInner(bool completed) { // set completed in Mission Storage MissionStorage.SetCompleted(this, completed); if (completed) { giveRewards(); } else { takeRewards(); } }
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> /// Checks if this <c>Mission</c> has ever been completed - no matter how many times. /// </summary> /// <returns>If this instance is completed returns <c>true</c>; otherwise <c>false</c>.</returns> public virtual bool IsCompleted() { return(MissionStorage.IsCompleted(this)); }
/// <summary> /// Determines whether this <c>Mission</c> is available by checking the criteria /// that makes the specific <c>Mission</c> available. /// </summary> /// <returns>If this instance is available returns <c>true</c>; otherwise <c>false</c>.</returns> public virtual bool IsAvailable() { return(Gate.CanOpen() && Schedule.Approve(MissionStorage.GetTimesCompleted(this))); }