private void CreateItemButton(Item.ItemType itemType, Sprite itemSprite, string itemName, int itemCost, string itemElement, int positionIndex, string description) { Transform shopItemTransform = Instantiate(ShopItemTemplate, Container); shopItemTransform.GetComponent <ShopItemUI>().SetDescription(description); shopItemTransform.gameObject.SetActive(true); shopItemTransform.gameObject.name = itemType.ToString(); RectTransform shopItemRectTransform = shopItemTransform.GetComponent <RectTransform>(); PositionButton(shopItemRectTransform, positionIndex); //Set shop item texts and icons shopItemTransform.Find("nameText").GetComponent <TextMeshProUGUI>().SetText(itemName); shopItemTransform.Find("cost").GetComponent <TextMeshProUGUI>().SetText(itemCost.ToString()); shopItemTransform.Find("itemImage").GetComponent <Image>().sprite = itemSprite; if (itemElement == "General") { shopItemTransform.Find("soul_Image").GetComponent <Image>().sprite = GameAssets.i.GeneralSoul; } else if (itemElement == "Fire") { shopItemTransform.Find("soul_Image").GetComponent <Image>().sprite = GameAssets.i.FireSoul; } else if (itemElement == "Water") { shopItemTransform.Find("soul_Image").GetComponent <Image>().sprite = GameAssets.i.WaterSoul; } else if (itemElement == "Earth") { shopItemTransform.Find("soul_Image").GetComponent <Image>().sprite = GameAssets.i.EarthSoul; } else if (itemElement == "Air") { shopItemTransform.Find("soul_Image").GetComponent <Image>().sprite = GameAssets.i.AirSoul; } Button shopBtn = shopItemTransform.GetComponent <Button>(); shopBtn.onClick.AddListener(() => TryBuyItem?.Invoke(itemType, itemCost, itemElement)); }
public void OnTryBuyItem(int shopId, int itemId, int shopItemId) { TryBuyItem?.Invoke(Bot, shopId, itemId, shopItemId); }