コード例 #1
0
ファイル: DisplayShop.cs プロジェクト: mattgaut/BaseBuilder
    void LoadItems(RectTransform attach_to, ItemType item_type, Inventory load_from)
    {
        bool buying_from_shop = load_from == shop.inventory;

        for (int id = 0; id <= Database.GetMaxID(item_type); id++)
        {
            int item_count = load_from.GetItemCount(item_type, id);
            if (item_count > 0)
            {
                ShopItemDisplay new_display = Instantiate(item_display_prefab, attach_to);
                IItem           item        = Database.GetItem(item_type, id);
                LoadItemDisplay(new_display, Database.GetItem(item_type, id), item_count);
                new_display.SetPrice(buying_from_shop ? item.price : (int)(item.price * shop.buy_rate));
                new_display.SetPriceLimit(buying_from_shop ? patron.inventory.gold : shop.inventory.gold);
                new_display.SetConfirmText(buying_from_shop ? "Buy" : "Sell");
                int id_copy = id;
                if (buying_from_shop)
                {
                    new_display.SetConfirmAction((transaction_count) => SellItem(item_type, id_copy, item.price, transaction_count));
                }
                else
                {
                    new_display.SetConfirmAction((transaction_count) => BuyItem(item_type, id_copy, item.price, transaction_count));
                }
                attach_to.sizeDelta += Vector2.up * new_display.GetComponent <RectTransform>().rect.height;
            }
        }
    }
コード例 #2
0
    private void CreateItem(ShopItem _item)
    {
        GameObject newObj = GameObject.Instantiate(itemPrefab, _coingrid.transform);

        ShopItemDisplay objDisplay = newObj.GetComponent <ShopItemDisplay>();

        objDisplay._master          = this;
        objDisplay._inheritedSource = _mainAudio;
        objDisplay._data            = _item;
        objDisplay.SetDisplay();
    }
コード例 #3
0
ファイル: DisplayShop.cs プロジェクト: mattgaut/BaseBuilder
 void LoadItemDisplay(ShopItemDisplay item_display, IItem item, int count)
 {
     item_display.SetName(item.item_name);
     item_display.SetItemCount(count);
 }