Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Hacker : MonoBehaviour {
- // Game Configuration Data
- const string menuHint = "You may type menu at any time.";
- string[] level1Passwords = { "books", "aisle", "shelf", "password", "font", "borrow" };
- string[] level2Passwords = { "worm", "duck", "frog", "Roxas", "cheese", "horny" };
- string[] level3Passwords = { "labyrinth", "flamingo", "hippo", "jackelope", "santa" };
- //Game State
- int level;
- string password;
- string password2;
- string password3;
- enum Screen { MainMenu, Password, Win };
- Screen currentScreen;
- // Use this for initialization
- void Start()
- {
- ShowMainMenu();
- }
- void ShowMainMenu()
- {
- currentScreen = Screen.MainMenu;
- Terminal.ClearScreen();
- Terminal.WriteLine("Greetings - Time to fuck shit up.");
- Terminal.WriteLine("What you wanna hack into?");
- Terminal.WriteLine("Press 1 for the local library");
- Terminal.WriteLine("Press 2 for the police station");
- Terminal.WriteLine("Press 3 for NASA");
- Terminal.WriteLine("Enter your selection:");
- }
- void OnUserInput(string input)
- {
- if (input == "menu") // we can always go direct to main menu
- {
- Terminal.ClearScreen();
- ShowMainMenu();
- }
- else if (input == "quit" || input == "close" || input == "exit")
- {
- Terminal.WriteLine("If on the web close the tab.");
- Application.Quit();
- }
- else if (currentScreen == Screen.MainMenu)
- {
- RunMainMenu(input);
- }
- else if (currentScreen == Screen.Password)
- {
- CheckPassword(input);
- }
- }
- void RunMainMenu(string input)
- {
- bool isValidLevelNumber = (input == "1" || input == "2" || input == "3");
- if (isValidLevelNumber)
- {
- level = int.Parse(input);
- AskForPassword();
- }
- else if (input == "marco") // easter egg
- {
- Terminal.WriteLine("Polo!");
- }
- else if (input == "007") // easter egg
- {
- Terminal.WriteLine("Welcome home, Mr. Bond.");
- }
- else
- {
- Terminal.WriteLine("Choose a valid level!");
- Terminal.WriteLine(menuHint);
- }
- }
- void AskForPassword()
- {
- currentScreen = Screen.Password;
- Terminal.ClearScreen();
- SetRandomPassword();
- Terminal.WriteLine("Enter your password, hint: " + password.Anagram());
- Terminal.WriteLine(menuHint);
- }
- void SetRandomPassword()
- {
- switch (level)
- {
- case 1:
- password = level1Passwords[Random.Range(0, level1Passwords.Length)];
- break;
- case 2:
- password = level2Passwords[Random.Range(0, level2Passwords.Length)];
- password2 = level2Passwords[Random.Range(0, level2Passwords.Length)];
- break;
- case 3:
- password = level3Passwords[Random.Range(0, level3Passwords.Length)];
- password2 = level3Passwords[Random.Range(0, level3Passwords.Length)];
- password3 = level3Passwords[Random.Range(0, level3Passwords.Length)];
- break;
- default:
- Debug.LogError("Invalid level number");
- break;
- }
- }
- void CheckPassword(string input)
- {
- if (input == "1")
- {
- if (input == password)
- {
- DisplayWinScreen();
- }
- else
- {
- AskForPassword();
- }
- }
- else if (input == "2")
- {
- if (input == password)
- {
- Terminal.WriteLine("Now for the second password. Hint: " + password2.Anagram());
- if (input == password2)
- {
- DisplayWinScreen();
- }
- else
- {
- AskForPassword();
- }
- }
- }
- else if (input == "3")
- {
- if (input == password)
- {
- Terminal.WriteLine("Now for the second password. Hint: " + password2.Anagram());
- if (input == password2)
- {
- Terminal.WriteLine("Now for the third password. Hint: " + password3.Anagram());
- if (input == password3)
- {
- DisplayWinScreen();
- }
- else
- {
- AskForPassword();
- }
- }
- }
- }
- }
- void DisplayWinScreen()
- {
- currentScreen = Screen.Win;
- Terminal.ClearScreen();
- ShowLevelReward();
- Terminal.WriteLine(menuHint);
- }
- void ShowLevelReward()
- {
- switch (level)
- {
- case 1:
- Terminal.WriteLine("Have a book...");
- Terminal.WriteLine(@"
- ______
- / //
- / //
- /_____ //
- (______(/
- "
- );
- Terminal.WriteLine("Play again for a greater challenge.");
- break;
- case 2:
- Terminal.WriteLine("Have a lockpick!");
- Terminal.WriteLine("Play again for a greater challenge.");
- Terminal.WriteLine(@"
- "
- );
- break;
- case 3:
- Terminal.WriteLine("Have a space ship!");
- Terminal.WriteLine(@"
- ^
- / \
- | _ |
- | { } |
- | omo |
- <| |>
- < >
- "
- );
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement