Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Example-JavaScript
Example-Unity3d
PlayFab-JSON
CloudScript.js
README.md

README.md

Simple In-Game Cross Promotion

Description:

This example shows off how you can use Player Publisher Data to reward players that play more than one of your games. This mechanic depends on each client "checking-in" after Authentication. The check-in process occurs in Cloud Script's secure environment. Mechanics like this are a useful tool when running a cross-promotional campaign to your existing players.

Ingredients (Building Blocks):

Preparation:

  1. Under the Economy > Currencies section of the Game Manager add a Virtual Currency to match the following parameters:
Property Value Detail
Code GM Abbreviation for our VC
Name Gems Name of our VC
Initial Deposit 5 How many each player gets with a new account
  1. Next, under the Catalog tab, add a new catalog called CrossPromotional.

  2. Navigate back to the top-level catalogs view and click on the small black arrow in the top-right corner of the "CrossPromotional Catalog". Choose the Upload JSON option and provide this catalog file or use your own.

    • If using your own, ensure that you have items that can be granted to players.
  3. Under the Servers > CloudScript section of the Game Manager, upload & deploy this .js file, or ensure that yours has corresponding methods.

  4. Under the Content > Title Data section of the Game Manager, add the following TitleData record:

    • Key : CrossPromotionalRewards

    • Value:

      { 
        	"E5A" : "chromePaint",  
      	"632D" : "biggerHat" 
      }
  5. To fully test this recipe you will need to have multiple titles with the similar Cloud Scripts & TitleData. This pattern allows you to have different rewards for each individual catalog. Ensure that your 2nd and third titles match the values in your TitleData:CrossPromotionalRewards (See step #5).

Mechanic Walkthrough:

  1. Client obtains a valid session ticket via one of the various authentication pathways (required to make Client API Calls)
  2. Client checks-in via calling into the Cloud Script method "CheckIn".
  3. Cloud Script reads the Player Publisher Data and determines if the player is eligible for a reward.
  4. Award results passed back to client for updating the player.

Cloud Script:

In this example we are using Cloud Script to act as the secure server ensuring that the CheckIn logic processing and item grants happen on a trusted machine. The results of any actions performed in Cloud Script are then passed back to inform the client.


Unity 3d Example Setup Instructions:

Import the following asset packages into a new or existing Unity project:

  • Ensure you have the latest SDK here.
  • Ensure you have the recipe files here.
  1. Add assets to your project.
  2. Open to the CrossPromotional scene.
  3. Add your title ID to the CrossPromotional.cs script via the Unity Inspector.
  4. Run the scene and observe the console for call-by-call status updates.

JavaScript Example Setup Instructions:

  1. Copy this folder to your web server.
  2. Navigate to index.html
  3. Enter in your title ID * This example automatically generates a GUID on login; however, You may choose any id you like. * After logging in whatever id was used will be saved into your browser's localstorage
  4. Observe your browser's developer console for call-by-call status updates.