woensdag 8 december 2010

Unlock them all!

Many games today feature so called 'Trophies' or 'Achievements'. Also some of our own games have them. The time management game won't be an exception. While playing, the player can unlock trophies. For example, by delivering 10 banana's to the monkey, or by filling up 10 buckets with water. Hopefully this will give the game a higher replay value. People have to play the game more than once to unlock all the trophies. These will be saved locally on your computer. So after you've played, you can comeback and play again without losing your progress :)

In the time management game there will be around 25 trophies to unlock. Varying from simple ones, such as delivering 10banana's to a monkey and trophies which are very hard to unlock. Finishing the complete game with a perfect score for example. To manage these I created a system which keeps track of each trophy's progress. I started by creating a data array which contained a list of trophies and their states, locked or unlocked. This was of course the easy part of the system. Nothing fancy. The difficult and cool part of the system is a second array which keeps track of each trophy's progress. All the trophies have different 'Goals'. So they can't use the same 'progress' data all the time. Therefor each trophy's progress is a unique list. This list consists out of 2 values. One value determines the target 'Score' of the specific trophy. We can say, the target of the 'BananaTrophy' = 10. The player has to deliver 10 banana's to unlock the 'BananaTrophy'. Then the other value in the list is the progress, or better said, the amount of banana's delivered in the game. When the player delivers a banana the progress value of the 'BananaTrophy' gets increased. Once per frame I run a function to check if there are any trophies that have enough progress to meet the target. If so, the trophy gets unlocked and the player gets a notification.

Doing it this way makes it very manageable for me to see if a trophy gets unlocked, is unlocked, is almost unlocked etc etc. Since it is dynamic and not 'hardcoded' it can be expanded without much of a trouble. One thing that has to be hardcoded though is the part where the trophy's progress value gets increased.

-- Joep

Geen opmerkingen:

Een reactie posten