Arrays

//Game State
    int level;
    enum Screen {MainMenu, Password, Win };
    Screen currentscreen;
    string userpassword;
    string[] level1words = { "tape", "pilot", "roof", "books", "school" };
    string[] level2words = { "butter", "power", "patrick", "finale", "sunday" };

    // Use this for initialization
    void Start() {
        currentscreen = Screen.MainMenu;
        ShowMainMenu("Kevin");
    }

    void ShowMainMenu (string User)
    {
        currentscreen = Screen.MainMenu;
        Terminal.ClearScreen();
        Terminal.WriteLine("Hello " + User);
        Terminal.WriteLine("What would you like hack into?");
        Terminal.WriteLine("Press 1 for the local library");
        Terminal.WriteLine("Press 2 for the local police office");
        Terminal.WriteLine("Press 3 for the Pentagon");
        Terminal.WriteLine("Enter your selection:");
    }

    void OnUserInput (string input)
    {
        if(input == "menu")
        {
            print("the user typed " + input);
            level = 0;
            ShowMainMenu("Kevin");
        }
        else if(currentscreen == Screen.MainMenu)
        {
            RunMainMenu(input);
        }
        else if(currentscreen == Screen.Password)
        {
            ConfirmPassword(input);
        }

    }
    
    void RunMainMenu(string input)
    {
        if (input == "1")
        {
            print("the user typed " + input);
            level = 1;
            currentscreen = Screen.Password;
            userpassword = level1words[3];
            StartGame();
        }
        else if (input == "2")
        {
            print("the user typed " + input);
            level = 2;
            currentscreen = Screen.Password;
            userpassword = level2words[new Random().Next(level2words.Length)];
            StartGame();
        }
        else if (input == "3")
        {
            print("the user typed " + input);
            level = 3;
            currentscreen = Screen.Password;
            userpassword = "mahomes";
            StartGame();
        }
        else if (input == "420")
        {
            print("the user typed " + input);
            currentscreen = Screen.Win;
            Terminal.WriteLine("the dude abides");
        }
        else
        {
            print("the user typed " + input);
            Terminal.WriteLine("1.. 2.. or 3.. this isn't hard");
        }
    }

    void StartGame()
    {
        print("the user typed " + level);
        Terminal.WriteLine("you chose level " + level);
        Terminal.WriteLine("please enter your password");
    }

    private void ConfirmPassword(string input)
    {
        if (input == userpassword)
        {
            currentscreen = Screen.Win;
            Terminal.WriteLine("Thank you");
        }
        else
        {
            Terminal.WriteLine("Please Try Again");
        }
    }

Privacy & Terms