//Convert money to a formated string used alot in UI public static string GetFormatedMoneyText(StdBigNumber money) { int allDigits = money.DigitCount; if (allDigits <= 5) { return(money.ToString()); } else { int left = allDigits % 3; if (left == 0) { left = 3; } string moneyText = ""; for (int i = 0; i < left; i++) { moneyText += money.GetDigit(allDigits - i - 1).ToString(); } moneyText += ","; for (int i = 0; i < 2; i++) { moneyText += money.GetDigit(allDigits - left - i - 1).ToString(); } return(moneyText); } }
public static void SaveMoney(StdBigNumber money) { string path = Path.Combine(Application.persistentDataPath, "money.dat"); using (BinaryWriter writer = new BinaryWriter(File.Create(path))) { string moneyText = money.ToString(); writer.Write(moneyText); writer.Close(); } }