// here is my version of the solo challenge,
// using stuff I picked up from the Unity manual or from google
// or had discovered before while messing around with coding or Unity
// (not sure why the board only sees part of it as code)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hacker : MonoBehaviour
{
//Game state
string chosenName = “stranger”;
int level;
enum Screen { MainMenu, Password, Win }
Screen currentScreen;
// Start is called before the first frame update
void Start()
{
ShowMainMenu("stranger");
}
void ShowMainMenu(string username)
{
currentScreen = Screen.MainMenu;
Terminal.ClearScreen();
Terminal.WriteLine("Hello, " + username);
Terminal.WriteLine("You've made it this far");
Terminal.WriteLine("Choose your battles wisely");
Terminal.WriteLine("");
Terminal.WriteLine("You can crack one of three passwords");
Terminal.WriteLine("");
Terminal.WriteLine("Enter 1 for library;");
Terminal.WriteLine("Enter 2 for police station;");
Terminal.WriteLine("Enter 3 for NASA.");
Terminal.WriteLine("");
}
void RunMainMenu(string input)
{
int.TryParse(input, out level);
if ((1 <= level) && (level <= 3))
{
StartGame();
}
else
Terminal.WriteLine("input unrecognized");
}
private void StartGame()
{
Terminal.WriteLine("You have chosen level " + level);
currentScreen = Screen.Password;
Terminal.WriteLine("Please enter your password");
}
void WinGame()
{
Terminal.WriteLine("Password correct.");
currentScreen = Screen.Win;
}
void OnUserInput(string input)
{
if (input == "menu")
{
ShowMainMenu(chosenName);
}
else if (currentScreen == Screen.MainMenu)
{
RunMainMenu(input);
}
else if (currentScreen == Screen.Password)
{
if ((level == 1 && input == "book") || (level == 2 && input == "intervention") || (level == 3 && input == "armstrong"))
{
WinGame();
}
else
{
Terminal.WriteLine("Password incorrect, try again");
}
}
if (input == "my name is Bogdan")
{
chosenName = "Bogdan";
ShowMainMenu(chosenName);
}
}
}