using UnityEngine;
using System;
public class Hacker : MonoBehaviour
{ //Game config data
string[] level1Passwords = { "apple", "class", "lunch", "books", "teacher","homework" };
string[] level2Passwords = { "documents", "shredder", "meeting", "company", "computers", "copier" };
//Game State
int level;
enum Screen { ShowMenu, Password, Win };
Screen currentScreen;
string password;
void Start() //Use this for initialization
{
print(level1Passwords[0]);
ShowMenu(); //statement
}
void ShowMenu ()
{ currentScreen = Screen.ShowMenu;
Terminal.ClearScreen();//clears the screen
Terminal.WriteLine("There are three systems you can hack"); //prints to the terminal
Terminal.WriteLine("1.School Terminal");
Terminal.WriteLine("2.Company Terminal");
Terminal.WriteLine("3.Bank Terminal");
Terminal.WriteLine("Enter your selection: ");
}
void OnUserInput(string input)
{
if (input == "menu") // prints user input on console; Boolean
{
ShowMenu();
}
else if (currentScreen == Screen.ShowMenu)
{
RunMain(input);
}
else if (currentScreen == Screen.Password)
{
CheckPassword(input);
}
}
void RunMain(string input)
{
bool isValidLevelNumber = (input == "1" || input == "2");
if (isValidLevelNumber)
{
level = int.Parse(input);
StartGame();
}
else if (input == "Crimson")
{
Terminal.WriteLine("Welcome back Crimson"); // Easter Egg
}
else
{
Terminal.WriteLine("Please choose a Valid level!"); // Incorrect level choice
}
}
void StartGame()
{
currentScreen = Screen.Password;
print(level1Passwords.Length);
print(level2Passwords.Length);
Terminal.ClearScreen();
switch(level)
{
case 1:
int index = Random.Range(0, level1Passwords);
password = level1Passwords[index];
break;
case 2:
password = level2Passwords[0];
break;
default:
Debug.LogError("Invalid Level Selection!");
break;
}
Terminal.WriteLine("Please enter your password: ");
}
void CheckPassword(string input)
{
if (input == password)
{
Terminal.WriteLine("Correct !");
}
else
{
Terminal.WriteLine("Incorrect !");
}
}
}
If I keep using System and using Unity the Random in Random.Range goes blue. If I take out using system, the Random is not blue and i get cannot convert string .