Free prize functionality is a way of encouraging users to revisit or keep playing your game by giving them a reward after a given period of time.
A countdown within specified bounds is initiated after which a prize is offered to the user. The default implementation allows you to specify a number of coins that they can win, however you can override this to provide any reward that fits your game.
The FreePrizeManager component is the basis of the free prize functionality and should be added to a gameobject in your scene. It lets you configure how the freeprize will work including:
Delay Range – The delay between collecting one prize and the next countdown starting. 0 = no delay
Time Range – The countdown range before the user can collect a new prize.
Value Range – The value that is awarded when they collect a free prize (coins in the default implementation).
Prize Dialog Closed Audio Clip – An optional audio clip that will be played when they close the collect free prize dialog.
Content Prefab – A prefab that will be used for extending and customising the original functionality and display.
Content Animator Controler – A controller that will be used for animating the contents of the free prize window when it is displayed and closed.
Content Shows Buttons – If false then the dialog Ok button will be displayed immediately, otherwise it is assumed this is triggered by the custom content.
Note: The FreePrizeManager is persistant and so the gameobject that it is added to will exist across scene changes. You might consider adding this to the same gameobject where you added the GameManager.
With the FreePrizeManager in place, you can use the EnableIfPrizeAvailable component to show different game objects depending upon the current state. You can link the Prize Available option to a button with the OnButtonClickShowFreePrizeDialog component to show the Free Prize dialog, and the Prize Countdown option to a text box with the TimeToFreePrizeDisplay component added to show the remaining time.
The information in the tutorial should hopefully be enough to get you up and running.
Please consider supporting us by downloading the Unity Asset Store package that contains code from the tutorial and other samples and resources. It also helps support our effort in maintaining this framework.
Check out the following games for a live sample of how the Free Prize functionality can easily used and customised.
Air Hockey Dreams – Look on the Level select page.
Space Minesweeper – Look on the Level select page.
To verify the functionality of the prize manager and the enable free prize components, you should perform the following tests.
To reset the tests, either:
- Delete the app and reinstall (iOS / Android)
- Clear app all data from settings (Android)
- If you have the cheat component added press ‘left shift + R’, or use the component editor buttons if running in the editor
- Use the FreePrizeManager component editor buttons if running in the editor
Free Prize Button and Dialog
- Reset the tests as described above and then start the game.
->Verify that the time to next prize is within the bounds you entered.
- Move to another scene within the game and then return to the scene showing the countdown.
-> Verify the time has decreased by the time taken.
- Exit the game and then restart.
-> Verify that the time has decreased by the time taken.
- Wait until the countdown has completed and revisit the free prize scene.
-> Verify that the free prize button is shown.
- Click the free prize button.
-> Verify the free prize pop up is awarded and that coins within the given range are added to the users score.
-> Verify that the countdown is restarted within the bounds specified.