Hello, I am trying to make a shop sysem for my game. I am stuck with these lines of code. I want to make a button to buy something but after I bought, I don’t want to buy it again. How can I do that with these code? I think that I should use boolean but I couldn’t. By the way, index is coming from which rocket has choosed. Thank you for your help.
public void BuyButton()
{
switch (index)
{
case 0:
if (//Item has not sold)
{
moneyAmount -= firstMoneyOfRocket;
PlayerPrefs.SetFloat("Cash", moneyAmount);
}
else if (//Item sold)
{
Debug.Log("You already bought this item.");
}
break;
case 1:
if(//Item hasnt sold)
{
moneyAmount -= secondMoneyOfRocket;
PlayerPrefs.SetFloat("Cash", moneyAmount);
}
else if (//ItemSold)
{
Debug.Log("You already bought this item.");
}
break;
}
}