//Game State
int level;
enum Screen {MainMenu, Password, Win };
Screen currentscreen;
string userpassword;
string[] level1words = { "tape", "pilot", "roof", "books", "school" };
string[] level2words = { "butter", "power", "patrick", "finale", "sunday" };
string[] level3words = { "popcorn", "jelly", "mike", "porch", "automobile" };
// Use this for initialization
void Start() {
currentscreen = Screen.MainMenu;
ShowMainMenu("Kevin");
}
void ShowMainMenu (string User)
{
currentscreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine("Hello " + User);
Terminal.WriteLine("What would you like hack into?");
Terminal.WriteLine("Press 1 for the local library");
Terminal.WriteLine("Press 2 for the local police office");
Terminal.WriteLine("Press 3 for the Pentagon");
Terminal.WriteLine("Enter your selection:");
}
void OnUserInput (string input)
{
if(input == "menu")
{
print("the user typed " + input);
level = 0;
ShowMainMenu("Kevin");
}
else if(currentscreen == Screen.MainMenu)
{
RunMainMenu(input);
}
else if(currentscreen == Screen.Password)
{
ConfirmPassword(input);
}
}
void RunMainMenu(string input)
{
bool isValidLevelNumber = (input == "1" || input == "2" || input == "3");
if (isValidLevelNumber)
{
level = int.Parse(input);
StartGame();
}
else if (input == "420")
{
print("the user typed " + input);
currentscreen = Screen.Win;
Terminal.WriteLine("the dude abides");
}
else
{
print("the user typed " + input);
Terminal.WriteLine("1.. 2.. or 3.. this isn't hard");
}
}
void StartGame()
{
print("the user typed " + level);
Terminal.ClearScreen();
switch (level)
{
case 1:
userpassword = level1words[new Random().Next(level1words.Length)];
break;
case 2:
userpassword = level2words[new Random().Next(level1words.Length)];
break;
case 3:
userpassword = level3words[new Random().Next(level1words.Length)];
break;
}
Terminal.WriteLine("please enter your password");
}
private void ConfirmPassword(string input)
{
if (input == userpassword)
{
currentscreen = Screen.Win;
Terminal.WriteLine("Thank you");
}
else
{
Terminal.WriteLine("Please Try Again");
}
}