using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hacker : MonoBehaviour {
string[] option1 = { "password", "books", "library" };
string[] option2 = { "traffic", "signal", "cops" };
enum Screen { MainMenu, Hacker, Win };
Screen currentScreen;
int level;
// Start is called before the first frame update
void Start() {
print("Hello Console");
ShowMainMenu();
}
// Update is called once per frame
void Update() {
}
void OnUserInput(string input) {
if (input == "menu") {
ShowMainMenu();
} else if (currentScreen == Screen.MainMenu) {
RunMainMenu(input);
} else if (currentScreen == Screen.Hacker) {
RunPasswordHacking(input);
}
}
void RunPasswordHacking(string input) {
string[] options;
if (level == 1) {
options = option1;
} else {
options = option2;
}
bool matched = false;
for (var i = 0; i < options.Length; i++) {
if (input == options[i]) {
matched = true;
break;
}
}
if (matched) {
Terminal.WriteLine("You guessed it right");
} else {
Terminal.WriteLine("Wrong password! Better luck next time");
}
}
private void RunMainMenu(string input) {
if (input == "1" || input == "2") {
level = input == "1" ? 1 : 2;
StartGame();
} else {
Terminal.WriteLine("Wrong Input! Enter Correct Menu Option");
}
}
void StartGame() {
currentScreen = Screen.Hacker;
Terminal.WriteLine("You have entered " + level);
Terminal.WriteLine("Please enter password to hack: ");
}
void ShowMainMenu() {
currentScreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine("Welcome to Terminal Hacker");
Terminal.WriteLine("Press (1) to Hack into college library");
Terminal.WriteLine("Press (2) to Hack into Traffic control");
Terminal.WriteLine("Enter your choice: ");
}
}