I included win screens for levels 2 and 3, with some ascii art that is themed for each level. Its coming along!
using System.Runtime.InteropServices;
using UnityEngine;
public class Hacker : MonoBehaviour
{
// Game Configuration data
string[] level1Passwords = { "volt", "watt", "jule", "shock", "electric" };
string[] level2Passwords = { "coffee", "magazine", "eclair", "grenade", "uniform" };
string[] level3Passwords = { "endorsement", "investigate", "utilitarian", "deniability", "government" };
// Game state
int level;
enum Screen { MainMenu, Password, Win };
Screen currentScreen;
string password;
// Start is called before the first frame update
void Start()
{
ShowMainMenu();
}
void ShowMainMenu()
{
currentScreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine("Welcome to Terminal Hacker. Type menu to return here.");
Terminal.WriteLine("");
Terminal.WriteLine("Press 1 to hack into Level 1: The PowerCompany.");
Terminal.WriteLine("");
Terminal.WriteLine("Press 2 to hack into Level 2: The ");
Terminal.WriteLine("Police Precinct.");
Terminal.WriteLine("");
Terminal.WriteLine("Press 3 to hack into Level 3: The FBI.");
Terminal.WriteLine("Please select your target.");
}
void OnUserInput(string input)
{
if (input == "menu") // we can always go direct to main menu
{
ShowMainMenu();
}
else if (currentScreen == Screen.MainMenu)
{
RunMainMenu(input);
}
else if (currentScreen == Screen.Password)
{
CheckPassword(input);
}
}
void RunMainMenu(string input)
{
bool isValidLevelNumber = (input == "1" || input == "2" || input == "3");
if (isValidLevelNumber)
{
level = int.Parse(input);
StartGame();
}
else if (input == "IMF") // easter egg
{
Terminal.WriteLine("Welcome back Ethan Hunt. Press either 1, 2, or 3. This is your mission, should you wish to accept it.");
}
else if (input == "hitman") // easter egg
{
Terminal.WriteLine("Good to see you 47. I need you to gather some intel. Where would you like to begin? Please enter 1, 2, or 3.");
}
else
{
Terminal.WriteLine("Please choose a valid level.");
}
}
void StartGame()
{
currentScreen = Screen.Password;
Terminal.ClearScreen();
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:
Debug.LogError("Invalid level number.");
break;
}
Terminal.WriteLine("You have chosen Level " + level);
Terminal.WriteLine("Please enter your password: ");
}
void CheckPassword(string input)
{
if (input == password)
{
DisplayWinScreen();
}
else
{
Terminal.WriteLine("Password Incorrect.");
}
}
void DisplayWinScreen()
{
currentScreen = Screen.Win;
Terminal.ClearScreen();
ShowLevelReward();
}
void ShowLevelReward()
{
switch(level)
{
case 1:
Terminal.WriteLine(@"
\ \
_\ _\
\ \
_\_\
\\
_\\
\
");
Terminal.WriteLine("You got some electricity!");
break;
}
switch(level)
{
case 2:
Terminal.WriteLine(@"
,---^-------()()
| |__-,-_----/
| |
|_|
");
Terminal.WriteLine("You got a shotgun!");
break;
}
switch(level)
{
case 3:
Terminal.WriteLine(@"
------------------------
| ______ ______ __ |
|/\ ___\/\ == \ /\ \ |
|\ \ __\\ \ __< \ \ \ |
| \ \_\ \ \_____\\ \_\|
| \/_/ \/_____/ \/_/|
------------------------
");
Terminal.WriteLine("You got a badge!");
break;
}
}
}