public static int?TryProgress(this TrackableDictionary <int, UserAchievement> dict, AchievementKey key, int increment) { UserAchievement ach; if (dict.TryGetValue((int)key, out ach)) { if (ach.AchieveTime.HasValue) { return(null); } ach = new UserAchievement { Value = ach.Value + increment }; dict[(int)key] = ach; } else { ach = new UserAchievement { Value = increment }; dict.Add((int)key, ach); } return(ach.Value); }
public static bool TryAchieved(this TrackableDictionary <int, UserAchievement> dict, AchievementKey key) { UserAchievement ach; if (dict.TryGetValue((int)key, out ach)) { if (ach.AchieveTime.HasValue) { return(false); } ach = new UserAchievement { AchieveTime = DateTime.UtcNow, Value = ach.Value }; dict[(int)key] = ach; } else { ach = new UserAchievement { AchieveTime = DateTime.UtcNow }; dict.Add((int)key, ach); } return(true); }
public static bool IsAchieved(this TrackableDictionary <int, UserAchievement> dict, AchievementKey key) { UserAchievement ach; return(dict.TryGetValue((int)key, out ach) && ach.AchieveTime.HasValue); }
public static bool TryProgress(this TrackableDictionary <int, UserAchievement> dict, AchievementKey key, int increment, int goal) { var value = TryProgress(dict, key, increment); if (value == null || value < goal) { return(false); } return(TryAchieved(dict, key)); }
public static bool TryAchieved(this TrackableDictionary<int, UserAchievement> dict, AchievementKey key) { UserAchievement ach; if (dict.TryGetValue((int)key, out ach)) { if (ach.AchieveTime.HasValue) return false; ach = new UserAchievement { AchieveTime = DateTime.UtcNow, Value = ach.Value }; dict[(int)key] = ach; } else { ach = new UserAchievement { AchieveTime = DateTime.UtcNow }; dict.Add((int)key, ach); } return true; }
public static int? TryProgress(this TrackableDictionary<int, UserAchievement> dict, AchievementKey key, int increment) { UserAchievement ach; if (dict.TryGetValue((int)key, out ach)) { if (ach.AchieveTime.HasValue) return null; ach = new UserAchievement { Value = ach.Value + increment }; dict[(int)key] = ach; } else { ach = new UserAchievement { Value = increment }; dict.Add((int)key, ach); } return ach.Value; }
public static bool IsAchieved(this TrackableDictionary<int, UserAchievement> dict, AchievementKey key) { UserAchievement ach; return dict.TryGetValue((int)key, out ach) && ach.AchieveTime.HasValue; }
public static bool TryProgress(this TrackableDictionary<int, UserAchievement> dict, AchievementKey key, int increment, int goal) { var value = TryProgress(dict, key, increment); if (value == null || value < goal) return false; return TryAchieved(dict, key); }