Hi,
Can you post your full script, here in the forum - not as an image.
See also;
- Forum User Guides : How to apply code formatting within your post
- Forum User Guides : How can I add images to my posts
using UnityEngine;
public class Hacker : MonoBehaviour
{
//Game config data
string[] level1passwords = {"Table","chair","dog","Cat","Mouse","Van"};
string[] level2passwords = {"Godhand","Griffith","Guts","Pino" };
//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("Welcome to hack game!!!!");
Terminal.WriteLine("Press 1 for ez");
Terminal.WriteLine("Press 2 for wtf is this?");
Terminal.WriteLine("Press 3 for gg,fml");
Terminal.WriteLine("Enter your selection: ");
}
void OnUserInput(string input)
{
if (input == "menu")
{
ShowMainMenu();
}
else if (Currentscreen == Screen.MainMenu)
{
RunMainMenu(input);
}
else if (Currentscreen == Screen.PassWord)
{
checkpassword(input);
}
}
void RunMainMenu(string input)
{
bool isValidLevelNumber = (input == "1" || input == "2");
if (isValidLevelNumber)
{
level = int.Parse(input);
StartGame();
}
else if (input == "007") // easter egg
{
Terminal.WriteLine("You do not know the wey Mr. Bond");
}
else
{
Terminal.WriteLine("unknown command");
}
}
void StartGame()
{
Currentscreen = Screen.PassWord;
Terminal.ClearScreen();
switch (level)
{
case 1:
Password = level1passwords[Random.Range(0, level1passwords.Length)];
break;
case 2:
Password = level2passwords[Random.Range(0, level2passwords.Length)];
break;
default:
Debug.LogError("invalid level");
break;
}
Terminal.WriteLine("Enter your Password, hint:" + Password.Anagram());
}
void checkpassword(string input)
{
if (input == Password)
{
DisplayWinScreen();
}
else
{
Terminal.WriteLine("Try again");
}
}
void DisplayWinScreen()
{
Currentscreen = Screen.Win;
Terminal.ClearScreen();
ShowLevelReward();
}
void ShowLevelReward()
{
switch (level)
{
case 1:
Terminal.WriteLine("Noice M8!");
Terminal.WriteLine(@"
//// ,_ _ \
\ ( / ('* \*(
` ' ' -`,
'\ `_C/ \\\|
.\ __,(___ \ ) /
.\__.-' `. ` |
.____ \ '|
"
);
break;
case 2:
Terminal.WriteLine("WOWWWWW!!!!");
Terminal.WriteLine(@"");
break;
default:
Debug.LogError("Invalid level");
break;
}
}
}
I might have messed it all up, let me know if you cannot read it. I don’t know how to like full script any other way.
sry
The only thing I can think of is a problem of Assets, maybe your Hacker.cs file is not at the right place or you didn’t import WM2000 correctly…
I suggest you rewatch-redo lesson 11
and the first minute and a half of lesson 12.
You can copy your Hacker.cs to a safe place first to be sure not to lose anything.
Hi,
Can you check that you have the Utility.cs script within your project.
If you do, can you zip up your project share it, I will happily take a look for you.
The forum will allow uploads of up to 10mb, if your zipped file is larger than that then you will need to use a service like Google Drive or Dropbox and then provide the URL.
2_Terminal Hacker.zip (8.5 MB)
Sorry for late reply guys, had work all day yesterday. I couldn’t find utility,cs but i compressed the project and made a zip.
If you cannot find Utility.cs then that is tge source of your issue.
This file contains an extension method for the type string
, Anagram
, because you don’t have this file, you don’t have the method.
Re-import the .unitypackage but only select Utility.cs, your error should then go away.
Thank you so much, I re-imported the . unity package and everything works now.
Thanks again.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.