2
             public Text TimesText;
             public bool WonPanel = false;
             public int muliplyer = 0;
             public bool DoMulti = false;

             if(JsonData.won == 3){
                TimesText.text = JsonData.won + "x";
                muliplyer = 3;
                DoMulti = true;
            }else if(JsonData.won == 2){
                TimesText.text = JsonData.won + "x";
                muliplyer = 2;
                DoMulti = true;
            }else{
                string newMoney = string.Empty;
                int val;

                for(int x = 0; x < MoneyText.text.Length; x++){
                    if(Char.IsDigit(MoneyText.text[x])){
                                newMoney += MoneyText.text[x];
                        }
                }
                if(newMoney.Length > 0){
                    val = int.Parse(newMoney);
                }else{
                        val = 0;
                }
                if(DoMulti){
                    int MultiMoneyAmount = val + (JsonData.won * muliplyer);
                    MoneyText.text = MultiMoneyAmount.ToString();
                    DoMulti = false;
                    TimesText.text = "0x";
                }else{
                    int NewMoneyAmount = val + JsonData.won;
                    MoneyText.text = NewMoneyAmount.ToString();
                    DoMulti = false;
                    TimesText.text = "0x";
                }

This is probably not the best way to do it but the JsonData.won is received from my server and it is what the client has the opportunity to win. Right now everything works fine. They only problem I am running into is that the MoneyText.Text which is how much in total the player has won, displays "15" or "20" when I want it to display "$0.15" and "$0.20". Now I can make that happen but when they earn over a dollar that is where I am confused. 100 would equal to $1.00.

Cory Sparks
  • 235
  • 1
  • 2
  • 13

1 Answers1

2

Parse it as a decimal then divide by 100(or whatever fraction is appropriate). Then for display purposes you can add whatever currency symbols, thousands separators, etc. that you want.

CheeZe5
  • 975
  • 1
  • 8
  • 24