public void AddShopTradeNode(Item item, Item trade, int cost) { ShopBuyNode node = Instantiate(prefab, container.transform); node.SetTradeNode(item, trade, cost); tradeNodes.Add(node); }
public void LoadInventories() { foreach (ShopBuyNode node in shopBuyNodes) { Destroy(node.gameObject); } shopBuyNodes.Clear(); if (currentNPC != null) { foreach (Item item in currentNPC.npcWares) { ShopBuyNode temp = Instantiate(buyPrefab, buyNodeContainer.transform); temp.SetTradeNode(ItemDatabase.NewItem(item), Resources.Load <Item>("Prototypes/Items/Elements/Blueium") as Item, item.GetValue()); shopBuyNodes.Add(temp); } } foreach (ShopSellNode node in shopSellNodes) { Destroy(node.gameObject); } shopSellNodes.Clear(); if (currentPlayer != null) { foreach (InventorySlot slot in currentPlayer.Inventory.slots) { if (!slot.IsEmpty() && slot.item.GetValue() > 0) { if (slot.item is Equipment equipment && equipment.isEquipped) { continue; } ShopSellNode temp = Instantiate(sellPrefab, sellNodeContainer.transform); temp.SetSellNode(slot.item, Resources.Load <Item>("Prototypes/Items/Elements/Blueium") as Item, slot.item.GetSellValue()); shopSellNodes.Add(temp); } } } }