Looking to overlook arguments based on parameters elsewhere in the code. (C#)
For starters, I'm relatively new to coding. That being said, I'm looking to make a key press cycle between sprites for the player character, while excluding sprites that have yet to have their parameters met. Currently, the code I've written uses a conglomerate of 'if, else if' statements to cycle from one to the next, but can only function when each 'else if' is 'true'.
void Start()
{
spriteRenderer = GetComponent<SpriteRenderer>();
if (spriteRenderer.sprite == null)
{
spriteRenderer.sprite = Model1;
modelNumber = 1;
}
}
void ModelSwitch()
{
if (modelNumber == 1 && A == 1)
{
spriteRenderer.sprite = Model2;
modelNumber = 2;
}
else if (modelNumber == 2 && B == 1)
{
spriteRenderer.sprite = Model3;
modelNumber = 3;
}
else if (modelNumber == 3 && C == 1)
{
spriteRenderer.sprite = Model4;
modelNumber = 4;
}
The models and what-not (as well as the ModelSwitch()) are defined properly elsewhere and cause no issues (I just see no reason in posting the excess code).
I'm looking to make it so that if the initial if statement returns false, that it will skip to the next available true statement. I.e. if modelNumber == 1 and A == 0 and B == 0, but C == 1, it skips to Model4. I'm positive there's an easy way of doing this without a wall of 'if, else if / &&, ||' statements, yet I lack the know-how to appropriately discern said 'easy way'.