Beispiel #1
0
        /// @param cost
        ///     The cost to display
        ///
        /// @return The formatted cost string
        ///
        public static string LocaliseColouredCost(this CurrencyItem cost)
        {
            if (m_cachedBankService == null)
            {
                m_cachedBankService = GlobalDirector.Service <BankService>();
            }

            string costString = string.Empty;

            if (k_currencies.Contains(cost.m_currencyID) == true)
            {
                costString = cost.LocaliseCost();
            }
            else
            {
                if (cost.IsFree() == true)
                {
                    costString = k_free.LocaliseGame();
                }
                else
                {
                    int    current       = Math.Min(m_cachedBankService.GetBalance(cost.m_currencyID), cost.m_value);
                    string currentString = TextUtils.GetFormattedCurrencyString(current);
                    string formatID      = k_costFail;
                    if (m_cachedBankService.CanAfford(cost) == true)
                    {
                        formatID = k_costSuccess;
                    }
                    costString = string.Format(formatID.LocaliseGame(), cost.m_currencyID, TextUtils.GetFormattedCurrencyString(cost.m_value), currentString);
                }
            }
            return(costString);
        }