I am trying to make a game with untiy and c# which is about numbers.
However i need metric prefixes for huge numbers (kilo,mega,giga etc)
i did something like this till now:
normal += 9;
if(normal >= 999)
{
normal = 0;
kilo += 1;
}
if(kilo >= 999)
{
kilo = 0;
mega += 1;
}
but i faced a problem that when the numbers go 981 990 999 the normal number reset instead of being 1008
also how can i do calculation on prefixes?
edit#1:
i have to objects (in unity) when i click on object "ASDASD" i get money and when i click on Object "QQQ" i buy something
this code is for ASDASD
public float normal;
public float kilo;
public float mega;
public float x;
public GUIText Displayer;
void Start ()
{
}
void OnMouseDown ()
{
if (gameObject.name=="ASDASD")
{
normal =normal + 90000;
if(normal > 99999)
{
x=normal-100000;
normal = 0;
kilo = kilo + 1 + x/100000f;
}
}
}
void Update ()
{
if (kilo==0)
Displayer.text = "" + normal.ToString("n0");
else if (kilo >=1)
Displayer.text="" + (kilo*100+normal/1000).ToString("n0") + "K";
}
}
now how can i do the second object code ? (buy something)