So far with the solo challenge

The thing that’s the most difficult and I can’t seem to figure out is how to get input from the player while in the Password screen, and if I try to attach it to the previous (string input) it takes the input from the main menu screen into the password screen and uses that as the input. I’m not sure how to make it it’s own thing, or to possibly create a string input2 or something.

The code I have currently.

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

public class Hacker : MonoBehaviour {

//This is the "Game State"
int level;
enum Screen { MainMenu, Password, Win };
Screen currentScreen;

// Use this for initialization
void Start ()
{
    ShowMainMenu();
}

void ShowMainMenu ()
{
    currentScreen = Screen.MainMenu;
    Terminal.ClearScreen();
    Terminal.WriteLine( " Greed Hacker ");
    Terminal.WriteLine("  You gotta make a quick buck, and ");
    Terminal.WriteLine(" what's the quickest way to make it, ");
    Terminal.WriteLine(" solving passwords and selling them!");
    Terminal.WriteLine("--------------------------------------");
    Terminal.WriteLine("Write 1: School Password - $50");
    Terminal.WriteLine("Write 2: Minecraft Password - $100");
    Terminal.WriteLine("Write 3: Youtuber Password - $500");
    Terminal.WriteLine("--------------------------------------");
    Terminal.WriteLine("Type your selection here -");
}


// This should only decide how to handle input, not actually do it.
void OnUserInput(string input)
{
    if (input == "menu" || input == "Menu") //We can always go directly to main menu
    {
        ShowMainMenu();
    }
    else if (currentScreen == Screen.MainMenu)
    {
        RunMainMenu(input);
    }
}

void RunMainMenu(string input)
{
    if (input == "1")
    {
        level = 1;
        StartGame(input);
    }
    else if (input == "2")
    {
        level = 2;
        StartGame(input);
    }
    else if (input == "3")
    {
        level = 3;
        StartGame(input);
    }
    else if (input == "666")
    {
        Terminal.WriteLine("S̶͍̳͊̋͐͜p̸̪̈͗͊ó̴͚̺͎̈͝ỏ̷͍͊́ó̷̹̝͆̀o̸͕̖͂͋͠ö̷̬͇̚͜ò̷̞̄͋o̸̞͇̠͌ȍ̴̦͘k̸͎͒̋̒ẏ̶̭͚̺ -");
    }
    else if (input == "hello" || input == "Hello" || input == "hi" || input == "Hi")
    {
        Terminal.WriteLine("Hi, but please type an actual number -");
    }
    else if (input == "69" || input == "420")
    {
        Terminal.WriteLine("Nice, but try again -");
    }
    else
    {
        Terminal.WriteLine("Uh. Try again -");
    }
}

void StartGame(string input)
{
    currentScreen = Screen.Password;
    Terminal.ClearScreen();
    Terminal.WriteLine("You chose password #" + level + " -");
    Terminal.WriteLine("Please enter your password -");
    if (currentScreen == Screen.Password)
    {
        if (input == "test")
        {
            Terminal.WriteLine("Congratulations! You got it right!");
        }
        else
        {
            Terminal.WriteLine("You got it wrong.");
        }
    }
}   

}

Privacy & Terms