- Home /
Question by
Pim0ush · Nov 09, 2017 at 02:26 PM ·
scripting problemscript.scriptingbasicshuge
How 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 boar for exemple ).
Comment
Your answer
Follow this Question
Related Questions
how can I change a light with multiple triggers. ? 0 Answers
How to lock an int as a playerPref? 1 Answer
How do you use enemies to kill the player? 0 Answers
Spawn A prefab after death 3 Answers
Trying to find the highest number than add it to itself. 2 Answers