public void AddItem(ItemO itemToAdd) { if (itemToAdd.MxStack > 1 && itemToAdd.currentStack < itemToAdd.MxStack) { for (int i = 0; i < items.Length; i++) { if (items[i] == itemToAdd) { itemToAdd.currentStack++; Stack.text = itemToAdd.currentStack.ToString(); return; } } } for (int i = 0; i < items.Length; i++) { if (items[i] == null) { items[i] = itemToAdd; itemImages[i].sprite = itemToAdd.sprite; itemImages[i].enabled = true; return; } } }
private void FillShop(string[] inventory, GameObject[] shopSlots, int size) { for (int i = 0; i < size; i++) { if (inventory[i] != "" && inventory[i] != null) { sss = shopSlots[i].GetComponent <ShopSlotScript>(); switch (inventory[i][0]) { case 'h': foreach (HealingItemObject healingItem in hio) { if (healingItem.name == inventory[i]) { ItemO = Instantiate(shopItem, shopSlots[i].transform); itemInfo = ItemO.GetComponent <ItemInfo>(); itemInfo.GetData(healingItem.icon, healingItem.itemName, healingItem.description, healingItem.name, healingItem.cost, txtDescName, txtDescDesc); sss.GetItem(itemInfo.strName, itemInfo.strDesc, inventory[i], itemInfo.cost, i, gameObject); break; } } break; case 'c': foreach (CombatItemObject combatItem in cio) { if (combatItem.name == inventory[i]) { ItemO = Instantiate(shopItem, shopSlots[i].transform); itemInfo = ItemO.GetComponent <ItemInfo>(); itemInfo.GetData(combatItem.icon, combatItem.itemName, combatItem.description, combatItem.name, combatItem.cost, txtDescName, txtDescDesc); sss.GetItem(itemInfo.strName, itemInfo.strDesc, inventory[i], itemInfo.cost, i, gameObject); break; } } break; case 'w': foreach (WeaponObject weapon in wpo) { if (weapon.name == inventory[i]) { ItemO = Instantiate(shopItem, shopSlots[i].transform); itemInfo = ItemO.GetComponent <ItemInfo>(); itemInfo.GetData(weapon.icon, weapon.weaponName, weapon.description, weapon.name, weapon.cost, txtDescName, txtDescDesc); sss.GetItem(itemInfo.strName, itemInfo.strDesc, inventory[i], itemInfo.cost, i, gameObject); break; } } break; } } } }
public void RemoveItem(ItemO itemToRemove) { for (int i = 0; i < items.Length; i++) { if (items[i] == itemToRemove) { items[i] = null; itemImages[i].sprite = null; itemImages[i].enabled = false; return; } } }