Section 2, Lecture 18: My Code So Far

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

public class Hacker : MonoBehaviour {

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



    void ShowMainMenu()
    {
        // Clears the screen and displays the main menu

        Terminal.ClearScreen();

        Terminal.WriteLine("PLEASE SELECT TARGET SYSTEM");
        Terminal.WriteLine("===========================");
        Terminal.WriteLine("");
        Terminal.WriteLine("1 - Auxiliary Subsystems");
        Terminal.WriteLine("");
        Terminal.WriteLine("2 - Security Kernel");
        Terminal.WriteLine("");
        Terminal.WriteLine("3 - Self-Destruct Protocol");
        Terminal.WriteLine("");
        Terminal.WriteLine("---------------------------");
        Terminal.WriteLine("Awaiting user input: ");
    }



    void ShowHelpMenu()
    {
        // Clears the screen and displays the help menu

        Terminal.ClearScreen();

        Terminal.WriteLine("USER GUIDE");
        Terminal.WriteLine("==========");
        Terminal.WriteLine("");
        Terminal.WriteLine("Type 1 to select Auxiliary Subsystems");
        Terminal.WriteLine("Type 2 to select Security Kernel");
        Terminal.WriteLine("Type 3 to select Self-Destruct Protocol");
        Terminal.WriteLine("Type menu to return to the main menu");

    }



    void OnUserInput(string input)
    {
        // Checks user input and prints lines to the terminal respectively

        if (input == "menu") // if the player types "menu", calls the ShowMainMenu() method
        {
            ShowMainMenu();
        }

        else if (input == "1") // if the player types "1", prints a string to the terminal
        {
            Terminal.WriteLine("Auxiliary Subsystems selected");
        }

        else if (input == "2") // if the player types "2", prints a string to the terminal
        {
            Terminal.WriteLine("Security Kernel selected");
        }

        else if (input == "3") // if the player types "3", prints a string to the terminal
        {
            Terminal.WriteLine("Self-Destruct Protocol selected");
        }

        else if (input == "help") // if the player types "help", calls the ShowHelpMenu() method
        {
            ShowHelpMenu();
        }

        else if (input == "Terminal.ClearScreen();") // if the player tries to clear the screen with code, mock them
        {
            Terminal.WriteLine("I suppose you think you're terribly clever don't you?");
        }

        else Terminal.WriteLine("ERROR:" + input + (" is not a recognized command")); // if the player types anything else, print an error to the terminal
    }

	// Update is called once per frame
	void Update () {
		
	}
}
1 Like

Evan,

I really dig the choices you’ve made for your menus. Target System is very clever as a theme and I love how you mess with your player. The help menu is such a good idea, that would surely clear things up for lost users! I also like the consistency you have in your menu title formatting – using capital letters and ==== as underlines – I feel like it sets the mood!

Very well organized!
Good job! :slight_smile:
GK

simple dry humor and neat coding, I like it

Privacy & Terms