Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //using System;
- using System.Collections;
- using UnityEngine;
- using UnityEngine.UI;
- public class Hacker : MonoBehaviour
- {
- string[] level1Passwords = { "book", "books", "student", "students", "learning", "teacher", "teachers", "degree", "degrees", "learn", "class", "classes" };
- string[] level2Passwords = { "money", "banker", "bankers", "power", "suit", "suits", "paper", "debt", "loan", "safe", "cash", "evil", "credit" };
- string[] level3Passwords = { "conspiracy", "secret", "secrets", "service", "services", "surveillance", "mission", "missions", "crime", "villain", "alien", "aliens" };
- string[] level1Gamewords = { "knowledge", "master", "professor" };
- string[] level2Gamewords = { "society", "credit card", "commercial" };
- string[] level3Gamewords = { "extraterrestial", "secret service", "conspiracy theory" };
- int level;
- float currentCountdownVal;
- int tryCounter = 0;
- string password;
- string gameword1;
- string gameword2;
- string gameword3;
- enum Screen { MainMenu, Password, Level, Win, GameOver }
- Screen currentScreen;
- void Start()
- {
- ShowMainMenu();
- }
- void ShowMainMenu()
- {
- currentScreen = Screen.MainMenu;
- Terminal.WriteLine("What would you like to hack?\n");
- StartCoroutine(MainMenuExecution(1.0f));
- }
- void Update()
- {
- }
- IEnumerator MainMenuExecution(float time)
- {
- yield return new WaitForSeconds(time);
- Terminal.WriteLine("Enter 'university',\nto hack into the local university\n");
- yield return new WaitForSeconds(time);
- Terminal.WriteLine("Enter 'national bank',\nto hack into the national bank\n");
- yield return new WaitForSeconds(time);
- Terminal.WriteLine("Enter 'Federal Bureau of Intelligence',\nto hack into the FBI\n");
- yield return new WaitForSeconds(time);
- Terminal.WriteLine("Enter your selection:");
- }
- void OnUserInput(string input)
- {
- if (input == "menu")
- {
- Terminal.ClearScreen();
- ShowMainMenu();
- }
- else if (currentScreen == Screen.MainMenu)
- {
- RunMainMenu(input);
- }
- else if (currentScreen == Screen.Password)
- {
- CheckPassword(input);
- }
- else if (currentScreen == Screen.Level)
- {
- LevelInput(input);
- }
- else if (currentScreen == Screen.GameOver)
- {
- RestartOrExit(input);
- }
- }
- void RunMainMenu(string input)
- {
- switch (input)
- {
- case "university":
- level = 1;
- SelectingPassword();
- break;
- case "national bank":
- level = 2;
- SelectingPassword();
- break;
- case "Federal Bureau of Intelligence":
- case "federal bureau of intelligence":
- level = 3;
- SelectingPassword();
- break;
- case "your selection":
- Terminal.WriteLine("\nHA. You're really funny.");
- break;
- default:
- Terminal.WriteLine("\nNot a valid input. Please try again:");
- break;
- }
- }
- void SelectingPassword()
- {
- currentScreen = Screen.Password;
- Terminal.ClearScreen();
- switch (level)
- {
- case 1:
- SetRandomPassword();
- Terminal.WriteLine("You chose the university. This will be easy.\n");
- Terminal.WriteLine("*Selecting random password*\n(Hint: Words that fit to university.)");
- Terminal.WriteLine("Please enter the password: ");
- break;
- case 2:
- SetRandomPassword();
- Terminal.WriteLine("This bank is pretty secure. Good Luck.\n");
- Terminal.WriteLine("*Selecting random password*\n(Hint: Words that fit to national bank.)");
- Terminal.WriteLine("Please enter the password: ");
- break;
- case 3:
- SetRandomPassword();
- Terminal.WriteLine("The FBI is unhackable. Or is it?\n");
- Terminal.WriteLine("*Selecting random password*\n(Hint: Words that fit to the FBI.)");
- Terminal.WriteLine("Please enter the password: ");
- break;
- default:
- Terminal.WriteLine("No level selected. How did this happen?");
- Terminal.WriteLine("Restarting game...");
- ShowMainMenu();
- break;
- }
- }
- void SetRandomPassword()
- {
- switch (level)
- {
- case 1:
- password = level1Passwords[Random.Range(0, level1Passwords.Length)];
- break;
- case 2:
- password = level2Passwords[Random.Range(0, level2Passwords.Length)];
- break;
- case 3:
- password = level3Passwords[Random.Range(0, level3Passwords.Length)];
- break;
- default:
- Terminal.WriteLine("No level selected. How did this happen?");
- Terminal.WriteLine("Restarting game...");
- ShowMainMenu();
- break;
- }
- }
- void CheckPassword(string input)
- {
- if (input == password)
- {
- Terminal.WriteLine("Starting level..");
- switch (level)
- {
- case 1:
- StartCoroutine(StartLevelExecution(120));
- break;
- case 2:
- StartCoroutine(StartLevelExecution(90));
- break;
- case 3:
- StartCoroutine(StartLevelExecution(60));
- break;
- default:
- Terminal.WriteLine("No level selected. How did this happen?");
- Terminal.WriteLine("Restarting game...");
- ShowMainMenu();
- break;
- }
- }
- else
- {
- Terminal.WriteLine("Sorry wrong password. Try again:");
- tryCounter++;
- if (tryCounter == 5)
- {
- Terminal.WriteLine("You already took " + tryCounter + " tries.");
- }
- else if (tryCounter >= 5 && tryCounter <= 10)
- {
- switch (level)
- {
- case 1:
- Terminal.WriteLine("Hint: Words that fit to university");
- break;
- case 2:
- Terminal.WriteLine("Hint: Words that fit to national bank");
- break;
- case 3:
- Terminal.WriteLine("Hint: Words that fit to the FBI");
- break;
- default:
- Terminal.WriteLine("No level selected. How did this happen?");
- Terminal.WriteLine("Restarting game...");
- ShowMainMenu();
- break;
- }
- if (tryCounter == 10)
- {
- ShowPasswordHelp();
- }
- }
- }
- }
- void ShowPasswordHelp()
- {
- Terminal.ClearScreen();
- Terminal.WriteLine("You already took 10 tries.");
- Terminal.WriteLine("Here is some help for you.");
- switch (level)
- {
- case 1:
- Terminal.WriteLine("Words that fit:");
- foreach(string password in level1Passwords)
- {
- Terminal.WriteLine(password.ToString());
- }
- break;
- case 2:
- Terminal.WriteLine("Words that fit:");
- foreach (string password in level2Passwords)
- {
- Terminal.WriteLine(password.ToString());
- }
- break;
- case 3:
- Terminal.WriteLine("Words that fit:");
- foreach (string password in level3Passwords)
- {
- Terminal.WriteLine(password.ToString());
- }
- break;
- default:
- Terminal.WriteLine("No level selected. How did this happen?");
- Terminal.WriteLine("Restarting game...");
- ShowMainMenu();
- break;
- }
- StartCoroutine(PasswordHelpDone(1.5f));
- }
- IEnumerator PasswordHelpDone(float time)
- {
- yield return new WaitForSeconds(time);
- Terminal.WriteLine("\nThis screen won't be shown again. Memorize these words.");
- yield return new WaitForSeconds(10.0f);
- Terminal.ClearScreen();
- yield return new WaitForSeconds(time);
- Terminal.WriteLine("Now enter the password: ");
- }
- void SetGameWords()
- {
- switch (level)
- {
- case 1:
- gameword1 = level1Gamewords[0];
- gameword2 = level1Gamewords[1];
- gameword3 = level1Gamewords[2];
- break;
- case 2:
- gameword1 = level2Gamewords[0];
- gameword2 = level2Gamewords[1];
- gameword3 = level2Gamewords[2];
- break;
- case 3:
- gameword1 = level3Gamewords[0];
- gameword2 = level3Gamewords[1];
- gameword3 = level3Gamewords[2];
- break;
- }
- }
- public IEnumerator StartLevelExecution(float countdownVal)
- {
- currentCountdownVal = countdownVal;
- currentScreen = Screen.Level;
- yield return new WaitForSeconds(1.5f);
- Terminal.ClearScreen();
- yield return new WaitForSeconds(1.5f);
- Terminal.WriteLine("You have " + countdownVal + " seconds to guess the words.\nYou have unlimited attempts.");
- yield return new WaitForSeconds(1.0f);
- Terminal.WriteLine("GO!");
- StartLevel();
- while (currentCountdownVal > 0)
- {
- yield return new WaitForSeconds(1.0f);
- currentCountdownVal--;
- }
- if (currentCountdownVal == 30)
- {
- Terminal.WriteLine("You have 30 seconds left.");
- }
- else if (currentCountdownVal == 10)
- {
- Terminal.WriteLine("You have 10 seconds left. Hurry up!");
- }
- else if (currentCountdownVal == 0)
- {
- GameOver();
- }
- }
- void StartLevel()
- {
- SetGameWords();
- Terminal.WriteLine("Word 1: " + gameword1.Anagram());
- }
- private void LevelInput(string input)
- {
- if (input == gameword1)
- {
- Terminal.WriteLine("Word 2: " + gameword2.Anagram());
- }
- else if (input == gameword2)
- {
- Terminal.WriteLine("Word 3: " + gameword3.Anagram());
- }
- else if (input == gameword3)
- {
- DisplayWinScreen();
- }
- else
- {
- Terminal.WriteLine("Wrong word! Try again:");
- }
- }
- void DisplayWinScreen()
- {
- currentScreen = Screen.Win;
- Terminal.ClearScreen();
- ShowLevelReward();
- }
- void ShowLevelReward()
- {
- Terminal.WriteLine("Well done!");
- switch (level)
- {
- case 1:
- Terminal.WriteLine("Have a book:");
- Terminal.WriteLine(@"
- __...--~~~~~-._ _.-~~~~~--...__
- // `V' \\
- // | \\
- //__...--~~~~~~-._ | _.-~~~~~~--...__\\
- //__.....----~~~~._\ | /_.~~~~----.....__\\
- ====================\\|//====================
- `---`
- ");
- break;
- case 2:
- Terminal.WriteLine("Have a dollar:");
- Terminal.WriteLine(@"
- ___________________________________
- |#######====================#######|
- |#(1)*UNITED STATES OF AMERICA*(1)#|
- |#** /===\ ******** **#|
- |*# {G} | (~) | #*|
- |#* ****** | /v\ | O N E *#|
- |#(1) \===/ (1)#|
- |##=========ONE DOLLAR===========##|
- ------------------------------------
- ");
- break;
- case 3:
- Terminal.WriteLine("Have an FBI badge:");
- Terminal.WriteLine(@"
- ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
- ⠀⠀⠀⠀⠀⠀⠀⣀⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀
- ⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀
- ⠀⠀⠀⢠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡄⠀⠀⠀
- ⠀⠀⢠⣿⡿⠿⠿⠿⠿⠿⠿⠿⣿⠿⠿⠿⠿⠿⠿⢿⣿⣿⣿⠿⠿⢿⣿⡄⠀⠀
- ⠀⢀⣿⣿⡇⠀⠀⣠⣤⣄⣀⣠⣿⠀⠀⢀⣤⣀⡀⠀⠘⣿⣿⠀⠀⢸⣿⣿⡀⠀
- ⠀⢸⣿⣿⡇⠀⠀⣿⣿⣿⣿⣿⣿⠀⠀⢸⣿⣿⠟⠀⠀⣿⣿⠀⠀⢸⣿⣿⡇⠀
- ⠀⢸⣿⣿⡇⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠺⣿⣿⠀⠀⢸⣿⣿⡧⠀
- ⠀⢸⣿⣿⡇⠀⠀⣿⣿⣿⣿⣿⣿⠀⠀⢸⣿⣿⣿⠀⠀⢹⣿⠀⠀⢸⣿⣿⡇⠀
- ⠀⠈⣿⣿⡇⠀⠀⣿⣿⣿⣿⣿⣿⠀⠀⠈⠛⠛⠉⠀⢀⣾⣿⠀⠀⢸⣿⣿⠃⠀
- ⠀⠀⠸⣿⣷⣶⣶⣿⣿⣿⣿⣿⣿⣶⣶⣶⣶⣶⣶⣾⣿⣿⣿⣶⣶⣾⣿⠇⠀⠀
- ⠀⠀⠀⠘⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀
- ⠀⠀⠀⠀⠀⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠁⠀⠀⠀⠀
- ⠀⠀⠀⠀⠀⠀⠀⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⠀⠀⠀⠀⠀⠀⠀
- ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠙⠛⠛⠋⠉⠉⠀⠀⠀⠀⠀⠀
- ");
- break;
- default:
- Terminal.WriteLine("No level selected. How did this happen?");
- Terminal.WriteLine("Restarting game...");
- ShowMainMenu();
- break;
- }
- }
- void GameOver()
- {
- currentScreen = Screen.GameOver;
- Terminal.ClearScreen();
- Terminal.WriteLine("GAME OVER!\nYou didn't make it in time.\nThe police is on their way.\n");
- Terminal.WriteLine("Press [ENTER] to continue..");
- }
- void RestartOrExit(string input)
- {
- Terminal.WriteLine("If you want to restart the game, type 'restart' or 'menu'.");
- Terminal.WriteLine("If you want to exit the game, type 'exit' or 'quit'.");
- if (input == "restart" || input == "menu")
- {
- Terminal.ClearScreen();
- ShowMainMenu();
- }
- else if (input == "exit" || input == "quit")
- {
- Application.Quit();
- }
- }
- }
Add Comment
Please, Sign In to add comment