Question by
Pim0ush · Nov 20, 2017 at 07:27 AM ·
scripting problemscript.scriptingbasics
Need help to reduce my script
Hi. Here is the part of my script I want to reduce ( "variables_et_saves" is another script with all varibles in static ) :
public class gain : MonoBehaviour {
void Update ()
{
if (variables_et_saves.money >= 1000) {
variables_et_saves.j = 1;
variables_et_saves.BankLoan = variables_et_saves.BankLoan1;
variables_et_saves.RentPerMonth = variables_et_saves.RentPerMonth1;
variables_et_saves.BankMultiplier = variables_et_saves.BankMultiplier1_2;
}
IEnumerator TimerGame ()
{
yield return new WaitForSeconds (1);
variables_et_saves.TimerD = variables_et_saves.TimerD + 1;
if (variables_et_saves.TimerD == 7) {
variables_et_saves.TimerW = variables_et_saves.TimerW + 1;
variables_et_saves.TimerD = 0;
}
if ((variables_et_saves.TimerW == 4) && (variables_et_saves.TimerD == 7)) {
variables_et_saves.TimerM = variables_et_saves.TimerM + 1;
variables_et_saves.TimerW = 0;
// Bank Loan
if (variables_et_saves.Bank == 1) {
if (variables_et_saves.TimerM = variables_et_saves.TimerM + 1) {
variables_et_saves.money = variables_et_saves.money - variables_et_saves.RentPerMonth;
variables_et_saves.Rent = variables_et_saves.Rent + variables_et_saves.RentPerMonth;
if (variables_et_saves.Rent >= variables_et_saves.BankLoan + variables_et_saves.BankMultiplier)
if (variables_et_saves.BankLoan == variables_et_saves.BankLoan1) {
variables_et_saves.BankLoan = variables_et_saves.BankLoan2;
variables_et_saves.RentPerMonth = variables_et_saves.RentPerMonth2;
variables_et_saves.Bank = 0;
} else if (variables_et_saves.BankLoan == variables_et_saves.BankLoan2) {
variables_et_saves.BankLoan = variables_et_saves.BankLoan3;
variables_et_saves.BankMultiplier = variables_et_saves.BankMultiplier3;
variables_et_saves.RentPerMonth = variables_et_saves.RentPerMonth3;
variables_et_saves.Bank = 0;
} else if (variables_et_saves.BankLoan == variables_et_saves.BankLoan3) {
variables_et_saves.BankLoan = variables_et_saves.BankLoan4;
variables_et_saves.BankMultiplier = variables_et_saves.BankMultiplier4;
variables_et_saves.RentPerMonth = variables_et_saves.RentPerMonth4;
variables_et_saves.Bank = 0;
} else if (variables_et_saves.BankLoan == variables_et_saves.BankLoan4) {
variables_et_saves.BankLoan = variables_et_saves.BankLoan5;
variables_et_saves.BankMultiplier = variables_et_saves.BankMultiplier5;
variables_et_saves.RentPerMonth = variables_et_saves.RentPerMonth5;
variables_et_saves.Bank = 0;
} else {
variables_et_saves.Bank = 0;
}
}
}
}
if ((variables_et_saves.TimerM == 12) && (variables_et_saves.TimerW == 4) && (variables_et_saves.TimerD == 7)) {
variables_et_saves.TimerY = variables_et_saves.TimerY + 1;
variables_et_saves.money = variables_et_saves.money - variables_et_saves.YearlyMoney;
variables_et_saves.TimerM = 0;
}
}
}
The //BankLoanPart is huge and cost me a lot a of varables, i would want to know if there is a way to reduce that ( like with board for exemple ).
Comment