public void Craft(IItemContainer itemContainer) { // if we have sufficient materials to craft the item if (CanCraft(itemContainer)) { // loop through the materials list and remove the required materials foreach (ItemAmount itemAmount in materials) { for (int i = 0; i < itemAmount.amount; i++) { sScrapItem oldItem = itemContainer.RemoveItem(itemAmount.item.ID); Destroy(oldItem); } } // loop through the results list and add them back to the inventory foreach (ItemAmount itemAmount in results) { for (int i = 0; i < itemAmount.amount; i++) { itemContainer.AddItem(Instantiate(itemAmount.item)); } } } }
public virtual bool CanRecieveItem(sScrapItem _item) { return(true); // tells us whether we can put this item inside a slot // As this is in the inventory slot, it will always return true as there are no current restrictions on what items // we can hold in our inventory. }
public void ShowScrapToolTip(sScrapItem _item) { scrapItemNameText.text = _item.itemName; scrapItemDescText.text = _item.itemDescription; scrapItemValueText.text = _item.scrapValue.ToString(); scrapItemIcon.sprite = _item.inventoryIcon; gameObject.SetActive(true); }
public override bool CanRecieveItem(sScrapItem _item) { if (_item == null && !isLooted) { return(true); } return(false); }
private void Drop(ItemSlot _dropItemSlot) { if (draggedSlot == null) { return; } // Can the slot that we are dropping the item, recieve the item from the slot that started the drag // AND // Can the slot that started the drag recieve the item from the slot that we are dropping the item if (_dropItemSlot.CanRecieveItem(draggedSlot.Item) && draggedSlot.CanRecieveItem(_dropItemSlot.Item)) { sEquippableItem dragItem = draggedSlot.Item as sEquippableItem; sEquippableItem dropItem = _dropItemSlot.Item as sEquippableItem; // If we are dragging an item out of an equipment slot if (draggedSlot is EquipmentSlot) { // Unequip the drag item and equip the item in the drop slot if (dragItem != null) { dragItem.Unequip(this); } if (dropItem != null) { dropItem.Equip(this); } } if (_dropItemSlot is EquipmentSlot) { // Unequip the drop item and equip the item in the drag item if (dragItem != null) { dragItem.Equip(this); } if (dropItem != null) { dropItem.Unequip(this); } } // Update the stat panel //statPanel.UpdateStatValues(); sScrapItem draggedItem = draggedSlot.Item; draggedSlot.Item = _dropItemSlot.Item; if (draggedSlot as LootBoxSlot) { print("slot looted!"); } _dropItemSlot.Item = draggedItem; } }
public override bool CanRecieveItem(sScrapItem _item) { if (_item == null) { return(true); } // Check if the item we are trying to equip is an equippable item sEquippableItem equippableItem = _item as sEquippableItem; // And if it is an equippable item, check if the items equipment type corresponds to the slot equipment type return(equippableItem != null && equippableItem.equipType == equipType); }
public bool ContainsItem(sScrapItem _item) { for (int i = 0; i < itemSlots.Length; i++) { if (itemSlots[i].Item == _item) { return(true); } } AM.PlayConsistentOneShot(errorSound, soundVolume); return(false); }
public bool RemoveItem(sScrapItem _item) { for (int i = 0; i < itemSlots.Length; i++) { if (itemSlots[i].Item == _item) { AM.PlayConsistentOneShot(trashSound, soundVolume); itemSlots[i].Item = null; PM.inventoryItems.Remove(_item); return(true); } } return(false); }
private void HideTooltip(ItemSlot _itemSlot) { // if the item in the selected equipment slot is an equippable item, hide the tooltip! sEquippableItem equippableItem = _itemSlot.Item as sEquippableItem; sScrapItem scrapItem = _itemSlot.Item; if (equippableItem != null) { itemTooltip.HideToolTip(); } else if (scrapItem != null) { itemTooltip.HideToolTip(); } }
public bool AddItem(sScrapItem _item) { for (int i = 0; i < itemSlots.Length; i++) { if (itemSlots[i].Item == null) { AM.PlayConsistentOneShot(pickUpSound, soundVolume); PM.inventoryItems.Add(Instantiate(_item)); itemSlots[i].Item = Instantiate(_item); return(true); } } Debug.Log("No room left in inventory!"); return(false); }
private void ShowTooltip(ItemSlot _itemSlot) { Toolbox.GetInstance().GetAudioManager().PlayConsistentOneShot(hoverSound, hoverVolume); // if the item in the selected equipment slot is an equippable item, display the tooltip! sEquippableItem equippableItem = _itemSlot.Item as sEquippableItem; sScrapItem scrapItem = _itemSlot.Item; if (equippableItem != null) { itemTooltip.ShowEquipmentToolTip(equippableItem); } else if (scrapItem != null) { itemTooltip.ShowScrapToolTip(scrapItem); } }
public sScrapItem RemoveItem(string _itemID) { // loop through the item slots for (int i = 0; i < itemSlots.Length; i++) { sScrapItem item = itemSlots[i].Item; // check to see if there is an item in the slot, and if so, does it have the same item ID as the one we are looking for if (item != null && item.ID == _itemID) { // if we find the item we are looking for, remove it from that slot, and return the item reference itemSlots[i].Item = null; return(item); } } // if we didnt find anything, return null return(null); }