Help me replace tons of "if" on the adequate code.
Hello. This is my code:
GameObject newPowerup = thePowerupPools[Random.Range(0, 3)].GetPooledObject ();
if (thePowerManager.safeMode == true && newPowerup.name.Contains ("SafeBoost"))
{
newPowerup.SetActive (false);
}
if (thePowerManager.doublePoints == true && newPowerup.name.Contains ("ScoreBoost"))
{
newPowerup.SetActive (false);
}
if (thePowerManager.speedMode == true && newPowerup.name.Contains ("SpeedBoost")) {
newPowerup.SetActive (false);
}
Well, if i doesnt want to activate this object, its pretty easy, but if i want SetActive (true);, i need tons of "if". For example:
if (thePowerManager.speedMode == false && thePowerManager.safeMode == true && thePowerManager.doublePoints == true && !newPowerup.name.Contains ("SafeBoost") && !newPowerup.name.Contains ("ScoreBoost")){
newPowerup.SetActive (true);
}
And same from the each position. And then the same from the each position when 2 false an 1 true.
Can you advise me another way to do this stuff, please?
Comment
Your answer