コード例 #1
0
    public void LoadNewShop(int maxShop, int amountMoney)
    {
        Future <List <BaseItem> > futureItems = ItemManager.Ins.RequestNewShop(playerUsingShop.Id, maxShop, amountMoney);

        futureItems.then((List <BaseItem> result) =>
        {
            foreach (UIItemInShop i in _UIitemInShop)
            {
                if (i != null)
                {
                    Destroy(i.gameObject);
                }
            }

            _UIitemInShop.Clear();
            ItemInShop.Clear();


            foreach (var item in result)
            {
                ItemInShop.Add(item);
            }

            foreach (BaseItem item in ItemInShop)
            {
                UIItemInShop u = Instantiate(ItemInShopPrefab, this.transform.Find("ShopNoticeBoard/Scroll View/Viewport/Content"));
                u.Init(item);
                _UIitemInShop.Add(u);
            }
        });
    }
コード例 #2
0
    public void AddNewItem(ItemInShop structure)
    {
        items.Add(structure);
        InitItemInShop(structure);

        ShopChange.Invoke();
    }
コード例 #3
0
 void initItem()
 {
     for (int i = 0; i < ItemDefine.itemCodeToBuy.Length; i++)
     {
         ItemInShop itemInShop    = ItemInShop.make(ItemDefine.itemCodeToBuy [i]);
         GameObject newShopItemUI = Instantiate(shopItemUIPrefab) as GameObject;
         newShopItemUI.transform.SetParent(shopItemHolder, false);
         newShopItemUI.transform.localScale = new Vector3(1, 1, 1);
         ShopItemUI shopItemUI = newShopItemUI.GetComponent <ShopItemUI> ();
         shopItemUI.item = itemInShop;
         shopItemUI.setUI(this);
     }
 }
コード例 #4
0
    public void onBuy(ItemInShop item, int amount)
    {
        int totalCost = item.price * amount;

        if (totalCost > gold)
        {
            if (onBuyFail != null)
            {
                onBuyFail.Invoke();
            }
            return;
        }

        Gold = Gold - totalCost;
        ItemInBag.addAmount(amount, item.code);
        if (onBuySuccess != null)
        {
            onBuySuccess.Invoke();
        }
    }
コード例 #5
0
 public bool RemoveItemFromShop(BaseItem item)
 {
     ItemInShop.Remove(item);
     return(true);
 }
コード例 #6
0
 public bool AddItemToShop(BaseItem item)
 {
     ItemInShop.Add(item);
     return(true);
 }
コード例 #7
0
 private void InitItemInShop(ItemInShop structure)
 {
     //Instantiate(itemInShopPrefab.gameObject, itemContext.parentForObject).GetComponent<ItemInShop>().Init(structure, itemContext, this);
 }