Heroic Labs Documentation

Virtual Store #

The virtual store in Blocks and Cities by Kyoso Interactive.
The virtual store in Blocks and Cities by Kyoso Interactive.

A virtual store is a way for players to spend hard currency and/or soft currency to obtain consumables, collectables, or other items relevant in your gameplay. Hard currency can also be used to purchase soft currency.

The virtual store is defined in the GDK using a JSON file and can be configured to support a variety of purchase types, including single purchases and subscriptions. Offers can be configured to be available for a limited time, and can be configured to be available to players who have completed a specific level or have reached a specific score.

See the customization parameters for your virtual store items here.

Purchase “intents” have been added to the server to allow you to disambiguate on a hard currency purchase between what the user wanted to buy if two store items share the same SKU code (possible with LiveOps configured for the game).

Listing store items #

You can list available store items.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
foreach (var storeItem in economySystem.StoreItems)
{
    Debug.Log($"{storeItem.Name} - {storeItem.Description}). Cost: ");

    if (!string.IsNullOrEmpty(storeItem.Cost.Sku))
    {
        Debug.Log($"{storeItem.Cost.Sku}");
    }
    else
    {
        foreach (var currencyKvp in storeItem.Cost.Currencies)
        {
            Debug.Log($"{currencyKvp.Key}: {currencyKvp.Value}");
        }
    }
}

Refreshing the store #

You can refresh the economy system’s store data.

1
await economySystem.RefreshStoreAsync();

You can also specify the StoreType.

1
await economySystem.RefreshStoreAsync(StoreType.AppleAppStore);

Making a purchase intent #

You can make a purchase intent for a user, which is useful to differentiate product purchases that use the same SKU code.

1
await economySystem.PurchaseIntentAsync(storeItem);

Alternatively you can specify a store item id and SKU code.

1
await economySystem.PurchaseIntentAsync("<itemId1>", "<sku>");

Purchasing a store item #

You can purchase a store item for a user.

1
await economySystem.PurchaseStoreItemAsync("<itemId1>", "<unityReceipt>");

Getting the active store type #

You can get the active store type.

1
Debug.Log($"Active store type is {economySystem.ActiveStoreType}");