[ https://www.sharemygame.com/share/a4bce8d9-6dc0-417b-9e22-3f0e341231c7](http://Demo game for next 30 days)
using UnityEngine;
using System;
//using System.Reflection;
public class Hacker : MonoBehaviour
{
string[] LibraryUserList = { "borrow", "return", "book", "available", "author" };
string[] PoliceUserList = { "omission","acquainted","affidavit","concealed","deterrent" };
string[] NasaUserList = { "terrestrial", "retrograde", "geostationary", "ecliptic", "celestial" };
string tempPassword = "";
// Dictionary<string, string[]> stringValues;
string[,] TerminalList = { { "Library", "LibraryUserList" }, { "Police", "PoliceUserList" }, { "NASA", "NasaUserList" } };
// Start is called before the first frame update
enum gameState { mainMenu, hackMode, gameEnd };
gameState terminalMode = gameState.mainMenu;
void Start()
{
// stringValues = new Dictionary<string, string[]>();
// stringValues.Add("Library", LibraryUserList);
// print("Hello Console" + currentSec.LibraryUserList);
Terminal.WriteLine("Hello World");
Terminal.WriteLine(" /* Welcome! This is a pseudo-hacking terminal for fun!\nIt lets you hack in to several computers!\n\nClick here and start typing to get hacking! */ \n \n Systems avaliable to hack \n 1] Library \n 2] Police \n 3] NASA \n\n Choose your terminal :");
}
void OnUserInput(string input)
{
switch (terminalMode) {
case gameState.mainMenu:
try {
int tempInput = int.Parse(input);
if (tempInput > 0 && tempInput <=3)
{
//setting the terminal mode to HackInput
terminalMode = gameState.hackMode;
Terminal.WriteLine("Access terminal <<" + TerminalList[tempInput-1, 0] + " >>");
Terminal.WriteLine("Getting random user name from " + TerminalList[tempInput - 1,0]);
getRandomUserName(TerminalList[tempInput - 1, 1].ToString());
Terminal.WriteLine("Enter user's password to access terminal.");
}
else
Terminal.WriteLine("Invalid! choose a terminal to hack, enter terminal number!");
}
catch( FormatException )
{
Terminal.WriteLine("Invalid! choose a terminal to hack, enter terminal number!!!");
}
break;
case gameState.hackMode:
print(input + " your input = password" + tempPassword);
if(tempPassword == input)
Terminal.WriteLine("Terminal Access Granted! Game Won! YAHEEE!");
else
Terminal.WriteLine("Terminal Access Fail! Game Over.");
Terminal.WriteLine("Enter enter key to go back to main menu!");
terminalMode = gameState.gameEnd;
break;
case gameState.gameEnd:
Terminal.WriteLine(@"Going back to main menu.
Systems avaliable to hack \n 1] Library \n 2] Police \n 3] NASA \n\n Choose your terminal :");
terminalMode = gameState.mainMenu;
break;
}
}
public void getRandomUserName(string userList)
{
var rnd = new System.Random().Next(0, 5);
Terminal.WriteLine("Online user in the "+ userList +"["+ rnd + "] is =>> " + shuffelString(passList(userList)[rnd]));
// print(this.GetType().GetField("userList").GetValue(this));
return;
}
public string[] passList(string userListName)
{
string[] tempList = { };
switch (userListName)
{
case "LibraryUserList":
tempList = LibraryUserList;
break;
case "PoliceUserList":
tempList = PoliceUserList;
break;
case "NasaUserList":
tempList = NasaUserList;
break;
}
return tempList;
}
public string shuffelString(string tempString)
{
string tt = "what the"; tt.Anagram();
print(tt.Anagram()+" Anagram is " + tt);
tempPassword = tempString;
string tempChatStr = tempString;
print("Enter the Password for " + tempChatStr);
string finalString = "";
do
{
int rnd = new System.Random().Next(0, tempChatStr.Length);
//finalString.push(tempChatAr[rnd]);
finalString+= tempChatStr[rnd];
///slice tempChatAr
// print("Hello Console " + finalString);
// print("first half " + tempChatStr.Substring(0, rnd));
// print("second half " + tempChatStr.Substring(rnd + 1));
tempChatStr = tempChatStr.Substring(0, rnd) + tempChatStr.Substring(rnd + 1);
} while (tempChatStr.Length >0);
return finalString;
}
// Update is called once per frame
void Update()
{
}
}