Hello,
First issue - I’m trying to use the same script below for the Policeman and Fireman objects. For the Policeman works fine, but when I hire Fireman the salary from the Fireman doesn’t add to the total negative income up in the right corner. i don’t get any errors so I can’t tell if it’s a conflict somewhere. The second issue is that I have set a maximum of 5 hired, but if I press to hire more (even if I know it won’t) it resets the amount of negative income that increased to the time I press the hire button again. So I hire 5, the negative income goes -650, -651, -652, etc. and if I press the hire button it goes back to -650.
Thank you
public class IncrementPlusOne : MonoBehaviour
{
public TMP_Text PolicemanHiredNumberText;
public int hired;
public TMP_Text salaryText;
public TMP_Text totalSalaryText;
public float salaryAmount;
public float salaryPerSecond;
public int totalSalaryPerSecond;
public float totalSalaryAmount;
public void Start()
{
salaryAmount = -130f;
salaryPerSecond = 1f;
}
public void Update()
{
PolicemanHiredNumberText.text = hired + "";
salaryText.text = (int)totalSalaryAmount + "";
totalSalaryText.text = -(hired * salaryAmount) + "";
totalSalaryPerSecond = (int)(salaryPerSecond * hired);
totalSalaryAmount -= totalSalaryPerSecond * Time.deltaTime;
}
public void Hireworkers()
{
if (hired < 5) { hired++; }
totalSalaryAmount = (int)(salaryAmount * hired);
}
}