/// <summary> /// Change the item index and update the ui to show the current buy item. /// </summary> private void UpdateBuyItem(ChangeIndex changeIndex) { buyItemIndex = changeIndex(buyItemIndex, currentTrader.itemsForSale.Count); Item itemToShow = currentTrader.itemsForSale[buyItemIndex].item; buyItem.SetItemAndImage(itemToShow, TextureDatabase.instance.LoadTexture(itemToShow.Sprite)); buyTitleText.text = itemToShow.Title; buyItemCost.text = itemToShow.Value.ToString(); }
/// <summary> /// Change the item index and update the sell item to show the current sell item. /// </summary> private void UpdateSellItem(ChangeIndex changeIndex) { List <ItemSlot> slots = InventoryManager.instance.slots; // Search for the next slot that has an item, and show that item int counter = 0; do { sellItemIndex = changeIndex(sellItemIndex, slots.Count); counter++; if (counter > slots.Count) { noItemsToSell.SetActive(true); return; } } while (slots[sellItemIndex].itemStack == null); noItemsToSell.SetActive(false); ItemStack itemStack = slots[sellItemIndex].itemStack; sellItem.SetItemAndImage(itemStack.item, TextureDatabase.instance.LoadTexture(itemStack.item.Sprite)); sellTitleText.text = itemStack.item.Title; sellStackAmount.text = itemStack.amount == 1 ? "" : itemStack.amount.ToString(); sellItemCost.text = itemStack.item.Value.ToString(); }
public IndexLayout(ILayoutable instance) { _layoutable = instance; _index = instance?.LayoutIndex ?? new ChangeIndex(); }
/// <summary> Updates <see cref="LayoutIndex"/> to the next value. </summary> public void MarkLayoutChanged() { _layoutIndex = _layoutIndex.Next(); }