private void SetDataBuying(IconWithTextController itc, ShopFollower.SellableItem iid) { int price = GetBuyingPrice(iid.Item); string text = $"{iid.Item.GetName()}\n{price} gold each"; itc.SetData(iid.Item, iid.Amount, text, () => ItemClickedBuying(iid)); }
private void ItemClickedBuying(ShopFollower.SellableItem it) { int price = GetBuyingPrice(it.Item); if (GoldAmount.Value < price) { PopUp.SetPopUp("Not Enough Gold.", new[] { ":(", "):" }, new Action[] { () => { }, () => { } }); return; } string title = $"Would you like to buy a {it.Item.GetName()} for {price} gold?\nAmount Left: {it.Amount}\n\n{it.Item.GetDescription()}"; PopUp.SetPopUp(title, new string[] { "Buy All", "Buy 1", "No" }, new Action[] { () => { int amt = 0; while (it.Amount > 0 && GoldAmount >= price) { GoldAmount.Value -= price; Inventory.Add(it.Item, 1); it.Amount -= 1; if (it.Amount == 0) { shopKeep.Items.Remove(it); } amt++; } RefreshBuyingList(); }, () => { GoldAmount.Value -= price; Inventory.Add(it.Item, 1); it.Amount -= 1; if (it.Amount == 0) { shopKeep.Items.Remove(it); } if (it.Amount > 0) { ItemClickedBuying(it); } RefreshBuyingList(); }, () => { RefreshBuyingList(); } }); }