I don’t know what I did wrong, I followed the video for this course, but for some reason, the “CheckPassword” line has an error message and it won’t go away no matter what I do. I’m posting my code here so you all can see what I did, any help at all would be appreciated.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hacker : MonoBehaviour
{
// Game state
int level;
enum Screen { MainMenu, Password, WinState };
Screen currentScreen;
string password;
// Start is called before the first frame update
void Start() {
ShowMainMenu();
}
void ShowMainMenu()
{
currentScreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine("Welcome to The Royal Liberty Museum");
Terminal.WriteLine("Which facility will you hack into?");
Terminal.WriteLine("Press 1 to hack the Nature Wing");
Terminal.WriteLine("Press 2 to hack the Science Wing");
Terminal.WriteLine("Press 3 to hack the Fine Arts Wing");
Terminal.WriteLine("Please 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)
{
currentScreen = Screen.Password;
if (input == "1")
{
level = 1;
password = "Botany";
StartGame();
}
else if (input == "2")
{
level = 2;
password = "Chemistry";
StartGame();
}
else if (input == "3")
{
level = 3;
password = "Artistry";
StartGame();
}
else
{
Terminal.WriteLine("Please Select a Valid Option");
}
void StartGame() //add hints for each wing
{
Terminal.WriteLine("You have selected Wing " + level);
Terminal.WriteLine("Please enter the password:");
}
void CheckPassword(string input)
{
if (input == password)
{
Terminal.WriteLine("Correct Password")
}
else
{
Terminal.WriteLine("Incorrect!");
}
}
}
}