public void SetShopMode(ItemShopMode shopMode) { foreach (var itemView in itemViews.ItemViews) { ItemAmountView amountView = itemView.GetComponent <ItemAmountView>(); if (amountView != null) { amountView.clampToItemAmount = shopMode == ItemShopMode.Selling; } } actionText.text = shopMode == ItemShopMode.Buying ? "Buy" : "Sell"; }
public void SetItemViews(List <ItemRef> items, EquippedDelegate isEquippedCallback) { itemViews.Clear(); int maxIndex = Mathf.Min(items.Count, itemViews.GetCount()); for (int index = 0; index < maxIndex; ++index) { itemViews.SetItem(index, items[index], isEquippedCallback(items[index].ReferencedItem)); ItemAmountView amountView = itemViews.ItemViews[index].GetComponent <ItemAmountView>(); if (amountView != null) { amountView.Clear(); } } }
public List <ItemRef> GetShopItems() { List <ItemRef> shopItems = new List <ItemRef>(); foreach (var itemView in itemViews.ItemViews) { ItemAmountView amountView = itemView.GetComponent <ItemAmountView>(); int amount = amountView != null ? amountView.Amount : 0; if (amount > 0) { shopItems.Add(new ItemRef(itemView.TargetItem.ReferencedItem, amount)); } } return(shopItems); }
public void Init(UnityAction <ItemShopMode> setShopMode, UnityAction <ItemRef> selectItemCallback, UnityAction <int> selectPageCallback, UnityAction setCostCallback) { itemViews = new ItemViewList(itemViewHolder.GetComponentsInChildren <ItemViewUI>(), selectItemCallback); pageView.SetSelectPageCallback(selectPageCallback); foreach (var itemView in itemViews.ItemViews) { ItemAmountView amountView = itemView.GetComponent <ItemAmountView>(); if (amountView) { amountView.UpdateAmountAction += setCostCallback; } } ShopModeButtonUI[] shopModeButtons = shopModeHolder.GetComponentsInChildren <ShopModeButtonUI>(); foreach (var button in shopModeButtons) { button.SelectShopModeAction += setShopMode; } }