using System;
using UnityEngine;
enum Screen {EnterName,MainMenu, Password, Win};
public class Hacker : MonoBehaviour
{
string name;
int level;
string passwordInput;
string passwordToGuess;
Screen currentScreen;
string[] validLevels = { "1","2","3"};
string[] passwordLevel1 = {"Teeku", "Bubbu", "Pukku", "Wuggy"};
string[] passwordLevel2 = {"HTTP", "FTP", "UML", "Hex", "Doc"};
string[] passwordLevel3 = {"Echo", "Blue", "Rigid"};
void Start()
{
if (string.IsNullOrEmpty(name))
{
EnterName();
}
}
void EnterName()
{
currentScreen = Screen.EnterName;
Terminal.ClearScreen();
Terminal.WriteLine("Please enter your Name: ");
}
void ShowMainMenu()
{
currentScreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine("Hi "+ name + "!");
Terminal.WriteLine("Welcome to The Hacking Game!\n Press 1 to hack Phone\n Press 2 to hack Server\n Press 3 to hack IBM \n\n Enter your selection:");
}
void OnUserInput(string input)
{
if (currentScreen == Screen.EnterName)
{
name = input;
ShowMainMenu();
}
else if (currentScreen == Screen.MainMenu)
{
;
if (Array.IndexOf(validLevels, input) >= 0)
{
level = int.Parse(input);
PlayLevel();
}
else
{
Terminal.WriteLine("Invalid level selected. Try Again.");
}
}
else if (currentScreen == Screen.Password)
{
if(input == "menu"){
ShowMainMenu();
}
else {
CheckPassword(input);
}
}
else if (currentScreen == Screen.Win)
{
ShowMainMenu();
}
else
{
print("Enter correct input");
}
}
void PlayLevel()
{
currentScreen = Screen.Password;
Terminal.ClearScreen();
Terminal.WriteLine("You have selected level: "+ level);
Terminal.WriteLine("To go to Main Menu type -> menu");
switch(level){
case 1:
passwordToGuess = passwordLevel1[UnityEngine.Random.Range(0, passwordLevel1.Length)];
break;
case 2:
passwordToGuess = passwordLevel2[UnityEngine.Random.Range(0, passwordLevel2.Length)];
break;
case 3:
passwordToGuess = passwordLevel3[UnityEngine.Random.Range(0, passwordLevel3.Length)];
break;
default:
break;
}
Terminal.WriteLine("Guess the password: ");
}
void CheckPassword(string input)
{
passwordInput = input;
if (passwordInput == passwordToGuess)
{
currentScreen = Screen.Win;
Terminal.ClearScreen();
Terminal.WriteLine("You Win!");
}
else
{
Terminal.WriteLine(":( Try Again..");
}
}
}