/// <summary>
        /// Removes a Badge from the Player's Inventory.
        /// If the Badge is active, it also unequips the Badge and removes it from the active Badge list
        /// </summary>
        /// <param name="badge">The Badge to remove</param>
        public void RemoveBadge(Badge badge)
        {
            if (badge == null)
            {
                Debug.LogError($"Attempting to remove a null Badge from the Inventory!");
                return;
            }

            if (HasBadgeType(badge.BadgeType) == false)
            {
                Debug.LogWarning($"Badge of type {badge.BadgeType} cannot be removed because it doesn't exist in the Inventory!");
                return;
            }

            //Remove from the all badges list
            AllBadges.Remove(badge);
            AllBadgeCounts[badge.BadgeType]--;
            if (AllBadgeCounts[badge.BadgeType] <= 0)
            {
                AllBadgeCounts.Remove(badge.BadgeType);
            }

            //Remove from active badges if it's active, and unequip it
            if (badge.Equipped == true)
            {
                //Unequip badge to remove its effects and deactivate it
                badge.UnEquip();
            }

            Debug.Log($"Removed {badge.Name} from the Inventory!");
        }
示例#2
0
        /// <summary>
        /// Sets the held Collectible for the enemy. Enemies in TTYD can hold Items and Badges.
        /// <para>If setting a Badge, this will unequip the current Badge from the enemy, provided the held Collectible is a Badge, and equip the new Badge.</para>
        /// </summary>
        /// <param name="heldCollectible">The Collectible to hold.</param>
        public void SetHeldCollectible(Collectible heldCollectible)
        {
            //Unequip the current badge held, if one is held
            if (HeldCollectible?.CollectibleType == Enumerations.CollectibleTypes.Badge)
            {
                Badge heldBadge = (Badge)HeldCollectible;
                heldBadge.UnEquip();
            }

            //Set the collectible
            HeldCollectible = heldCollectible;

            //Equip the held Badge, if one is held
            if (HeldCollectible?.CollectibleType == Enumerations.CollectibleTypes.Badge)
            {
                Badge heldBadge = (Badge)HeldCollectible;
                heldBadge.Equip(this);
            }
        }