コード例 #1
0
        public void SetItemUnlocked(string itemId, bool unlocked)
        {
            if (unlocked && ItemUnlocked(itemId))
            {
                return;
            }
            if (!unlocked && unlockablesMap.ContainsKey(itemId) && !ItemUnlocked(itemId))
            {
                return;
            }

            var added = unlockablesMap.ContainsKey(itemId);

            unlockablesMap[itemId] = unlocked;
            OnItemUpdated?.Invoke(new UnlockableItemUpdatedArgs(itemId, unlocked, added));
        }
コード例 #2
0
        public virtual void SetItemUnlocked(string itemId, bool unlocked)
        {
            if (string.IsNullOrEmpty(itemId))
            {
                throw new ArgumentNullException(nameof(itemId), "Can't set unlock status of item with empty ID.");
            }

            if (unlocked && ItemUnlocked(itemId))
            {
                return;
            }
            if (!unlocked && unlockablesMap.ContainsKey(itemId) && !ItemUnlocked(itemId))
            {
                return;
            }

            var added = unlockablesMap.ContainsKey(itemId);

            unlockablesMap[itemId] = unlocked;
            OnItemUpdated?.Invoke(new UnlockableItemUpdatedArgs(itemId, unlocked, added));
        }