Posted before Ben solution. Might be messy.
public class Hacker : MonoBehaviour
{
int level;
enum Screen { MainMenu, Password, Win};
Screen currentScreen;
// Start is called before the first frame update
void Start()
{
SplashScreen();
ShowMainMenu();
}
void OnUserInput(string input)
{
if(input == "menu")
{
Terminal.ClearScreen();
ShowMainMenu();
}
else if(currentScreen == Screen.MainMenu)
{
RunMainMenu(input);
}
else if (currentScreen == Screen.Password)
{
RunPassword(input);
}
}
private void RunMainMenu(string input)
{
if (input == "1")
{
level = 1;
StartGame(1);
}
else if (input == "2")
{
level = 2;
StartGame(2);
}
else if (input == "3")
{
level = 3;
StartGame(3);
}
else
{
Terminal.WriteLine("Invalid Input");
}
}
void StartGame(int level)
{
currentScreen = Screen.Password;
Terminal.WriteLine("Accessing node " + level);
Terminal.WriteLine("Enter the password: ");
}
private void RunPassword(string input)
{
if (level == 1)
{
CheckPassword(input, "book");
}
else if (level == 2)
{
CheckPassword(input, "oppression");
}
else if (level == 3)
{
CheckPassword(input, "Hermann");
}
}
private void CheckPassword(string input, string passkey)
{
if (input == passkey)
{
Terminal.WriteLine("Processing...");
Terminal.WriteLine("Database Connected");
}
else
{
Terminal.WriteLine("Error. Invalid Password");
Terminal.WriteLine("Enter password");
}
}
void ShowMainMenu()
{
currentScreen = Screen.MainMenu;
Terminal.WriteLine("Total of connected nodes: 3");
Terminal.WriteLine("==============================================================");
Terminal.WriteLine("Please Select Database?");
Terminal.WriteLine("");
Terminal.WriteLine("[1] #ID45789 - Local Library");
Terminal.WriteLine("[2] #ID59666 - Police Station");
Terminal.WriteLine("[3] #ID31415 - NASA");
Terminal.WriteLine("");
Terminal.WriteLine("?:");
}
void SplashScreen()
{
Terminal.WriteLine("### ###### ### ##### ##### @@@@ @@@@ @@@@ @@@@");
Terminal.WriteLine("### ### ### ### ### ## ## ### @ @ @ @ @ @ @ @");
Terminal.WriteLine("### ### ### ### ### #### ### @@@ @ @ @ @ @ @");
Terminal.WriteLine("### ### ### ### ### ## ### @@ @ @ @ @ @ @");
Terminal.WriteLine("###### ###### ### ### @@@@@@ @@@@ @@@@ @@@@");
Terminal.WriteLine("");
Terminal.WriteLine("Terminal WM2000 - Developed by Ben & Rick");
Terminal.WriteLine("==============================================================");
}
}