Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Hacker : MonoBehaviour
- {
- // Game config
- string[] level1passwords = { "friend", "neighbor", "home", "password", "123", "qwerty" };
- string[] level2passwords = { "police", "law", "squadcar", "sergeant", "tazer", "donut" };
- string[] level3passwords = { "federal", "machinegun", "fbiopenup", "feds", "prison", "trouble" };
- // Game state
- int level;
- int CrackAttempts;
- enum Screen { MainMenu, Password, Win, EasterEgg };
- Screen currentScreen = Screen.MainMenu;
- string password;
- // Start is called before the first frame update
- void Start()
- {
- ShowMainMenu();
- }
- void ShowMainMenu()
- {
- Terminal.ClearScreen();
- Terminal.WriteLine("What would you like to hack into?");
- Terminal.WriteLine(" ");
- Terminal.WriteLine("Press 1 for your neighbors wifi.");
- Terminal.WriteLine("Press 2 for the local police station.");
- Terminal.WriteLine("Press 3 for the FBI.");
- Terminal.WriteLine(" ");
- Terminal.WriteLine("Please enter your selection:");
- currentScreen = Screen.MainMenu;
- }
- void OnUserInput (string input)
- {
- bool isValidLevelNumber = (input == "1" || input == "2" || input == "3");
- if (isValidLevelNumber)
- {
- level = int.Parse(input);
- StartGame();
- }
- else if (input == "Menu")
- {
- ShowMainMenu();
- currentScreen = Screen.MainMenu;
- }
- else if (currentScreen == Screen.Password)
- {
- Password();
- }
- else if (input == "Method0901")
- {
- Terminal.WriteLine("Follow Method0901 on twitch: twitch.tv/METHOD0901");
- currentScreen = Screen.EasterEgg;
- }
- else
- {
- Terminal.WriteLine("Please make a valid selection.");
- }
- void StartGame ()
- {
- Terminal.ClearScreen();
- Terminal.WriteLine("You have chosen level " + level);
- Terminal.WriteLine(" ");
- Terminal.WriteLine("Input 'Menu' or a new level number to");
- Terminal.WriteLine("choose another level.");
- Terminal.WriteLine("Please enter the password: hint: " + password.Anagram());
- currentScreen = Screen.Password;
- switch (level)
- {
- case 1:
- int index1 = Random.Range(0, level1passwords.Length);
- password = level1passwords[index1];
- level = 1;
- break;
- case 2:
- int index2 = Random.Range(0, level2passwords.Length);
- password = level2passwords[index2];
- level = 2;
- break;
- case 3:
- int index3 = Random.Range(0, level3passwords.Length);
- password = level3passwords[index3];
- level = 3;
- break;
- default:
- Debug.LogError("Invalid level number.");
- break;
- }
- }
- void Password()
- {
- if (input == password)
- {
- DisplayWinScreen();
- }
- else
- {
- Terminal.WriteLine(" ");
- Terminal.WriteLine("Password incorrect.");
- CrackAttempts += 1;
- Terminal.WriteLine("Failed cracking attempts: " + CrackAttempts);
- Terminal.WriteLine("Try again:");
- StartGame();
- }
- }
- void DisplayWinScreen()
- {
- currentScreen = Screen.Win;
- Terminal.ClearScreen();
- ShowLevelReward();
- }
- void ShowLevelReward()
- {
- switch (level)
- {
- case 1:
- Terminal.WriteLine("You cracked the level " + level + " password!");
- Terminal.WriteLine(@"
- _______ _______
- | || |
- | ___|| ___|
- | | __ | | __
- | || || || |
- | |_| || |_| |
- |_______||_______|
- ");
- break;
- case 2:
- Terminal.WriteLine("You cracked the level " + level + " password!");
- Terminal.WriteLine(@"
- _______ _______ _______
- | || || |
- | _ || _ || ___|
- | |_| || | | || | __
- | ___|| |_| || || |
- | | | || |_| |
- |___| |_______||_______|
- ");
- break;
- case 3:
- Terminal.WriteLine("You beat the game!!!");
- Terminal.WriteLine(@"
- _______ _______
- | || |
- | ___||____ |
- | |___ ____| |
- | ___|| ______|
- | |___ | |_____
- |_______||_______|
- ");
- break;
- default:
- Debug.LogError("Invalid level reached. How did we get here...");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement