My terminal hacker. 3 levels, login screen, and easter egg. Did I do this block quote right?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Hacker : MonoBehaviour 
{
	//Game State Variables
	public string output = null;
	public string player = null;
	public int level;
	public enum Screen { welcome, menu, passsword, hell, win };
	public Screen currentscreen = Screen.welcome;
	public string password = null;

	void Start () 
	{
		ShowWelcome ();
	}

	public void ShowWelcome()
	{
		currentscreen = Screen.welcome;
		Terminal.ClearScreen ();
		Terminal.WriteLine ("Who goes there?");
	}

	public void ShowMainMenu(string name)
	{
		currentscreen = Screen.menu;
		Terminal.ClearScreen ();
		Terminal.WriteLine ("Ayyyyyy, " + name + "'s come to see us!");
		Terminal.WriteLine ("Welcome to Porthack.io");
		Terminal.WriteLine ("So you wanna be a hacker?");
		Terminal.WriteLine ("Select your target:");
		Terminal.WriteLine ("");
		Terminal.WriteLine ("1. School Database");
		Terminal.WriteLine ("2. Big Money Bank #666");
		Terminal.WriteLine ("3. Atlanta CDC");
		Terminal.WriteLine ("");
		Terminal.WriteLine ("Enter your selection: ");
	}

	void RunMenu (string input)
	{
		if (input == "1") 
		{
			currentscreen = Screen.passsword;
			level = 1;
			StartGame ();
			password = "Grades";
		}
		else if (input == "2") 
		{
			currentscreen = Screen.passsword;
			level = 2;
			StartGame ();
			password = "Money";
		}
		else if (input == "3") 
		{
			currentscreen = Screen.passsword;
			level = 3;
			StartGame ();
			password = "Disease";
		}
		else if (input == "666") 
		{
			currentscreen = Screen.hell;
			Terminal.ClearScreen ();
			Terminal.WriteLine ("Devilman recognized");
			Terminal.WriteLine ("Welcome home, Amon");
		}
		else if (input == "menu") 
		{
			currentscreen = Screen.menu;
			Terminal.ClearScreen ();
			ShowMainMenu (player);
		}
		else 
		{
			Terminal.WriteLine ("Please enter a valid option. Fool");
		}
	}

	void StartGame()
	{		
		if (level == 1) 
		{
			currentscreen = Screen.passsword;
			Terminal.ClearScreen ();
			Terminal.WriteLine ("Anytown HS Database.");
			Terminal.WriteLine ("Please enter your password: ");
		} 
		else if (level == 2) 
		{
			currentscreen = Screen.passsword;
			Terminal.ClearScreen ();
			Terminal.WriteLine ("Big Money Bank Branch #666");
		} 
		else if (level == 3) 
		{
			currentscreen = Screen.passsword;
			Terminal.ClearScreen();
			Terminal.WriteLine ("CDC Internal Server");
		}
	}

	void menuquit (string input)
	{
		if (input == "qq") 
		{
			ShowWelcome ();
			currentscreen = Screen.welcome;
		}
		else if (input == "menu") 
		{
			ShowMainMenu (player);
			currentscreen = Screen.menu;
		}
	}

	void HandlePassword(string input)
	{
		menuquit (input);
		if (level == 1 && input == password) 
		{	
			Terminal.ClearScreen ();
			Terminal.WriteLine ("YOU WIN!!");
			Terminal.WriteLine ("Enter menu to play again or qq to quit.");
		} 
		else if (level == 1 && input != password) 
		{
			Terminal.ClearScreen ();
			Terminal.WriteLine ("Anytown HS Database");
			Terminal.WriteLine ("");
			Terminal.WriteLine ("Password incorrect, try again");
		} 
		else if (level == 2 && input == password) 
		{
			Terminal.ClearScreen ();
			Terminal.WriteLine ("YOU WIN!!");
			Terminal.WriteLine ("Enter menu to play again or qq to quit.");
		} 
		else if (level == 2 && input != password) 
		{
			Terminal.ClearScreen ();
			Terminal.WriteLine ("Big Money Bank #666");
			Terminal.WriteLine ("");
			Terminal.WriteLine ("Password incorrect, try again");
		} 
		else if (level == 3 && input == password) 
		{
			menuquit (input);
			Terminal.ClearScreen ();
			Terminal.WriteLine ("YOU WIN!!");
			Terminal.WriteLine ("Enter menu to play again or qq to quit.");
		} 
		else if (level == 3 && input != password) 
		{
			Terminal.ClearScreen ();
			Terminal.WriteLine ("CDC Internal Server");
			Terminal.WriteLine ("");
			Terminal.WriteLine ("Password incorrect, try again");
		}
		menuquit (input);
	}

	void OnUserInput (string input)
	{
		output = input;
		menuquit (input);
		if (currentscreen == Screen.welcome) 
		{
			player = input;
			ShowMainMenu (player);
		} 
		else if (currentscreen == Screen.menu) 
		{
			RunMenu (input);
		} 
		else if (currentscreen == Screen.passsword) 
		{
			HandlePassword (input);
		}
		else if (input == "qq") 
		{
			currentscreen = Screen.welcome;
			ShowWelcome ();
		} 
		else if (currentscreen != Screen.menu && input == "menu") 
		{
			currentscreen = Screen.menu;
			ShowMainMenu (player);
		}
	}
}

I threw my menuquit() function in a few extra places because it would occasionally check qq and/or menu as password input rather than immediately kicking you back to the welcome or main menu screens.

1 Like

Hi Ian, welcome to the community.:slight_smile:

It isn’t actually the blockquote you want for code, but thanks for asking. You can just copy/paste code in to your posts and then apply the code formatting characters on their own line both before and after it. See below for details. :slight_smile:


See also;

wow wow wee wow that is excellent, thank you

1 Like

Privacy & Terms