This Fsm is responsible for showing the Game Over Menu Interface when the player looses the game. It also deals with a lot of functionalites like responding to new highscore and registering new highscore with related user's data to the GameAnalytic server.
The Fsm articulates around three Global events
Here we only process the High Score label with the default content ( for optimization, it's better then doing the same thing every frame in the "Show the Menu" state.
RESTART GAME is fired by GAME MANAGER : Menu UI when the user press the restart button.
NEW HIGH SCORE
We simply react to a new high score so that we display it in the UI in the ""Show the Menu" state. note this we are using here a custom action "Set Gui Enabled", only because I did not wanted to create two UI states. You shoudl always avoid duplicating logics, in our case, without writing a custom action to enable gui, you would simply create two different UI states, the problem would be that you need to then also duplicate the Gender selection as well, etc, etc.
Note: When you encounter such duplicate issue, always double check and ask on the PlayMaker forum to see if someone has a trick to avoid duplicating states logic and maybe provide you with a custom actions to make the Fsm better, more optimized and flexible.
NEW HIGH SCORE is fired by GAME MANAGER : Score when it detects that the score is higher than the current one ( stored in the player preferences).
Here we finally show the Game Over GUI. We are presenting the user with a highscore section If the user achieved a new high score , and we show a simple user form for the purpose of demonstration to let the user save his profile. Noticeably, we ask the user to select gender, and we save this choice as a string 'male' or 'female' that we reinject then in the "Send GA User Event" state that sends a User GameAnalytics Event.
The GUI also present a button for the user to restart the game. note that it broadcast the event "RESTART GAME", even tho it's defined in this very Fsm, we ensure this way that other Fsm can also prepare themselves for a game restart.
The Save button of the GUI, will first broadcast a "SAVE HIGH SCORE" global event ( which will store the high score in the player prefs), and then sends a GameAnalytics User event to record the user profile. It's is strongly recommanded to do this for the GameAnalytics data to become useful during analysis.
In a real word project integration, the player profile will likely be exposed differently, like not asking for his number of friends, but instead looking up his facebook account or similar.
GAME OVER is fired by Lave : Floor when the ball touches the floor.
PlayMaker Custom Actions
- Set Gui Enabled
PlayMaker Actions used
- Get Fsm Float
- GUILayout Begin Area
- GUILayout Begin Centered
- GUILayout Begin Horizontal
- GUILayout Begin Vertical
- GUILayout Int Field
- GUILayout End Area
- GUILayout End Centered
- GUILayout End Horizontal
- GUILayout End Vertical
- GUILayout Flexible Space
- GUILayout Float Label
- GUILayout Label
- GUILayout Toggle
- Send Event
- Set bool Value
- Set String Value