Hey everyone,
So I found a way to keep the variable index:
- Define index outside the Void Functions:
int index;
- Switch statement:
switch (level)
{
case 1:
index = UnityEngine.Random.Range(0, passwordsLevelOne.Length);
password = passwordsLevelOne[index]; // password is one and only one of the array
Terminal.WriteLine("Hint: " + passwordsHintOne[index]); // hint is chosen accordingly to the password
break;
case 2:
index = UnityEngine.Random.Range(0, passwordsLevelTwo.Length);
password = passwordsLevelTwo[UnityEngine.Random.Range(0, passwordsLevelTwo.Length)];
Terminal.WriteLine("Hint: " + passwordsHintThree[index]);
break;
- You need to have an array for your hints that matches the layout of the array for passwords.
I hope this helped and have a nice day