Store Offers Example¶
This Demo shows how to create Store for In-Apps and other in-game items. The store is using Balancy to manage all the data. It has not only ordinary offers, but also conditional offers. Such offers are available for players only after certain conditions are complete.
There are 2 types conditions:
- Reach certain level.
- Make N purchases.
You can use as many other conditions as you want to.
Before you begin¶
Such development method on Conditions proved to work extremely well in many projects. The code will be reusable for any game system and it's super easy for game-designer to view and edit all the conditions in one place.
How to start¶
- Clone Git Project.
- Open Project in Unity.
- Launch Scene Assets/StoreDemo/Scenes/SampleScene.unity.
- Press Play.
- Click on offers to purchase items. Please note that once you make 5 purchases, new offers appear.
Create your own Balance¶
- Open Balancy Dashboard
- Click on Examples button
- Find Store Offers example
- Click on Clone and confirm
You'll get your own version of Store Offers app on Balancy. Follow our documentation and replace in Unity Project GameId from our project to your newly created one.
Brief description of Balancy setup for Store Offers¶
- Item Model is the template for all items. In my example I've created Gems and Gold as Items.
- All items, including resources are stored in Inventories. Thus, we have Inventory Config. We'll speak more about Inventory in our next Example Project with Inventories.
Store Offer is the main Template for this Example Project. It looks like this
The first parameter is Icon. This is the image, which is used in the game store. We synchronized Unity Addressables with Balancy to make it work. You can find how it works here.
- Conditions is the most tricky part. I'll explain it in the next section
- Items list of items you get when you purchase the offer. I'm using component ItemWithAmount here - you can find it in the Templates list.
- Price are the items, which are taken during the purchase.
- There are other parameters, please check them by yourself.
Conditions are often used to hide some parts of a game from a player before he is ready.
Condition can be anything:
- player's level;
- find a specific item;
- killed a certain enemy;
You should implement Conditions logic only once in Balancy and in your code and after that you can use it everywhere: Tutorials, Quests, Dialogs,... I'm using them in Store Offers.
- To see offers with Ids 53 and 56 player must make 5 purchases.
- For this offer 50 player must have at least level 5 and make 10 purchases.
You can see this information in my table (screenshot above). ConditionChecker.cs is the class, which works with conditions. You should check its implementation. If you decide to add any new types of Conditions, you'll need to make changes only there.