I think there should have some other way (e.g create a function with passing arguments?) to make the following code more efficiency. But I can not figure out how to do that. Here are my code example:
if (money >= weaponA_LV1Cost)
{
Instantiate (weaponA_LV1, buildPos, Quaternion.identity);
money = money - weaponA_LV1Cost;
}
if (money >= weaponB_LV1Cost)
{
Instantiate (weaponB_LV1, buildPos, Quaternion.identity);
money = money - weaponB_LV1Cost;
}
if (money >= weaponC_LV1Cost)
{
Instantiate (weaponC_LV1, buildPos, Quaternion.identity);
money = money - weaponC_LV1Cost;
}