S
squirrelah
Guest
I am trying to recreate something very similar to what starcraft/warcraft series has as their UI in the lower right-hand corner and I just wanted some opinions on what the most efficient way to do this would be.
The main features I would like is basically whenever a specific type of unit is selected different commands will be available. A lot of units will have the same commands(attack, move, etc) but "Builder" units will be able to click or press a hotkey to open up more options(effectively options to place different kinds of buildings).
as far as I can tell there are basically two ways to do this.
1. Have a bunch of logic that determines when units are selected, it determines which options are available(so if you have a builder and a non-builder, does it let you open up the building menu?). This seems like it is going to be mandatory either way I go.
2.a Have 15 different(assuming I am using a 3x5 grid as the picture above shows, and I am using all available space) point_in_rectangle functions running at the same time, and constantly updating(in accordance to the camera moving). And then having a global.left_pressed variable, with a controller object so that if it is in the point_in_rectangle and global.left_pressed the option would be chosen(or if they press the appropriate hotkey).
2.b Or I can have 15 different objects(or instances of the same object but with slightly more complicated code) that are created/destroyed based on what the player has chosen. And I would use the Left-pressed Event for each instance/object. For example, if they have a builder and open the building box, it will destroy all the instances from the previous menu and create new ones that if left pressed(or hotkey is pressed) it will initiate the process of constructing a building.
These objects will also have to follow the player around based on how they are moving the map in order to stay attached the to GUI.
I genuinely can't tell which one would be harder to do or which one would be more efficient from an optimization standpoint. I'm also slightly less concerned about optimization although it is important and more worried about making sure that the controls are as fluid as they can be, and there's no way for someone to press a button and something not run quick enough for it to register in time. I don't think there will be a difference in this regard but I'd hate to start building it and then realize halfway through the way I am doing it there's going to be an inherent lag or something.