Is this a bad approach?

code
numberOfTries = 0;
switch (level)
{
case 1:
//
password = level1Passwords[Random.Range(0,level1Passwords.Length)];

            break;
        case 2:
            //
            password = level2Passwords[Random.Range(0, level2Passwords.Length)];
            break;

        default:
            Debug.LogError("I dont know that level");
            break;
    }

For demo declaring index is ok, but for less repeats just using the function within less repeats.
Is this a bad approach?

Hi Steve,

Welcome to our community! :slight_smile:

Unfortunately, your code is really hard to read for me because it is not formatted. Apart from that, given I didn’t miss anything, it looks fine to me. :slight_smile:


See also:

Privacy & Terms