Since the completion of my proposal I have been reviewing my prototype to see what stage I am at, and where to go. I decided to get some of the basic mechanics covered first.
Going through both my prototype and my MoSCoW Analysis created for my proposal I started to workout what area to start working on properly. As already I had a suitable camera, very basic controls, one unit type, two building types, basic building mechanic, basic selection mechanic and basic pathfinding. As it had been a long time since properly analysing the code and viewing what I have I got a fresh look at it. All RTS games are UI driven as they are the way for the player to interact with the game compared to through keyboard inputs like you would have in say an FPS game. Therefore I restructured my whole UI to start having elements where they should be. Below is an image showing the basic bottom bar. The left square in this bar is for object options such as Build or Train. The right square shows the selected object type (temp placeholder). Then the middle bar represents where all the selected objects can be seen.
After making these tweaks I started looking into improving the selection mechanic. As what I had already allowed for one unit or building to be selected, but as I thought about it more, I started to see the importance of the selection mechanic in the game. Therefore I started coding the ability to select multiple units. Now there are three different ways multiple units can be selected in an RTS game. They can be selected normally, then units can be added by shift clicking, or by double clicking on one unit to select all of that type on screen, or finally a drag box. The first change was to change the selected object variable into a list to hold all of these objects. As multiple units were being selected I looked into the use of projectors to show a visual indication of selected units. I went for a basic ring around the base of the unit and a square on buildings.
Shift Click: Shift clicking was the easiest to add, as it is the exact same as the selecting, except rather than deselecting before it selects an object, it will just select it and add it to the list. Unless the object is already selected in which it will deselect that object. Image to the left shows three units that were selected individually by shift clicking.
Double Click: Double clicking was slighty more challenging but not by much. First the double clicking mechanic had to be implemented as this isn't registered as an input. But by having a bool variable set within a certain time frame of clicking after already clicked can get this working. Then when in that double clicking state, it will deselect all units, then select all of the type that was double clicked on by searching through tags. The Image to the right shows two worker units that were selected by double clicking on one unit. Note: The worker ui remains as later on multiple workers can help build a building.
Drag Box: Drag box is the most complicated. It works by clicking and dragging over units on the screen. To actually do this stage could be done in different ways. From my research I chose to go ahead and create another list of game objects that were on screen, then each object will update to the selecting script if it's world position to screen position is within the screen position boundaries. Then when the player clicks and drags it only has to check the objects on screen list, and whether those objects screen positions fall within the box the player drew with their mouse. Finally all that was needed was to draw this box so the player had an indication of what they are selecting. The Image to the left shows two units that were selected with a drag box over them. Note: Objects can be added as well using the drag box and holding shift but not deselected.
Once all of this was added there needed to be more UI elements to show the player what units were selected, as during an actual game, they may select the units and move the camera to a location they want the unit to go to. Therefore, on the UI it would be great if player could confirm what they have selected. Here is that UI:
Temporary icons for each unit type and building type were made to act as a placeholder. But this shows where the icons will go and roughly how they are positioned. An additional feature that was added was the ability to deselect a unit from the list or select just that unit from the icons on the UI. When the list is greater than multiples of 23 the icons will be put onto a new line. A common thing some people don't like in RTS games is the limit on how many units can be selected. As an ambitious idea for now it has all been added to a scroll view allowing all units to be seen in this window and not limited to how many could fit in a static box.
That sums up a lot of work with a selection mechanic. The plan before next post is to try and get resources added and dispalyed, and look into some way of storing data that buildings and units might need like cost.