- Home /
Trying to make a hacking minigame...
So I am trying to make a hacking minigame where you can access files on computers in the game, but I can't figure out the best way to make a "file structure" on the computers. I'd like to have multiple directories with different files in them that can be accessed, edited, and deleted. I'm just not sure on the best way to get the whole thing started, I don't think using lists would work as some directories would have files and other directories in them. Any ideas?
Well the file directory doesn't actually have to be a functional file directory right, it's just part of the game? So you are simulating the file directory in the game play?
You might need a more experienced programmer to answer this kind of thing depending on how crazy/realistic you are going for.
Right now if I was just going to randomly jump into something like that I would use OnGUI() for all the buttons(buttons would simulate how to access the folders/text fields/etc) and from there call functions to update the data. So the OnGUI() would simulate the computer system visually and you would use separate functions to actually handle their input in the folders and to manipulate the data if there are certain objectives they are going for.
Not sure how helpful that will be it seems like if you are trying to program something like this you would already be leaps and bounds above what I just suggested in your understanding of how to set it up.
Classes and Lists... it's as simple as that
It's quite easy to replicate the structure of a file system.
Take a look at this question. You'll find some ideas there.
Answer by vexe · Sep 07, 2013 at 01:56 PM
Woot! what a happy coincidence, I happen to be doing the VERY SAME THING! - But I think I'm a little bit ahead of you ;-)
Cutting, (I didn't need copying, but it's just as easy) pasting, renaming, opening files/folders, text/audio/video/image files, go back, navigable addressbar, scrolling, deleting, recycle bin, multiple selection, unique naming, etc :D
I'm gonna probably make this available at the store after we release our game.
But if you wanna do this in a way that is easy, and convenient like the way I did it, then first you gotta get NGUI. Learn the basics from Michael (ArenMook), then it's smooth sailing from there :) - And don't forget to make an account at NGUI's forums, you WILL need a LOT of help at the beginning.
The rest is all pure programming and organizing code and class design, I hope you're good at OOP. If you're only willing to make a file manager (just like like you see in the pics, not a whole OS like what I think I'm gonna be doing), then you could have classes like:
FileManager:
RootFolder
CurrentFolder
RecycleBin
FolderStack (for going back)
Clipboard
Cut();
Copy();
Paste();
...
FolderContent:
background
icon
label
Open();
Delete();
Rename();
MoveTo();
...
^ ^
^ ^
FILE Folder
List <FolderContent> Contents
List <FILE> Files // keeping a list of files and folder for convenience and easy access
List <Folder> Folders
GetFile(string fileName, bool recursive);
GetFolder(string folderName, bool recursive);
GetUniqueName(string forName);
...
^ ^
^ ^
^ RecycleBin
^ RestoreAll();
^ DeleteAll(); // Clear it out - destroys contents completely
AudioFIle, TextFile, VideoFile, ImageFile, etc
(Arrows mean children - inheritance)
(Here's how I implemented the Clipboard I used a queue, but you could use a list if you like)
You're gonna need a couple more stuff. Sorry I'm not giving details. But if you so decide to go and get NGUI, let me know and I will be more than happy to help you, and even share some code :) But that doesn't mean that you don't try yourself first.
Doing this in UnityGUI is really a pain in the butt! Don't even think about it!
There are a lot of quirks and gotchas in NGUI and headaches in the beginning, but once you get it right, NGUI isn't just a GUI system, it will offer a LOT of powerful tools, like a brand new event handling system. It will help you solve problems in much better and efficient ways than UnityGUI.
Good luck!