Skip to content

1 Unicorn Battle Backend Guide

Paul Gilmore edited this page Nov 14, 2017 · 16 revisions

Unicorn Battle is a great demo game to show off how PlayFab works. Like most modern games, it's designed to be operated as a service, and depends on a back-end platform like PlayFab to operate the game post-launch.

These instructions describe how to set up your own personalized back-end for the game, so you can experiment with changing data and using all the PlayFab features without affecting anyone else. Following these steps, you will first create a new title, then upload a series of configuration files to that title using a custom UB_Uploader tool to support the Unicorn Battle game.

This project also serves as an example of how to use the Admin API to configure a title. Tools like this can be helpful when you need to frequently reset large amounts of configuration data.

Setting up the Unicorn Battle backend

There are just a few steps to set up the Unicorn Battle backend.

  1. Create a new title
  2. Navigate to Title -> Admin -> Billing -> Add Credit Card
    • Unicorn Battle uses the CDN feature, which is not free
    • You will need a credit card on file for your title to access CDN features
  3. Download the required files to a Windows PC
  4. Run our tool to upload the configuration data and set up the new title

Let's get started!

Create the new title

  1. Go to the Game Manager and click "Create a new game"

  2. Fill out the page for the new title. You can use our Unicorn Battle icon for the title image if you'd like. Click "Create Game".

  3. You should now see your new title appear in your game studio. If it's not there right away, wait a minute then refresh your browser since it makes take a few seconds to show up. Take note of the Title ID for your new title -- you will need that title ID in future steps.

  4. You will also need your Developer Secret Key. This will be used to authenticate your use of the Admin API, and allow the uploader tool to modify settings for your game. To locate this key, click on your game, then click on Settings. Locate the secret key.

  5. Open your title in Game Manager, navigate to: Admin -> Billing -> Add A Credit Card

Download required files

  1. Download the Unicorn Battle configuration files, and UB_Uploader Tool folder to a Windows PC.

Optionally, if you'd like to see how it works, you can open the solution in Visual Studio.

Configure for your new title

Before you can upload the configuration files, you must edit the files with the Title ID for your own personal Unicorn Battle title that you set up earlier.

  1. Locate the "UB_Uploader/PlayFabData/" folder that you downloaded just now.
  2. Edit the "TitleSettings.json" file with your Title ID and corresponding Developer Secret Key that you retrieved earlier. Save the file.

Upload the configuration files to create your own back-end for Unicorn Battle:

You are now ready to upload the files.

  1. Locate the "UB_Uploader/" folder that you downloaded just now. Run the "UB_Uploader.exe" tool.
  2. You should see a log of the changes the tool made to your title, with no errors.
  3. Log into Game Manager
  4. Click the Unicorn Battle demo title.
  5. Navigate to Settings then API Features
  6. Ensure that your clients are allowed to post player statistics. * note: this would not be a good idea if this was a competitive game.

Post Setup

What did UB_Uploader just do?

PlayFab is designed around combining systems specializing in availability and scalability into a single service. In doing so, we have many service components that can be found aggregated within our web API portal.

While complete coverage of components is outside the scope of this document, here are the specifics as they are used by Unicorn Battle:

  • Game Manager > Settings > Title Data: These fields enable the developer to fine tune their player's experience while not having to update the client code.
| Key | Value Type | Details
---: | :---: | :--- 
Achievements | JSON Dictionary | The threshold data for evaluating achievements.
CharacterLevelRamp | JSON Dictionary | The level up curve thresholds
Classes | JSON Dictionary | The defining values for our character classes
CommunityWebsite | String | URL to open when "Community Website" is clicked in-game.
DefaultBossCreeps | JSON Dictionary | A collection of enemy boss encounters. Used by the quest system.
DefaultCreeps | JSON Dictionary | A collection of basic enemy encounters. Used by the quest system.
DefaultMegaCreeps | JSON Dictionary | A collection of tough enemy encounters. Used by the quest system.
DefaultHeroEncounters | JSON Dictionary | A collection of hero encounters. Used by the quest system.
DefaultRareCreeps | JSON Dictionary | A collection of rare enemy encounters. Used by the quest system.
DefaultStoreEncounters | JSON Dictionary | A collection of merchant encounters. Used by the quest system.
Events | JSON Dictionary | The event calendar for running in-game events
Levels | JSON Dictionary | A collection of locations. Used by the quest system.
MinimumInterstitialWait | Number | The number of seconds to wait during the interstitial screen.
Offers | JSON Dictionary | A collection of offers. System currently in-development.
Sales | JSON Dictionary | The sales calendar for running in-game sales
Spells | JSON Dictionary | The overall spells table shared by Players and NPCs
StartingCharacterSlots | Number | How many character slots are provided for free.
  • Game Manager > Promotions > Title News: This component is being used to drive the in-game tips system (displayed during interstitial loading screens)

  • Game Manager > Server > Cloud Script: Cloud-hosted game logic for processing quests and other transactions

    Method Details
    CreateCharacter Creates a new Character
    DeleteCharacter Deletes and existing Character
    InitializeNewCharacterData Defines values for a new character
    SaveProgress Saves character progress after a quest
    SubtractLife Removes lives from a character
    PurchaseItem Purchases an item for a character.
    ConsumeItem Consume uses from a character's ItemInstance
    UnlockContainer Try to Unlock and unpack a container for a character
    GetCharacterStatistics aggregate and return statistics for all owned characters
    UpdateCharacterStats update statistics for a character
    EvaluateAchievements determine if an achievement has passed its threshold
    TransferItemToPlayer Transfers an ItemInstance to a Player's inventory
    TransferItemToCharacter Transfers an ItemInstance to a Character's inventory
    TransferVcToPlayer Transfers Virtual Currency to a Player's inventory
    TransferVCToCharacter Transfers Virtual Currency to a Character's inventory
  • Game Manager > Economy:

    • > Currencies: Defines the mediums of exchange for this title
    • > Catalogs: A collection of CatalogItems. These Items can be edited in the Game Manager
    • > Drop-tables: Are weighted distribution tables that control the probability of getting specific items
    • > Stores: Are subsets of CatalogItems that makeup in-game stores. These items can be sold at prices differing from the primary catalog.
  • Player Statistics Definitions: Contain settings that alter the default behavior of Player Statistics

    • Additional information on this topic can be found here
  • Content Deliver Network: While not accessible via GameManager, everything we need exists in the Admin API.

    • Unicorn Battle uses simple AssetBundles that contain updated art for sales and events.
    • Additional information on this topic can be found here.

Next Steps