Game Progress

Integration Guide

Report On Game Complete / User Level Up

It will increment the current level and reward currency added in API Call. The response contains Game Progress data and the user's currencies list with actual balance.

using System.Collections.Generic;
using RGN.Modules.Currency;
using RGN.Modules.GameProgress;
using UnityEngine;

namespace SomeNamespace
{
    internal sealed class GameCompleteLevelUp
    {
        public async void OnGameCompleteAsync()
        {
            OnGameCompleteResult onGameCompleteResult =
                    await GameProgressModule.I.OnGameCompleteAsync(
                        new List<Currency>() {
                            new Currency()
                            {
                                name = "rgntestCoin",
                                quantity = 25
                            }
            });
            string progressDebugStr =
                JsonUtility.ToJson(onGameCompleteResult.gameProgress);
            string currenciesDebugStr =
                JsonUtility.ToJson(onGameCompleteResult.userCurrencies);
            Debug.Log($"gameProgress: " +
              $"{progressDebugStr}\n\r" +
              $"currencies: {currenciesDebugStr}");
        }
    }
}

Retrieve Game Progress user level value:

using RGN.Modules.GameProgress;
using UnityEngine;

namespace SomeNamespace
{
    internal sealed class GetGameProgress
    {
        public async void GetGameProgressAsync()
        {
            GameProgress gameProgress =
                await GameProgressModule.I.GetGameProgressAsync();
            Debug.Log("Game Progress level: " +
                gameProgress.level);
        }
    }
}

Store Custom User Data:

You can store your custom serialized classes in our database:

using RGN.Modules.GameProgress;
using UnityEngine;

namespace SomeNamespace
{
    [System.Serializable]
    internal sealed class CustomUserData
    {
        public int HitPoints;
        public int RegenerateHealth;
        public int HealthRegenDelay;
        public int HealthRegenRate;
        public string ModelUrl;
        public string[] Bookmarks;
        public float Health;
    }

    internal sealed class StoreCustomData
    {
        public async void StoreCustomDataAsync()
        {
            var data = new CustomUserData() {
                HitPoints = 10,
                RegenerateHealth = 10,
                HealthRegenDelay = 39,
                ModelUrl = "model_xyz_1",
                Bookmarks = new string[] { "bookmark_1", "bookmark42" },
                Health = 3.14f
            };
            UpdateUserLevelResponseData<CustomUserData> customUserData =
                await GameProgressModule.I.UpdateUserProgressAsync(data, null);
            Debug.Log("Custom user data updated, hit points: "
                + customUserData.playerProgress.HitPoints);
        }
    }
}

To retrieve custom data from the backend you need to use:

using RGN.Modules.GameProgress;
using UnityEngine;

namespace SomeNamespace.GetCustomDataNS
{
    [System.Serializable]
    internal sealed class CustomUserData
    {
        public int HitPoints;
        public int RegenerateHealth;
        public int HealthRegenDelay;
        public int HealthRegenRate;
        public string ModelUrl;
        public string[] Bookmarks;
        public float Health;
    }

    internal sealed class GetCustomData
    {
        public async void GetCustomDataAsync()
        {
            var result =
                await GameProgressModule.I.GetUserProgressAsync<CustomUserData>();
            Debug.Log("Custom user data hit points: "
                + result.playerProgress.HitPoints);
        }
    }
}

Last updated