Advertisement
Guest User

Code

a guest
Jul 27th, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.43 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Hacker : MonoBehaviour
  6.  
  7. {
  8.     // Game config
  9.     string[] level1passwords = { "friend", "neighbor", "home", "password", "123", "qwerty" };
  10.     string[] level2passwords = { "police", "law", "squadcar", "sergeant", "tazer", "donut" };
  11.     string[] level3passwords = { "federal", "machinegun", "fbiopenup", "feds", "prison", "trouble" };
  12.    
  13.     // Game state
  14.     int level;
  15.     int CrackAttempts;
  16.     enum Screen { MainMenu, Password, Win, EasterEgg };
  17.     Screen currentScreen = Screen.MainMenu;
  18.     string password;
  19.  
  20.     // Start is called before the first frame update
  21.    
  22.     void Start()
  23.     {
  24.         ShowMainMenu();
  25.     }
  26.     void ShowMainMenu()
  27.     {
  28.         Terminal.ClearScreen();
  29.         Terminal.WriteLine("What would you like to hack into?");
  30.         Terminal.WriteLine(" ");
  31.         Terminal.WriteLine("Press 1 for your neighbors wifi.");
  32.         Terminal.WriteLine("Press 2 for the local police station.");
  33.         Terminal.WriteLine("Press 3 for the FBI.");
  34.         Terminal.WriteLine(" ");
  35.         Terminal.WriteLine("Please enter your selection:");
  36.         currentScreen = Screen.MainMenu;        
  37.     }
  38.  
  39.     void OnUserInput (string input)
  40.     {
  41.         bool isValidLevelNumber = (input == "1" || input == "2" || input == "3");
  42.         if (isValidLevelNumber)
  43.         {
  44.             level = int.Parse(input);
  45.             StartGame();
  46.         }
  47.        
  48.         if (input == "Menu")
  49.         {
  50.             ShowMainMenu();
  51.             currentScreen = Screen.MainMenu;
  52.         }
  53.        
  54.         else if (input == "Method0901")
  55.         {
  56.             Terminal.WriteLine("Follow Method0901 on twitch: twitch.tv/METHOD0901");
  57.             currentScreen = Screen.EasterEgg;
  58.         }
  59.        
  60.         else if (currentScreen == Screen.Password)
  61.         {
  62.             Password();
  63.         }
  64.        
  65.         else
  66.         {
  67.             Terminal.WriteLine("Please make a valid selection.");
  68.         }
  69.        
  70.        
  71.  
  72.         void StartGame ()
  73.         {
  74.             Terminal.ClearScreen();
  75.             Terminal.WriteLine("You have chosen level " + level);
  76.             Terminal.WriteLine(" ");
  77.             Terminal.WriteLine("Input 'Menu' or a new level number to");
  78.             Terminal.WriteLine("choose another level.");
  79.             Terminal.WriteLine("Please enter the password:");
  80.             currentScreen = Screen.Password;
  81.         }
  82.        
  83.         switch (level)
  84.         {
  85.             case 1:
  86.                 password = level1passwords[3];
  87.                 level = 1;
  88.                 break;
  89.             case 2:
  90.                 password = level2passwords[5];
  91.                 level = 2;
  92.                 break;
  93.             case 3:
  94.                 password = level3passwords[2];
  95.                 level = 3;
  96.                 break;
  97.         }
  98.  
  99.         void Password()
  100.         {
  101.             if (input == password)
  102.             {
  103.                 Terminal.WriteLine("Password successfully cracked.");
  104.             }
  105.             else
  106.             {
  107.                 Terminal.WriteLine(" ");
  108.                 Terminal.WriteLine("Password incorrect.");
  109.                 CrackAttempts += 1;
  110.                 Terminal.WriteLine("Failed cracking attempts: " + CrackAttempts);
  111.                 Terminal.WriteLine("Try again:");
  112.             }
  113.         }
  114.  
  115.  
  116.        
  117.        
  118.     }
  119.    
  120.        
  121.  
  122.    
  123.        
  124. }
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement