Question by
kyco4ekmyaska · Oct 06, 2017 at 07:31 AM ·
c#upgrademoneysystem
Takes money for the next purchase and not for this one
Takes money for the next purchase and not for this one
public class upgrades : MonoBehaviour {
public Button Button_cpu;
public Button Button_gpu;
public Text gpu_text;
public Text cpu_text;
public int[] price_cpu;
public int[] price_gpu;
private int cur_price_cpu;
private int cur_price_gpu;
public int multiplication_cpu;
public int multiplication_gpu;
public void Update()
{
cpu_text.text = "upgrade cpu " + price_cpu[cur_price_cpu] + " $";
gpu_text.text = "upgrade gpu " + price_gpu[cur_price_gpu] + " $";
}
public void Upgrade_CPU()
{
if (stream.Money >= price_cpu[cur_price_cpu])
{
cur_price_cpu++;
stream.Money = stream.Money - price_cpu[cur_price_cpu]; // if price - 10, next price 500 - takes 500,not 10.
stream.Income += multiplication_cpu/10;
}
}
public void Upgrade_GPU()
{
if (stream.Money >= price_gpu[cur_price_gpu])
{
cur_price_gpu++;
stream.Money = stream.Money - price_gpu[cur_price_gpu]; //Takes money for the next purchase and not for this one
stream.Income += multiplication_gpu/10;
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612140401im_/https://answers.unity.com/themes/thub/images/avi.jpg)