Class Progressions
Class progressions are progressions that the Class is currently on, your game may have many progressions but the Class doesn't necessarily progress through all of them at a given time, some may need to be unlocked or may be mutually exclusive.
Starting a Class on a progression is as easy as just starting to add points to it. That progression will then be listed when retrieving progressions for that Class.
Retrieving Class Progressions
Retrieving a single Class Progression using the progression key
int characterId = 1;
string progressionKey = "mage";
LootLockerSDKManager.GetCharacterProgression(characterId, progressionKey, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Output the character level and show how much points are needed to progress to the next tier
Debug.Log($"The character is currently level {response.step}");
if (response.next_threshold != null)
{
Debug.Log($"Points needed to reach next level: {response.next_threshold - response.points}");
}
});
Retrieving all Class Progressions
int characterId = 1;
LootLockerSDKManager.GetCharacterProgressions(characterId, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Output the character level and show how much points are needed to progress to the next tier for all character progressions
foreach (var characterProgression in response.items)
{
Debug.Log($"Current level in {characterProgression.progression_name} is {characterProgression.step}");
if (characterProgression.next_threshold != null)
{
Debug.Log($"Points needed to reach next level in {characterProgression.progression_name}: {characterProgression.next_threshold - characterProgression.points}");
}
}
});
Retrieving Class Progressions using count
Count can be used to limit the number of entries returned.
int characterId = 1;
int count = 20;
LootLockerSDKManager.GetCharacterProgressions(characterId, count, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Output the character level and show how much points are needed to progress to the next tier for all character progressions
foreach (var characterProgression in response.items)
{
Debug.Log($"Current level in {characterProgression.progression_name} is {characterProgression.step}");
if (characterProgression.next_threshold != null)
{
Debug.Log($"Points needed to reach next level in {characterProgression.progression_name}: {characterProgression.next_threshold - characterProgression.points}");
}
}
});
Paginating through Class Progressions
You can use "after" parameter to paginate if the Class is on many progressions.
int characterId = 1;
int numberOfItemsPerPage = 10;
LootLockerPaginatedCharacterProgressionsResponse characterProgressions;
void Start()
{
LootLockerSDKManager.StartGuestSession(_ =>
{
// Fetch the initial character progressions list
LootLockerSDKManager.GetCharacterProgressions(characterId, numberOfItemsPerPage, response =>
{
if (!response.success)
{
Debug.Log("Failed: " + response.Error);
}
if (response.pagination.total == 0)
{
Debug.Log("You character does not have any progressions, start them by giving some exp to the character");
}
characterProgressions = response;
});
});
}
void Update()
{
if (characterProgressions == null) return;
// Fetch the next page if more character progressions exist
if (Input.GetKeyDown(KeyCode.RightArrow) && characterProgressions.pagination.next_cursor != null)
{
LootLockerSDKManager.GetCharacterProgressions(characterId, numberOfItemsPerPage, characterProgressions.pagination.next_cursor, response =>
{
if (!response.success)
{
Debug.Log("Failed: " + response.Error);
}
characterProgressions = response;
Debug.Log($"Paginating right, got {characterProgressions.items.Count} character progressions");
});
}
// Fetch the previous page if we are not on the first page
if (Input.GetKeyDown(KeyCode.LeftArrow) && characterProgressions.pagination.previous_cursor != null)
{
LootLockerSDKManager.GetCharacterProgressions(characterId, numberOfItemsPerPage, characterProgressions.pagination.previous_cursor, response =>
{
if (!response.success)
{
Debug.Log("Failed: " + response.Error);
}
characterProgressions = response;
Debug.Log($"Paginating left, got {characterProgressions.items.Count} character progressions");
});
}
}
Interacting with Class Progressions
Adding points to a Class Progression
int characterId = 1;
string progressionKey = "mage";
ulong amountOfPoints = 100;
LootLockerSDKManager.AddPointsToCharacterProgression(characterId, progressionKey, amountOfPoints, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// If the awarded_tiers array contains any items that means the character leveled up
// There can also be multiple level-ups at once
if (response.awarded_tiers.Any())
{
foreach (var awardedTier in response.awarded_tiers)
{
Debug.Log($"Reached level {awardedTier.step}!");
foreach (var assetReward in awardedTier.rewards.asset_rewards)
{
Debug.Log($"Rewarded with an asset, id: {assetReward.asset_id}!");
}
foreach (var progressionPointsReward in awardedTier.rewards.progression_points_rewards)
{
Debug.Log($"Rewarded with {progressionPointsReward.amount} bonus points in {progressionPointsReward.progression_name} progression!");
}
foreach (var progressionResetReward in awardedTier.rewards.progression_reset_rewards)
{
Debug.Log($"Progression {progressionResetReward.progression_name} has been reset as a reward!");
}
}
}
});
Subtracting points from a Class Progression
int characterId = 1;
string progressionKey = "mage";
ulong amountOfPoints = 10;
LootLockerSDKManager.SubtractPointsFromCharacterProgression(characterId, progressionKey, amountOfPoints, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Output the amount of points the character has after subtracting points
Debug.Log($"Character now has {response.points} points in {response.progression_name} progression");
});
Resetting a Class Progression
Resets the Class Progression points to 0, effectively returning the Class to level 1, if you want to remove the progression from a Class see below.
int characterId = 1;
string progressionKey = "mage";
LootLockerSDKManager.ResetCharacterProgression(characterId, progressionKey, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Character level is now 1
Debug.Log($"Character is level {response.step} since the {response.progression_name} was reset");
});
Deleting a Class Progression
Completely removes a Class Progression, it will no longer be listed when retrieving Class Progressions.
int characterId = 1;
string progressionKey = "mage";
LootLockerSDKManager.DeleteCharacterProgression(characterId, progressionKey, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
// Trying to fetch the deleted character progression will result in a "Not Found" error
LootLockerSDKManager.GetCharacterProgression(progressionKey, response =>
{
if (!response.success) {
Debug.Log("Failed: " + response.Error);
}
}
});
Last updated