Implementing leaderboards is turning out to be a lot more involved than I initially expected.
Of course, it seems pretty straightforward to have a call from the main system to simply add a score and a name for that score as the primary key in a dictionary. Additionally, it also seems straightforward to sort the list of key-value pairs by value.
Then, the next step that you realize that you need to do is implement serialization and persistence. Sure, you can just choose a file format and read and write that format.
But then, you get to the user interface, and realize that there are quite a lot of moving parts to get it all working together.
I’m using NGUI for Unity, and it’s been great. But NGUI also is so flexible that you still need to put in a lot of effort to get what you want to look right. In this case, I wanted to use either a UITable or UIGrid. The UITable allows variable width cells, since my leaderboards will list rank, name, and score for each row.
On top of having the grid or table correctly list each row item, I wanted the view to be scrollable, so that more entries can be displayed. NGUI has a UIScrollView just for this purpose, and managing that has required some effort as well.
After having the basic structure implemented, you then go about hooking up the leaderboard system to the rest of the game, so that you can make the appropriate calls to log the player’s score. I decided to log the player’s score at the game over screen, just like old arcade games.
Since I’m planning to support a local leaderboard at this time, I realized that I needed the user to identify himself/herself. This meant that I had to introduce the Android keyboard, which actually, wasn’t all that bad, but the fact is it was something that I slightly overlooked.
So, this all sounds like a bunch of complaining, but really, I just want to illustrate that even the simplest of features requires detailed interface and technical design to get as accurate of a time estimate as possible, so that you don’t get in trouble with your development schedule.