Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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;
        }