WinScreen3

using UnityEngine;

public class Hacker : MonoBehaviour
{

const string menuInfo = "You may type menu at any time to back to main menu";
int level;
string password;
string[] level1Password = {"GUN", "PASSWORD", "SUSPECT","DNA","ENEMY" };
string[] level2Password = { "MILLIONS", "JACKPOT", "BIG WIN", "MONEY", "FINANCIAL FREEDOM" };
string[] level3Password = { "SPECIAL FORCES", "CRIME", "SPECIALIZED WEAPONS", "SNIPER", "COORDINATED ACTION" };
enum Screen {MainMenu, Password, Win };
Screen currentScreen = Screen.MainMenu;


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


void ShowMainMenu()
{
    currentScreen = Screen.MainMenu;
    Terminal.ClearScreen();
    Terminal.WriteLine("What would you like to hack into?");
    Terminal.WriteLine("Press 1 for the FBI");
    Terminal.WriteLine("Press 2 for the EURO JACKPOT");
    Terminal.WriteLine("Press 3 for the NASA");
    Terminal.WriteLine("Enter your selection: ");
}

void OnUserInput(string input)
{
    if(input == "menu" || input =="MENU")
    {
        level = 0; 
        ShowMainMenu();
    }

    else if (currentScreen == Screen.MainMenu)
    {
        RunMainMenu(input);
    }

    else if(currentScreen == Screen.Password)
    {
        Password(input);
    }
    

}

void RunMainMenu(string input)
{

    bool isValidLevelNumber = (input == "1"|| input =="2"|| input == "3");
    if (isValidLevelNumber)
    {
        level = int.Parse(input);
        StartGame();
    }
    else if (input == "3")
    {
        password = level3Password[3];
        StartGame();
    }
    else if (input == "why not")
    {
        Terminal.WriteLine("because");
    }
    else
    {
        Terminal.WriteLine("Wrong choose, try again later");
    }
}

void StartGame()
{
    currentScreen = Screen.Password;
    Terminal.ClearScreen();
    SetRandomPasswor();
    Terminal.WriteLine("Enter your password, hint: " + password.Anagram());
    Terminal.WriteLine(menuInfo);
}

private void SetRandomPasswor()
{
    switch (level)
    {
        case 1:
            password = level1Password[Random.Range(0, level1Password.Length)];
            break;
        case 2:
            password = level2Password[Random.Range(0, level2Password.Length)];
            break;
        case 3:
            password = level3Password[Random.Range(0, level3Password.Length)];
            break;
        default:
            Debug.LogError("Invalid level number");
            break;
    }
}

void Password(string input)
{
    if (input == password)
    {
        DisplayWinScreen();
    }
    else
    {
        StartGame();
    }
}

void DisplayWinScreen()
{
    currentScreen = Screen.Win;
    Terminal.ClearScreen();
    ShowLevelRewards();
}

void ShowLevelRewards()
{
    switch (level)
    {
        case 1:
            Terminal.WriteLine("Congratulations you are in");
            Terminal.WriteLine("There is your reward");
            Terminal.WriteLine(menuInfo);
            break;
        case 2:
            Terminal.WriteLine("Congratulations you are the WINNER");
            Terminal.WriteLine("Write your bank account details to get a money");
            Terminal.WriteLine(@"

             MONEY MONEY MONEY !!!       

            ");
            Terminal.WriteLine(menuInfo);

            break;

        case 3:
            Terminal.WriteLine("Congratulations you are in");
            Terminal.WriteLine("All data is yours");
            Terminal.WriteLine(menuInfo);

            break;

        default:
            Debug.LogError("Invalid level reached");
            break;
    }

    
}

}

Privacy & Terms