Example #1
0
    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;
                }
            }
        }
    }