예제 #1
0
 private void TryBuyItem(ShopItem.ItemType itemType)
 {
     if (shopCustomer.TrySpendGoldAmount(ShopItem.GetCost(itemType)))
     {
         //can afforf cost
         shopCustomer.BouthItem(itemType);
     }
 }
예제 #2
0
    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;
        }
    }
예제 #3
0
    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);
        };
    }
예제 #4
0
 public PlayerPart GetPartOfType(ShopItem.ItemType type)
 {
     return(parts.FirstOrDefault((p) => { return p.item.type == type; }));
 }