Had a lot of fun just figuring it out to be honest. Looking forward to learning a lot more! Here was my solution!
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hacker : MonoBehaviour
{
int level; // Game State
enum Screen { MainMenu, Password, Win }; // Our screens for different input settings.
Screen currentScreen;
// Use this for initialization
void Start()
{
ShowMainMenu();
}
void ShowMainMenu()
{
currentScreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine(" Hack_O_Matic 3000 | v2.4 ");
Terminal.WriteLine(" ------------------------ ");
Terminal.WriteLine("Please select your option of choice.");
Terminal.WriteLine("Option 1: Your friends phone");
Terminal.WriteLine("Option 2: The university system");
Terminal.WriteLine("Option 3: The local traffic system");
Terminal.WriteLine("Option 4: The online banking system");
Terminal.WriteLine("Option 5: The ASIO database");
Terminal.WriteLine(" ");
Terminal.WriteLine("Please enter your option: ");
}
void OnUserInput(string input) // Decides how to handle input aka, if password is the screen, it will run by the RunPassword method.
{
if (input == "menu") // Takes directly to main menu
{
ShowMainMenu(); // Will show main menu
}
else if (currentScreen == Screen.MainMenu) // If current screen is already main menu it will instead run our use the user input for the options. Section
{
RunMainMenu(input);
}
else if (currentScreen == Screen.Password) // If screen is on the password enter screen it will run the password authentication method using the input.
{
RunPassword(input);
}
}
void RunMainMenu(string input) // Makes the input only affect the level choice / difficulty.
{
if (input == "1") // If the user chooses option 1 it will choose the passwords for option 1 and change the screen to password.
{
level = 1;
StartGame(input);
}
else if (input == "2") // If the user chooses option 2 it will choose the passwords for option 2 and change the screen to password.
{
level = 2;
StartGame(input);
}
else if (input == "MI6")
{
Terminal.WriteLine("This Terminal will self destruct in 10 seconds... ");
Terminal.WriteLine("If you do not choose a valid option");
}
else if (input == "007")
{
Terminal.WriteLine("Martini, sir?");
Terminal.WriteLine("No, a valid option would be nice.");
}
else if (input == "Yugioh")
{
Terminal.WriteLine("You've activated my TRAP card! Now choose a valid OPTION!");
}
else if (input == "Indiana")
{
Terminal.WriteLine("I hate code Jock! I HATE IT!! ");
}
else if (input == "Batfink")
{
Terminal.WriteLine("Your typing cannot hurt me! My wings are like a SHIELD of STEEL!");
}
else
{
Terminal.WriteLine("That is not a valid option, please try again.");
}
}
void StartGame(string input) // Starts the game, enter a password for the selected level.
{
currentScreen = Screen.Password; // Changes screen to password screen.
Terminal.WriteLine("You have chosen level " + level);
Terminal.WriteLine("Please enter the password ");
}
void RunPassword(string input) // Password input method to define correct or incorrect input for game.
{
if (level == 1 && input == "juke" || input == "cozy")
{
Terminal.ClearScreen();
currentScreen = Screen.Win;
Terminal.WriteLine("You've now broken your friends trust :( ");
Terminal.WriteLine(" ");
Terminal.WriteLine("Please type menu to return to the menu. ");
}
else if (level == 2 && input == "crazy" || input == "quirk")
{
Terminal.ClearScreen();
currentScreen = Screen.Win;
Terminal.WriteLine("You can now cheat the system.");
Terminal.WriteLine(" ");
Terminal.WriteLine("Please type menu to return.");
}
else
{
Terminal.WriteLine("That is incorrect, try again.");
}
}
}