What design pattern is best for implementing trophies in a game? I am not a games developer, but is it easy for each player's action to check and update conditions that satisfy 50-100 trophies at any time aside from everything that goes on in the game engine? How is it best done?
I think the best way to design something like this is first to inspire yourself from the best, Assassins Creed 2 is a good example.
You find a trophy for each chapter and one for completing the game on each difficulty. These are generally 'Complete Chapter x' or 'Defeat Boss xyz'. I would prefer having really exmplcit names eg 'Complete Chapter x', as you don't want the player to check his trophies every time he finishes a chapter because he thinks he got someting cool.
You also should have trophies that will push the player to play how YOU want him to.
For exploration you will have a collectible trophy, for fighting you will have a 'Kill x Guards' etc. These can help to force the player to explore more, and even learn to play better.
The biggest difficulty in my sense is Hidden Trophies. The name needs to imply what needs to be done but without spoiling any of the game. You don't want for example 'Kill the Traitor' when you only have one Ally in the game. These should also be some of the hardest trophies where people could rarely get them without specifically trying for it.
There can often be half of the total trophies that are secrets.
Of course, 'Lolphies' are also good and will inspire or reward a certain type of play.
Trophies are very game-dependant though and require a lot of thought!
|show 4 more comments|
Basically you want at least 3 types of data structures:
Counters: This happened. A gun was fired. An enemy was killed. This polygon was touched.
Conditions: If Counter X > 500. If Counter Y = 0.
Trophy: If condition A is met, this condition is visible. If condition Y is met, this condition is invisible.
In your game code you sprinkle counters firing where appropriate and forget about it.
Some other class either in response to an event of the counter firing or periodically will check the list of conditions and see if they've been met. After, again either in response to an event or periodically trophy's will check if all their conditions are met. If so it gets rewarded.
Your UI can iterate all trophies and display the visible conditions. If no conditions are visible, then the trophy is hidden.
Everything is separate and during the update loop all you need to do is increase a number and maybe flag the data as changed, anything else can be deferred to when there's more time / even a separate thread.
If you are asking for a technical way: I'm a very, very noob game developer, but this is how I implemented my AchievmentManager (I think it's the observer pattern):