/// <summary> /// Change the magic item to the specified item. /// </summary> /// <param name="itemIndex">The item index to change the value to.</param> public void ChangeMagicItem(int itemIndex) { if (itemIndex < 0 || itemIndex >= m_ItemDefinitions.Length || itemIndex == m_Index) { return; } if (m_CharacterLocomotion.IsAbilityTypeActive <Use>()) { return; } if (m_Index != -1) { m_Objects[m_Index].SetActive(false); m_ParticleStreamAttributeMonitor.SetActive(false); SetButtonColor(m_Index, m_NormalColor); } m_Index = itemIndex; m_Inventory.Pickup(m_ItemDefinitions[itemIndex].CreateItemIdentifier(), 1, 0, false, true); m_Objects[m_Index].SetActive(true); for (int i = 0; i < m_Objects[m_Index].transform.childCount; ++i) { m_Objects[m_Index].transform.GetChild(i).gameObject.SetActive(true); } if (m_ItemDefinitions[itemIndex] == m_ParticleStreamItemDefinition) { m_ParticleStreamAttributeMonitor.SetActive(true); } SetButtonColor(m_Index, m_PressedColor); }
/// <summary> /// Internal method which picks up the ItemIdentifier. /// </summary> /// <param name="character">The character that should pick up the ItemIdentifier.</param> /// <param name="inventory">The inventory belonging to the character.</param> /// <param name="slotID">The slot ID that picked up the item. A -1 value will indicate no specified slot.</param> /// <param name="immediatePickup">Should the item be picked up immediately?</param> /// <param name="forceEquip">Should the item be force equipped?</param> /// <returns>True if an ItemIdentifier was picked up.</returns> protected override bool DoItemIdentifierPickupInternal(GameObject character, InventoryBase inventory, int slotID, bool immediatePickup, bool forceEquip) { // Add the ItemIdentifiers to the Inventory. This allows the character to pick up the actual item and any consumable ItemIdentifier (such as ammo). var pickedUp = false; if (m_ItemDefinitionAmounts != null) { for (int i = 0; i < m_ItemDefinitionAmounts.Length; ++i) { if (inventory.Pickup(m_ItemDefinitionAmounts[i].ItemIdentifier, m_ItemDefinitionAmounts[i].Amount, slotID, immediatePickup, forceEquip)) { pickedUp = true; } } } return(pickedUp); }