Here's something I tried, declared index and updated it in every case

void StartGame()
{
int index;
currentScreen = Screen.Password;
Terminal.ClearScreen();
switch(level)
{
case 1:
index = Random.Range(0, level1Passwords.Length);
password = level1Passwords[index];
break;

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

        case 3:
            index = Random.Range(0, level3Passwords.Length);
            password = level3Passwords[index];
            break;

        default:
            Debug.LogError("invalid level number");
            break;
    }
    Terminal.WriteLine("Please enter password for level " + level);

}
1 Like

Great looking code! :fire:

Privacy & Terms