Setup In-Game Store

In this how to, we will go through the steps of listing catalog items based on their kind in order to generate the correct UI elements that contains enough data to have an in-game store.

Prerequisites

Get The Catalog Items

In order to create the UI of the store, we must gather all the information of what we're selling.

private void CreateStoreUI()
{
    string CatalogKey = "<INSERT KEY>";
    int count = 0;
    string after = null;

    LootLockerSDKManager.ListCatalogItems(CatalogKey, count, after, (response) =>
    {
        if (!response.success)
        {
            Debug.Log("Could not List Items from Catalog");
            return;
        }

        LootLockerInlinedCatalogEntry[] inlinedEntryList = response.GetLootLockerInlinedCatalogEntries();

        foreach (var entry in inlinedEntryList)
        {
            switch (entry.entity_kind)
            {
                case LootLockerCatalogEntryEntityKind.asset:
                    ConfigureAsset(entry.asset_details);
                    break;
                case LootLockerCatalogEntryEntityKind.currency:
                    ConfigureCurrency(entry.currency_details);
                    break;
                case LootLockerCatalogEntryEntityKind.progression_points:
                    ConfigureProgressionPoints(entry.progression_point_details);
                    break;
                case LootLockerCatalogEntryEntityKind.progression_reset:
                    ConfigureProgressionReset(entry.progression_reset_details);
                    break;
                case LootLockerCatalogEntryEntityKind.group:
                    ConfigureGroup(entry.group_details);
                    break;
            }
        }
    });
}

private void ConfigureAsset(LootLockerAssetDetails asset)
{
    Debug.Log(asset.name);
    Debug.Log(asset.id);
    Debug.Log(asset.thumbnail);
}

private void ConfigureCurrency(LootLockerCurrencyDetails currency)
{
    Debug.Log(currency.amount);
    Debug.Log(currency.name);
    Debug.Log(currency.id);
    Debug.Log(currency.code);
}

private void ConfigureProgressionPoints(LootLockerProgressionPointDetails progression)
{
    Debug.Log(progression.amount);
    Debug.Log(progression.name);
    Debug.Log(progression.id);
    Debug.Log(progression.key);
}

private void ConfigureProgressionReset(LootLockerProgressionResetDetails progression)
{
    Debug.Log(progression.name);
    Debug.Log(progression.id);
    Debug.Log(progression.key);
}

private void ConfigureGroup(LootLockerInlinedGroupDetails group)
{

    Debug.Log(group.name);
    Debug.Log(group.description);

    foreach (var asset in group.assetDetails)
    {
        ConfigureAsset(asset);
    }
    foreach (var currency in group.currencyDetails)
    {
        ConfigureCurrency(currency);
    }
    foreach (var progression in group.progressionPointDetails)
    {
        ConfigureProgressionPoints(progression);

    }
    foreach (var progression in group.progressionResetDetails)
    {
        ConfigureProgressionReset(progression);
    }
}

Conclusion

In this how to, we've received a list of catalog items, converted it into an inline list, which we can use to display all the items available for purchase. If you want to learn more about our Catalogs press here, other important reads can be found in Economy, Currencies and Wallets.

Last updated