I am currently having trouble with game state, being level and crrentScreen. I have the code written out but it doesn’t update in the debug inspector. level remains at 0 and currentScreen at MainMenu, user input has no effect on these.
public class Hacker : MonoBehaviour
{
//Game state
int level;
enum Screen { MainMenu, Password, Win };
Screen currentScreen = Screen.MainMenu;
void Start() //Use this for initialization.
{
ShowMainMenu();
}
void ShowMainMenu()
{
Terminal.ClearScreen();
Terminal.WriteLine("What would you like to hack into?");
Terminal.WriteLine("Press 1 for the local library");
Terminal.WriteLine("Press 2 for the police station");
Terminal.WriteLine("Press 3 for the military base");
Terminal.WriteLine("Enter your selection: ");
}
void OnUserInput(string input)
{
Terminal.ClearScreen();
if (input == "1")
{
level = 1;
StartGame();
}
else if (input == "2")
{
level = 2;
StartGame();
}
else if (input == "Xendalta")
{
Terminal.WriteLine("An honor, lord arbiter!");
}
else if (input == "menu")
{
ShowMainMenu();
}
else
{
Terminal.WriteLine("Please enter a valid level.");
}
}
void StartGame()
{
currentScreen = Screen.Password;
Terminal.WriteLine("You have chosen level " + level);
}
}
Please inform me if and where I went wrong in this.