Domain.UserAchievementDictionaryExtensions.TryAchieved C# (CSharp) Method

TryAchieved() public static method

public static TryAchieved ( UserAchievement>.this dict, AchievementKey key ) : bool
dict UserAchievement>.this
key AchievementKey
return bool
        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;
        }
UserAchievementDictionaryExtensions