It took me a while to finally make something work. There are way too many if statements as well. Hopefully, we’ll clean up the code soon. I didn’t watch the video yet so I don’t know if my version is good.
Edit: Yeah my version is a lot more complicated than Ben’s.
public class Hacker : MonoBehaviour
{
//Game state: availble everywhere
int level;
enum Screen { MainMenu, Password, Win };
enum Level { LevelZero, LevelOne, LevelTwo };
Screen currentscreen;
Level currentlevel;
// Use this for initialization
void Start()
{
string username = "Hello " + System.Environment.UserName + "!" + " Thank you for your purchased of Hacker McHack 9000."; //2) Define the varible further if needed.
ShowMainMenu(username); //3)Call the Function
}
void ShowMainMenu(string username) //1) Declare that the function exist. Declare the that varible exist.
{
Terminal.ClearScreen();
currentscreen = Screen.MainMenu;
currentlevel = Level.LevelZero;
Terminal.WriteLine(username);// 1.1) Tell the function how to use the varible.
Terminal.WriteLine("Here you can hack into anyone's mind");
Terminal.WriteLine("and control them remotely from home!");
Terminal.WriteLine("");
Terminal.WriteLine("Who would you like to hack into today?");
Terminal.WriteLine("Press 1 for Baby");
Terminal.WriteLine("Press 2 for Teenager");
Terminal.WriteLine("Press 3 for Scientist");
Terminal.WriteLine("Press 4 for Your Cat ((ΦωΦ))");
Terminal.WriteLine("Enter your choice: ");
}
//Should decide how to handel the input, not actually do it
void OnUserInput(string input)
{
if (input.ToUpper() == "MENU")
{
ShowMainMenu("Welcome back to the main menu " + System.Environment.UserName);
}
else if (currentscreen == Screen.MainMenu)
{
RunMainMenu(input); //passes input to the MainMenu state
}
else if (currentscreen == Screen.Password)
{
RunPassword(input); //Passes on input to the RunPassword function where the passwords will be processed.
}
}
void RunMainMenu(string input)
{
if (input == "1")
{
level = 1;
currentlevel = Level.LevelOne;
StartGame();
}
else if (input == "2")
{
level = 2;
currentlevel = Level.LevelTwo;
StartGame();
}
else if (input == "3")
{
level = 3;
StartGame();
}
else if (input == "4")
{
level = 4;
StartGame();
}
else if (input.ToUpper() == "I DON'T HAVE A CAT")
{
Terminal.WriteLine("Then we'll hack into your neighbour's cat instead!");
}
else if (input.ToUpper() == "BEEP BOOP")
{
Terminal.WriteLine("Beep Beep Boop Bop Boop Beep Beep");
Terminal.WriteLine("(ノ°ο°)ノ");
}
else if (input.ToUpper() == "I DON'T WANT TO PLAY")
{
Terminal.WriteLine("Okay so...");
}
else if (input.ToUpper() == "BOO")
{
Terminal.WriteLine("⊂(•̀_•́⊂ )∘˚˳°");
}
else if (input.ToUpper() == "MEOW")
{
Terminal.WriteLine("(^=˃ᆺ˂)");
}
else
{
Terminal.WriteLine("Please select an actual level ಠ_ಠ");
}
}
void StartGame()
{
Terminal.ClearScreen();
currentscreen = Screen.Password;
Terminal.WriteLine("You have selected Level " + level);
Terminal.WriteLine("Please enter the password");
}
void RunPassword(string input)
{
if (currentlevel == Level.LevelOne)
{
if (input.ToUpper() == "RAINBOW" || input.ToUpper() == "SISTER")
{
Terminal.WriteLine("You are correct");
}
else
{
Terminal.WriteLine("You are incorrect. Try again");
}
}
else if (currentlevel == Level.LevelTwo)
{
if (input.ToUpper() == "GEOMETRY" || input.ToUpper() == "MITOSIS")
{
Terminal.WriteLine("You are correct");
}
else
{
Terminal.WriteLine("You are incorrect. Try again");
}
}
}
}