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); } }); }
public void AddNewItem(ItemInShop structure) { items.Add(structure); InitItemInShop(structure); ShopChange.Invoke(); }
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); } }
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(); } }
public bool RemoveItemFromShop(BaseItem item) { ItemInShop.Remove(item); return(true); }
public bool AddItemToShop(BaseItem item) { ItemInShop.Add(item); return(true); }
private void InitItemInShop(ItemInShop structure) { //Instantiate(itemInShopPrefab.gameObject, itemContext.parentForObject).GetComponent<ItemInShop>().Init(structure, itemContext, this); }