示例#1
0
 /// <summary>
 /// Four parameter ItemSet constructor.
 /// </summary>
 /// <param name="slotCount">The number of slots used by the ItemSet.</param>
 /// <param name="slotID">The ID of the slot that will use the ItemSet.</param>
 /// <param name="itemDefinition">The ItemDefinition of the ItemSet.</param>
 /// <param name="itemIdentifier">The ItemIdentifier of the ItemSet.</param>
 /// <param name="state">The state to change to when the ItemSet is active.</param>
 public ItemSet(int slotCount, int slotID, ItemDefinitionBase itemDefinition, IItemIdentifier itemIdentifier, string state)
 {
     m_Slots                   = new ItemDefinitionBase[slotCount];
     m_Slots[slotID]           = itemDefinition;
     m_State                   = state;
     m_Enabled                 = true;
     m_ItemIdentifiers         = new IItemIdentifier[slotCount];
     m_ItemIdentifiers[slotID] = itemIdentifier;
 }
示例#2
0
        /// <summary>
        /// Returns true if the ItemDefinition belongs to the category with the specified index.
        /// </summary>
        /// <param name="itemDefinition">The ItemDefinition to determine if it belongs to the category.</param>
        /// <param name="categoryIndex">The index of the category which the ItemIdentifier may belong to.</param>
        /// <returns>True if the ItemDefinition belongs to the category with the specified index.</returns>
        public bool IsCategoryMember(ItemDefinitionBase itemDefinition, int categoryIndex)
        {
            // If an ItemDefinition doesn't have a category it is a member of every category.
            if (itemDefinition.GetItemCategory() == null)
            {
                return(true);
            }

            return(IsCategoryMember(itemDefinition.GetItemCategory(), categoryIndex));
        }
示例#3
0
        /// <summary>
        /// Returns true if the ItemDefinitionrepresents the default ItemCategory.
        /// </summary>
        /// <param name="itemIdentifier">The ItemDefinition to determine if it is the default ItemCategory.</param>
        /// <returns>True if the ItemDefinition represents the default ItemCategory.</returns>
        public bool IsDefaultItemCategory(ItemDefinitionBase itemDefinition)
        {
            if (itemDefinition == null)
            {
                return(false);
            }
            var category = itemDefinition.GetItemCategory();

            if (category == null)
            {
                return(false);
            }

            return(IsDefaultItemCategory(itemDefinition, category));
        }
示例#4
0
        /// <summary>
        /// Returns true if the ItemCategory represents the default ItemCategory.
        /// </summary>
        /// <param name="itemDefinition">The ItemDefinition to determine if it is the default ItemCategory.</param>
        /// <param name="itemCategory">The ItemCategory to determine if it is the default ItemCategory.</param>
        /// <returns>True if the ItemCategory represents the default ItemCategory.</returns>
        private bool IsDefaultItemCategory(ItemDefinitionBase itemDefinition, IItemCategoryIdentifier itemCategory)
        {
            var categoryParents = itemCategory.GetDirectParents();

            if (categoryParents != null)
            {
                for (int i = 0; i < categoryParents.Count; ++i)
                {
                    if (IsDefaultItemCategory(itemDefinition, categoryParents[i]))
                    {
                        return(true);
                    }
                }
            }

            var index = CategoryToIndex(itemCategory);

            if (index == -1)
            {
                return(false);
            }

            // The default category does not match the active category. Return false.
            if (m_CategoryItemSets[index].DefaultItemSetIndex != m_ActiveItemSetIndex[index])
            {
                return(false);
            }

            // The default category is active. Ensure the ItemDefinition is in that ItemSet.
            var hasItemDefinition = false;
            var itemSetList       = m_CategoryItemSets[index].ItemSetList[m_ActiveItemSetIndex[index]];

            for (int i = 0; i < itemSetList.Slots.Length; ++i)
            {
                if (IsChildOf(itemDefinition, itemSetList.Slots[i]))
                {
                    hasItemDefinition = true;
                    break;
                }
            }
            if (!hasItemDefinition)
            {
                return(false);
            }

            return(true);
        }
示例#5
0
        /// <summary>
        /// Returns true if the possible child ItemDefinition is a child of the possible parent ItemDefinition.
        /// </summary>
        /// <param name="possibleChild">The ItemDefinition that may be a child of the specified parent.</param>
        /// <param name="categoryIndex">The ItemDefinition that may be a parent of the specified child.</param>
        /// <returns>True if the child ItemDefinition is a child of the parent ItemDefinition.</returns>
        private bool IsChildOf(ItemDefinitionBase possibleChild, ItemDefinitionBase possibleParent)
        {
            if (possibleChild == null || possibleParent == null)
            {
                return(false);
            }

            var itemDefinition = possibleChild;

            while (itemDefinition != null)
            {
                if (itemDefinition == possibleParent)
                {
                    return(true);
                }
                itemDefinition = itemDefinition.GetParent();
            }
            return(false);
        }
示例#6
0
 /// <summary>
 /// Initializes the ItemDefinitionAmount to the specified values.
 /// </summary>
 /// <param name="itemIdentifier">The definition of item.</param>
 /// <param name="amount">The amount of ItemDefinitionBase.</param>
 public void Initialize(ItemDefinitionBase itemDefinition, int amount)
 {
     m_ItemDefinition = itemDefinition;
     m_Amount         = amount;
 }
示例#7
0
 /// <summary>
 /// ItemDefinitionAmount constructor with two parameters.
 /// </summary>
 /// <param name="itemDefinition">The definition of item.</param>
 /// <param name="amount">The amount of ItemDefinitionBase.</param>
 public ItemDefinitionAmount(ItemDefinitionBase itemDefinition, int amount)
 {
     Initialize(itemDefinition, amount);
 }
示例#8
0
 /// <summary>
 /// Future method.
 /// </summary>
 bool IItemCategoryIdentifier.InherentlyContains(ItemDefinitionBase itemDefinition, bool includeThis)
 {
     return(false); // Intentional, structure for future work.
 }
 /// <summary>
 /// ItemDefinitionAmount constructor with two parameters.
 /// </summary>
 /// <param name="itemDefinition">The definition of item.</param>
 /// <param name="amount">The amount of ItemDefinitionBase.</param>
 public ItemDefinitionAmount(ItemDefinitionBase itemDefinition, int amount)
 {
     ItemDefinition   = itemDefinition;
     Amount           = amount;
     m_ItemIdentifier = null;
 }