GameDev BlogPost 44: Stats
Stats UI, Surrender, Web Tool18.02.2020 - 16:11
After writing last weeks blogpost I spent a few more hours trying to come up with a good name, but still without success.
When I added the walking spawned entites last week, I only had a hardcoded value whether they were flying or not. Now I changed it so that it is set automatically based on the type of spawned entity. Then I started to work on a new stats UI. Origninally I only wanted to show it after the game ended, but then I realized, that it should be accessable at all times. It shows a number of stats per player like gold earned, gold spent, lives lost, buildings constructed, damage dealt, etc. Even though it may not be necessary, I thought it might be a good idea to make it sortable by the individual stats, so I spent some time on implementing sorting. I also had to add tracking for a few more stats to the player class, in fact I made a struct for all tracked stats, so it is easily extentable when I think of more stats in the future. Then I added a new layout to my menu class that distributes the children evenly in the horizontal space, which made the stats ui a lot easier to work on and I can also add a new label in the future and the layout will position it automatically.
When testing the stats ui with multiple clients, I found a bug, that buildings were unlocked twice when both players picked it. It took me a while to locate the exact problem, but it turned out to be an oversight from when I changed the item picking to be non locking (e.g. players don't need to wait for each other to pick anymore and can continue to play instead). Another thing that was bothering me for a while was the wave details button. Previously it had an "i" on it to indicate that it is clickable for more information, but when I added symbols to the wave icons, the "i" was barely visible and a new player wouldn't find the button. So I changed it and made it a proper button and only added the wave icon on top of the button.
Then I added a new button to the game over ui to open the stats ui. To make testing the game over ui easier I added a new command (/ff) to instantly surrender and lose. Then I worked on the design of the stats ui for the rest of the evening.
So far I had a big "Refresh" button on the stats ui to update the stats, but the more I thought about the more I realized that this was stupid. So I made the stats update on the fly instead, but added a 500ms cooldown to avoid updating the numbers too often and tank performance unnecessarily. Then I added a new #define to the code to switch between 7 elements and 5 elements, because I have been thinking about having only 5 elements recently. It would make balancing ever so slightly easier and also 7 elements may have the problem that you could avoid enemies of an element that you have problems with too easily. I need to do a lot of testing to find out what is better, but to test it the game would need to be able to work with only 5 elements too. In the afternoon I made a wooden bucket in Blender and then spent a lot more time thinking about names, but as can guess, still without a result.
I wanted to convert the web tool to also be able to support a 5 element tower set, but it was a little bit more complicated. Because I was using a n-n relationship between the sets and the buildings, I couldn't just add a new value to the sets table to differentiate between 5 and 7 elements, because having the same tower in 2 sets with a different number of elements would be weird. So instead I changed the relationship to 1-n so a building can only ever be in 1 set. I was able to remove the complete relationship table and I could remove a bunch of code and a few files from the web tool and cleaner code is always an improvement. I was also using a n-n relationship between the buildings and the effects and there was a big warning to tell me that if an effect is shared between multiple buildings, changing the effect would change it for all buildings and I never liked it. So I also removed that relationship and made it 1-n instead. It may take a little bit longer to create the same effect multiple times, but it's only a few seconds and makes the tool a lot more intuative to use, so I rather have it this way. Finally, I changed the ui, so that the light and dark element inputs are hidden when the set is only using 5 elements.
I only worked a bit more on the web tool and added conditions to the projectiles depending on the attack type of the tower, e.g. if a tower is using the line attack type, only the line type projectiles are options in the select.
by Christian - 18.02.2020 - 16:11