Thought I’d leave this so you can compare it and see my mistakes! At least I now know i need more experience in variables
public class Hacker : MonoBehaviour
{
// Game State
int Level;
enum Screen { MainMenu, Password, PasswordTwo, Win };
Screen currentScreen;
// Start is called before the first frame update
void Start()
{
ShowMainMenu();
}
void ShowMainMenu()
{
currentScreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine("1. Hack Computers around Your Location");
Terminal.WriteLine("2. Hack Computers Overseas");
Terminal.WriteLine("3. Hack Central Processing Unit");
Terminal.WriteLine("Enter your selection now: ");
}
void ShowWinScreen()
{
currentScreen = Screen.Win;
Terminal.ClearScreen();
Terminal.WriteLine("YOU WIN! :)");
Terminal.WriteLine("Return to menu?");
}
void OnUserInput(string Input)
{
if (Input == "menu")
{
ShowMainMenu();
}
else if (currentScreen == Screen.MainMenu)
{
RunMainMenu(Input);
}
else if (currentScreen == Screen.Password)
{
RunPasswordOne(Input);
}
else if (currentScreen == Screen.PasswordTwo)
{
RunPasswordTwo(Input);
}
else if (currentScreen == Screen.Win)
{
RunWin(Input);
}
}
void RunPasswordOne(string Input)
{
if (Input == "Carrot")
{
Terminal.WriteLine("Password Is Correct!");
ShowWinScreen();
}
else if (Input == "menu")
{
ShowMainMenu();
}
else
{
Terminal.WriteLine("Password Is Incorrect");
}
}
void RunPasswordTwo(string Input)
{
if (Input == "Escape")
{
Terminal.WriteLine("Password Is Correct!");
ShowWinScreen();
}
else if (Input == "menu")
{
ShowMainMenu();
}
else
{
Terminal.WriteLine("Password Is Incorrect");
}
}
void RunWin(string Input)
{
if (Input == "return")
{
ShowMainMenu();
}
}
void RunMainMenu(string Input)
{
if (Input == "dog")
{
Terminal.WriteLine("Woof!");
}
else if (Input == "1")
{
Level = 1;
StartLevelOne();
}
else if (Input == "2")
{
Level = 2;
StartLevelTwo();
}
else
{
Terminal.WriteLine("Please select a valid level");
}
}
void StartLevelOne()
{
currentScreen = Screen.Password;
Terminal.WriteLine("You have selected level " + Level);
Terminal.WriteLine("Please enter your password: ");
}
void StartLevelTwo()
{
currentScreen = Screen.PasswordTwo;
Terminal.WriteLine("You have selected level " + Level);
Terminal.WriteLine("Please enter your password: ");
}
}