void UpdateInfo() { int diff = ammoItem.MaxAmount - ammoItem.CurrentAmount; if (diff > ammoItem.AmountToBuy) { diff = ammoItem.AmountToBuy; } int diffAll = ammoItem.MaxAmount - ammoItem.CurrentAmount; buyText.text = GetBuyText(diff); buyAllText.text = GetBuyAllText(diffAll); priceText.text = MoneyFormatter.FormatMoney(shop.GetAmmoPrice(ammoItem, diff)); priceAllText.text = MoneyFormatter.FormatMoney(shop.GetAmmoPrice(ammoItem, diffAll)); currentAmountText.text = GetAmountText(ammoItem.CurrentAmount, ammoItem.MaxAmount); SetAmountPercentage((float)ammoItem.CurrentAmount / ammoItem.MaxAmount); buyButton.interactable = diff != 0 && shop.EnoughMoneyToBuy(ammoItem, diff); buyAllButton.interactable = diffAll != 0 && shop.EnoughMoneyToBuy(ammoItem, diffAll); }
string GetRepairText(int price) { if (repairTranslation == null) { repairTranslation = repairText.GetComponent <TranslatedText>(); } string translated; try { translated = repairTranslation.GetValue(); } catch { translated = "Repair {0}"; } return(string.Format(translated, MoneyFormatter.FormatMoney(price))); }
string GetBuyText(int price) { if (buyTranslation == null) { buyTranslation = buyText.GetComponent <TranslatedText>(); } string translated; try { translated = buyTranslation.GetValue(); } catch { translated = "Buy {0}"; } return(string.Format(translated, MoneyFormatter.FormatMoney(price))); }
void SetMoneyAmount(int amount) { moneyAmountText.text = MoneyFormatter.FormatMoney(amount); }