This is my code but it say somtin is wrong with anagram please help me

using UnityEngine;
public class Hacker : MonoBehaviour {
// Game configuration data
const string menuHint = “You may type menu at any time.”;
string level1Passwords = { “books”, “aisle”, “shelf”, “password”, “font”, “borrow” };
string level2Passwords = { “prisoner”, “handcuffs”, “holster”, “uniform”, “arrest” };
string level3Passwords = { “starfield”, “telescope”, “environment”, “exploration”, “astronauts” };
// Game state
int level;
enum Screen { MainMenu, Password, Win };
Screen currentScreen;
string password;
// Use this for initialization
void Start ()
{
ShowMainMenu ();
}
void ShowMainMenu ()
{
currentScreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine(“What would you like to hack into?”);
Terminal.WriteLine(“Press 1 for the local library”);
Terminal.WriteLine(“Press 2 for the police station”);
Terminal.WriteLine(“Press 3 for NASA!”);
Terminal.WriteLine(“Enter your selection:”);
}
void OnUserInput(string input)
{
if (input == “menu”) // we can always go direct to main menu
{
ShowMainMenu();
}
else if (input == “quit” || input == “close” || input == “exit”)
{
Terminal.WriteLine(“If on the web close the tab.”);
Application.Quit();
}
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);
AskForPassword();
}
else if (input == “007”) // easter egg
{
Terminal.WriteLine(“Please select a level Mr Bond!”);
}
else
{
Terminal.WriteLine(“Please choose a valid level”);
Terminal.WriteLine(menuHint);
}
}
void AskForPassword()
{
currentScreen = Screen.Password;
Terminal.ClearScreen();
SetRandomPassword();
Terminal.WriteLine(“Enter your password, hint: " + password.Anagram());
Terminal.WriteLine(menuHint);
}
void SetRandomPassword()
{
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;
}
}
void CheckPassword(string input)
{
if (input == password)
{
DisplayWinScreen();
}
else
{
AskForPassword();
}
}
void DisplayWinScreen()
{
currentScreen = Screen.Win;
Terminal.ClearScreen();
ShowLevelReward();
Terminal.WriteLine(menuHint);
}
void ShowLevelReward()
{
switch (level)
{
case 1:
Terminal.WriteLine(“Have a book…”);
Terminal.WriteLine(@”
_______
/ //
/ //
/_____ //
((/
"
);
break;
case 2:
Terminal.WriteLine(“You got the prison key!”);
Terminal.WriteLine(“Play again for a greater challenge.”);
Terminal.WriteLine(@"
__
/0 _

__/-=’ = ’
"
);
Terminal.WriteLine(“Play again for a greater challenge.”);
break;
case 3:
Terminal.WriteLine(@"


| '_ \ / / __|/ _ |
| | | | (
| __ \ (| |
|
| ||_,|)_,|
"
);
Terminal.WriteLine(“Welcome to NASA’s internal system!”);
break;
default:
Debug.LogError(“Invalid level reached”);
break;
}
}
}Preformatted text

Hi Cameron,

First of all, please use the code formatting button to format your code, because it is almost impossible to read the code you posted here. See the image on how to do it (first select all code and then press the button you see on the image):

aaa

You said that there is something wrong with the code, what is this error? Are there any messages popping up in Unity? If there are, please take a screenshot of them.

This is the error I get every time

So basically, since so much of this project is imported assets, it’s possible something didn’t import correctly. You need to have a Utility.cs script somewhere in your project that allows you to use string Anagram();.

You should be able to reimport your unity package, but ONLY import the Utility.cs file over. This should fix your problem.

Privacy & Terms