Got the ASCII art challenge with Anagram

The screen space was very small, so I can’t show my winning message, but everything is working and most of the art shows correctly with a line to return to the main menu.The formatting in the copy paste has broken my ASCII art here though.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Hacker : MonoBehaviour
{   
    // Game Configuration Data
    string[] level1Passwords = {"book", "computer", "chair", "card", "font"};
    string[] level2Passwords = {"jail", "badge", "cell", "gun", "swat"};
    string[] level3Passwords = {"prism", "mystic", "windstop", "nexus", "pisces"};
    string[] level4Passwords = {"bond", "cyber", "doughnut", "crypto", "exploit"};
    // member variable Game State
    int level;

    enum Screen {MainMenu, Password, Win};

    string Password;


    Screen currentScreen;
    // Start is called before the first frame update
    void Start()
    {   
        ShowMainMenu();
    }


    void ShowMainMenu()
    {   
        currentScreen = Screen.MainMenu;
        Terminal.ClearScreen();
        Terminal.WriteLine("Hello Hacker");
        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 the NSA");
        Terminal.WriteLine("Press 4 for the GCHQ");
        Terminal.WriteLine("Enter your Selection.");
    }

    
    void OnUserInput(string input) 
    {
        if (input == "menu")   //we can always go directly to main 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" || input == "3" || input == "4");
        if (isValidLevelNumber)
        {
            level = int.Parse(input);
            StartGame();
        }
        

        else if (input == "007")
        {
            Terminal.WriteLine("The name's Bond, James Bond.");
        }

        else 
        {
            Terminal.WriteLine("Please choose a level or \ntype 'menu' to return to the main menu");
        }
        
    }

    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;
            case 3:
                Password = level3Passwords[Random.Range(0, level3Passwords.Length)];
                break;
            case 4:
                Password = level4Passwords[Random.Range(0, level4Passwords.Length)];
                break;
            default:
                Debug.LogError("Invalid Level Number");
                break;

        }
        Terminal.WriteLine("Please Enter the correct Password, hint: " + Password.Anagram());

    }

    void CheckPassword(string input)
    {
        if (input == Password)
        {
            ShowWin();
        }
        else
        {
            Terminal.WriteLine("Wrong Password, please try again or \ntype 'menu' to return to the main menu.");
            Terminal.WriteLine("What is the password?");
        }

    }

    void ShowWin()
    {
        currentScreen = Screen.Win;
        Terminal.ClearScreen();
        WinScreen();
    }
    void WinScreen()
    {   
        switch (level)
        {
            case 1:
                Terminal.WriteLine("Have a book!");
                Terminal.WriteLine(@"

      ______ ______
    _/      Y      \_
   // ~~ ~~ | ~~ ~  \\
  // ~ ~ ~~ | ~~~ ~~ \\      
 //________.|.________\\     
`----------`-'----------'             
"
                );
                Terminal.WriteLine("Type 'menu' to return.");
                break;
            case 2:
                Terminal.WriteLine("Get out of jail!"); 
                Terminal.WriteLine(@"
================================
||     ||<(.)>||<(.)>||     || 
||    _||     ||     ||_    || 
||   (__D     ||     C__)   || 
||   (__D     ||     C__)   ||
||   (__D     ||     C__)   ||
||     ||     ||     ||  dwb||
================================
"
                );
                Terminal.WriteLine("Type 'menu' to return.");
                break;
            case 3:
                Terminal.WriteLine("Have a camera!");
                Terminal.WriteLine(@" 
      .-------------------.
     /-----.------.------/|
     |Kodak|__Ll__| [==] ||
     |     | .--. | ---- ||
     |     |( () )|      ||
     |     | `--' |      |/
     `-----'------'------'                    
"
                    );
                Terminal.WriteLine("Type 'menu' to return.");
                break;
            case 4:
                Terminal.WriteLine("Have a computer!");
                Terminal.WriteLine(@"
   +--------------+
   | .------------. |
   ||                 ||
   ||                 ||
   |+------------+|
   +-..--------..-+
  / /============\ \
 / /==============\ \
/____________________\
\____________________/
"
                );
                Terminal.WriteLine("Type 'menu' to return.");
                break;
            default:
                Debug.LogError("Invalid Error Reached.");
                break;
                

        }
        
    }
    
}

1 Like

Great job for getting everything to work!

Privacy & Terms