private void TryBuyItem(ShopItem.ItemType itemType) { if (shopCustomer.TrySpendGoldAmount(ShopItem.GetCost(itemType))) { //can afforf cost shopCustomer.BouthItem(itemType); } }
public void BouthItem(ShopItem.ItemType itemType) { Debug.Log("Bouth Itme : " + itemType); switch (itemType) { case ShopItem.ItemType.Hp: AddHealthPotion(); break; case ShopItem.ItemType.Pistol: AddDamagePistol(); break; case ShopItem.ItemType.Rifle: AddDamageRifle(); break; case ShopItem.ItemType.Shotgun: AddDamageShotgun(); break; } }
private void CreateItemButton(ShopItem.ItemType itemType, Sprite itemSprite, string itemName, int itemCost, int positionIndex) { Transform shopItemTransform = Instantiate(shopItemTemplate, container); shopItemTransform.gameObject.SetActive(true); RectTransform shopItemRectTransform = shopItemTransform.GetComponent <RectTransform>(); float shopItemHeight = 90f; shopItemRectTransform.anchoredPosition = new Vector2(0, -shopItemHeight * positionIndex); shopItemTransform.Find("nameText").GetComponent <Text>().text = itemName.ToString(); shopItemTransform.Find("costText").GetComponent <Text>().text = "$" + itemCost.ToString(); shopItemTransform.Find("itemImage").GetComponent <Image>().sprite = itemSprite; shopItemTransform.GetComponent <Button_UI>().ClickFunc = () => { //Clicked on shop item button TryBuyItem(itemType); }; }
public PlayerPart GetPartOfType(ShopItem.ItemType type) { return(parts.FirstOrDefault((p) => { return p.item.type == type; })); }