I have already added level 3 lol!

using UnityEngine;

public class Hacker : MonoBehaviour {

//Game configuration

const string menuHint = “You may select menu at any time”;

string level1passwords = {“book”,“self”,“aisle”,“password”,“font”,“borrow” };

string level2passwords = {“gun”,“lockerroom”,“criminals”,“uniform”,“rifle”};

string level3passwords = {“soldiers”,“technology”,“experimentarea”,“Aliens”};

//Game State

int level;

enum Screen { MainMenu, password , Win };

Screen CurrentScreen;

string Password;

// Start is called before the first frame update

void Start() {

   

    ShowMainMenu ();

}

 void ShowMainMenu () {

   CurrentScreen = Screen.MainMenu;

   Terminal.ClearScreen ();

   Terminal.WriteLine("What Would Would you Like to hack");

   Terminal.WriteLine("press 1 for local librairy");

   Terminal.WriteLine("press 2 for Poilce station");

   Terminal.WriteLine("press 3 for Area 56");

   Terminal.WriteLine("Enter for your selection");

 }

      

  //Giving input

  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" || input == "3");

     if (isValidLevelNumber)

     {

       level = int.Parse(input);

       AskForPassword();

     }

        if (input == "1")

        {        

           

            Password = level1passwords[2]; //todo changes later

           AskForPassword();

        }

        else if (input == "2")

        {

           

             Password = level2passwords[1];

             AskForPassword();

       }

        else if (input == "3")

         {

             

              Password = level3passwords[0];

             AskForPassword();

         }

         else if (input == "007")

        {    

             Terminal.WriteLine ("develouped at 11/19/2023");

         }

               else

          {

            Terminal.WriteLine ("Error please choose a valid level");

            Terminal.WriteLine (menuHint);

          }

 }



    }

   void AskForPassword()

    {

   

    CurrentScreen = Screen.password;

    Terminal.ClearScreen();

    SetRandomPassword();

    Terminal.WriteLine ("ENTER PASS: hint =  " + Password.Anagram ());

    Terminal.WriteLine (menuHint);

    }

      void SetRandomPassword()        

    {

    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;

        default:

        Debug.LogError("Invalid Level number");

        break;

     }

           

    }

    void CheckPassword (string input)

    {

     if (input == Password)

    {

     DisplayWinScreen();

     }        

    else

    {

     AskForPassword();

     }

  }

     void DisplayWinScreen()

  {

    CurrentScreen = Screen.Win;

    Terminal.ClearScreen();

    ShowLevelReward();

    Terminal.WriteLine (menuHint);

  }

    void ShowLevelReward()      

  {

    switch(level)

    {

      case 1:

             Terminal.WriteLine("Thats a Magical Book!?!?");

             Terminal.WriteLine(@"

             

_______

/ /,

/ //

/______//

(______(/

              ");

              break;

 

     case 2:

            Terminal.WriteLine("There YOU hAvE A PrIsinOr Cell kEy!!");

            Terminal.WriteLine(@"

               __

              /o \_____

              \__/-""--)-

              ");

              break;

       case 3:

            Terminal.WriteLine("Thats it! You WOn!");

            Terminal.WriteLine(@"

 ___

 _YOU WON!_____

|,----------.  |\

||           |=| |

||          || | |

||       . _o| | | __

|`-----------' |/ /~/

 ~~~~~~~~~~~~~~~ / /

                 ~~

              ");

              break;

              default :

               Debug.LogError("Invalid Level Reached");

               break;

  }

}  

}

Privacy & Terms