Skip to content

Commit 345ed86

Browse files
committed
Differentiate nested callback response variables
1 parent 3319dde commit 345ed86

File tree

2 files changed

+51
-51
lines changed

2 files changed

+51
-51
lines changed

Samples~/LootLockerExamples/Scripts/LootLockerLevelProgression.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ void Start()
3333
* LootLocker will create an identifier for the user and store it in PlayerPrefs.
3434
* If you want to create a new player when testing, you can use PlayerPrefs.DeleteKey("LootLockerGuestPlayerID");
3535
*/
36-
LootLockerSDKManager.StartGuestSession((response) =>
36+
LootLockerSDKManager.StartGuestSession((startGuestSessionResponse) =>
3737
{
38-
if (response.success)
38+
if (startGuestSessionResponse.success)
3939
{
4040
// New player
41-
if(response.seen_before == false)
41+
if(startGuestSessionResponse.seen_before == false)
4242
{
4343
// Register the progression to the player; this will create the progression if it doesn't already exist.
4444
// It is the same as adding 0 to the progression.
45-
LootLockerSDKManager.RegisterPlayerProgression(progressionKey, (response) =>
45+
LootLockerSDKManager.RegisterPlayerProgression(progressionKey, (registerPlayerProgressionResponse) =>
4646
{
47-
if (response.success)
47+
if (registerPlayerProgressionResponse.success)
4848
{
4949
Debug.Log("Progression registered");
50-
UpdateProgressionUI(response.step, response.points, response.previous_threshold, response.next_threshold);
50+
UpdateProgressionUI(registerPlayerProgressionResponse.step, registerPlayerProgressionResponse.points, registerPlayerProgressionResponse.previous_threshold, registerPlayerProgressionResponse.next_threshold);
5151
}
5252
else
5353
{
@@ -59,17 +59,17 @@ void Start()
5959
{
6060
// This player is old and has already registered the progression
6161
// So we just need to get it.
62-
LootLockerSDKManager.GetPlayerProgression(progressionKey, (response) =>
62+
LootLockerSDKManager.GetPlayerProgression(progressionKey, (getPlayerProgressionResponse) =>
6363
{
64-
if (response.success)
64+
if (getPlayerProgressionResponse.success)
6565
{
6666
/*
67-
* response.step is the current tier of the progression
68-
* response.points is the current amount of points taht the player has in the progression
69-
* response.previous_threshold is the amount of points needed to reach the previous tier
70-
* response.next_threshold is the amount of points needed to reach the next tier
67+
* getPlayerProgressionResponse.step is the current tier of the progression
68+
* getPlayerProgressionResponse.points is the current amount of points taht the player has in the progression
69+
* getPlayerProgressionResponse.previous_threshold is the amount of points needed to reach the previous tier
70+
* getPlayerProgressionResponse.next_threshold is the amount of points needed to reach the next tier
7171
* */
72-
UpdateProgressionUI(response.step, response.points, response.previous_threshold, response.next_threshold);
72+
UpdateProgressionUI(getPlayerProgressionResponse.step, getPlayerProgressionResponse.points, getPlayerProgressionResponse.previous_threshold, getPlayerProgressionResponse.next_threshold);
7373
}
7474
else
7575
{
@@ -99,13 +99,13 @@ public void AddPointsToProgression()
9999
// Add X amount of points to the progression
100100
// All progressions uses ulong as the type for the points, so you need to cast the value to ulong.
101101
// Progressions will not be able to go below 0 (no negative progressions).
102-
LootLockerSDKManager.AddPointsToPlayerProgression(progressionKey, (ulong)pointsAmountSlider.value, (response) =>
102+
LootLockerSDKManager.AddPointsToPlayerProgression(progressionKey, (ulong)pointsAmountSlider.value, (addPointsToPlayerProgressionResponse) =>
103103
{
104-
if(response.success)
104+
if(addPointsToPlayerProgressionResponse.success)
105105
{
106106
Debug.Log("Points added to progression");
107107
// If the player leveled up, the count of awarded_tiers will be greater than 0
108-
UpdateProgressionUI(response.step, response.points, response.previous_threshold, response.next_threshold);
108+
UpdateProgressionUI(addPointsToPlayerProgressionResponse.step, addPointsToPlayerProgressionResponse.points, addPointsToPlayerProgressionResponse.previous_threshold, addPointsToPlayerProgressionResponse.next_threshold);
109109
}
110110
else
111111
{
@@ -117,12 +117,12 @@ public void AddPointsToProgression()
117117
public void ResetProgression()
118118
{
119119
// Reset the progression to 0
120-
LootLockerSDKManager.ResetPlayerProgression(progressionKey, (response) =>
120+
LootLockerSDKManager.ResetPlayerProgression(progressionKey, (resetPlayerProgressionResponse) =>
121121
{
122-
if(response.success)
122+
if(resetPlayerProgressionResponse.success)
123123
{
124124
Debug.Log("Progression reset");
125-
UpdateProgressionUI(response.step, response.points, response.previous_threshold, response.next_threshold);
125+
UpdateProgressionUI(resetPlayerProgressionResponse.step, resetPlayerProgressionResponse.points, resetPlayerProgressionResponse.previous_threshold, resetPlayerProgressionResponse.next_threshold);
126126
}
127127
else
128128
{

Samples~/LootLockerExamples/Scripts/LootLockerMultipleProgressions.cs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,31 @@ void Start()
5454
* LootLocker will create an identifier for the user and store it in PlayerPrefs.
5555
* If you want to create a new player when testing, you can use PlayerPrefs.DeleteKey("LootLockerGuestPlayerID");
5656
*/
57-
LootLockerSDKManager.StartGuestSession((response) =>
57+
LootLockerSDKManager.StartGuestSession((startGuestSessionResponse) =>
5858
{
59-
if (response.success)
59+
if (startGuestSessionResponse.success)
6060
{
6161
// Register the progression to the player; this will create the progression if it doesn't already exist.
6262
// It is the same as adding 0 to the progression.
63-
LootLockerSDKManager.RegisterPlayerProgression(progressionKey1, (response) =>
63+
LootLockerSDKManager.RegisterPlayerProgression(progressionKey1, (registerPlayerProgressionResponse) =>
6464
{
65-
if (response.success)
65+
if (registerPlayerProgressionResponse.success)
6666
{
6767
Debug.Log("Progression registered");
68-
UpdateProgressionUI1(response.step, response.points, response.previous_threshold, response.next_threshold);
68+
UpdateProgressionUI1(registerPlayerProgressionResponse.step, registerPlayerProgressionResponse.points, registerPlayerProgressionResponse.previous_threshold, registerPlayerProgressionResponse.next_threshold);
6969
}
7070
else
7171
{
7272
Debug.Log("Error registering progression");
7373
}
7474
});
7575
// Same with progression 2
76-
LootLockerSDKManager.RegisterPlayerProgression(progressionKey2, (response) =>
76+
LootLockerSDKManager.RegisterPlayerProgression(progressionKey2, (registerPlayerProgressionResponse) =>
7777
{
78-
if (response.success)
78+
if (registerPlayerProgressionResponse.success)
7979
{
8080
Debug.Log("Progression registered");
81-
UpdateProgressionUI2(response.step, response.points, response.previous_threshold, response.next_threshold);
81+
UpdateProgressionUI2(registerPlayerProgressionResponse.step, registerPlayerProgressionResponse.points, registerPlayerProgressionResponse.previous_threshold, registerPlayerProgressionResponse.next_threshold);
8282
}
8383
else
8484
{
@@ -110,21 +110,21 @@ public void AddPointsToProgression1()
110110
// Add X amount of points to the progression
111111
// All progressions uses ulong as the type for the points, so you need to cast the value to ulong.
112112
// Progressions will not be able to go below 0 (no negative progressions).
113-
LootLockerSDKManager.AddPointsToPlayerProgression(progressionKey1, (ulong)pointsAmountSlider1.value, (response) =>
113+
LootLockerSDKManager.AddPointsToPlayerProgression(progressionKey1, (ulong)pointsAmountSlider1.value, (addPointsToPlayerProgressionResponse) =>
114114
{
115-
if(response.success)
115+
if(addPointsToPlayerProgressionResponse.success)
116116
{
117117
Debug.Log("Points added to progression");
118118
// If the player leveled up, the count of awarded_tiers will be greater than 0
119-
UpdateProgressionUI1(response.step, response.points, response.previous_threshold, response.next_threshold);
119+
UpdateProgressionUI1(addPointsToPlayerProgressionResponse.step, addPointsToPlayerProgressionResponse.points, addPointsToPlayerProgressionResponse.previous_threshold, addPointsToPlayerProgressionResponse.next_threshold);
120120

121121
// Update both progressions
122-
LootLockerSDKManager.GetPlayerProgressions((response) =>
122+
LootLockerSDKManager.GetPlayerProgressions((getPlayerProgressionsResponse) =>
123123
{
124-
if(response.success)
124+
if(getPlayerProgressionsResponse.success)
125125
{
126-
var progression1 = response.items.Find(x => x.progression_key == progressionKey1);
127-
var progression2 = response.items.Find(x => x.progression_key == progressionKey2);
126+
var progression1 = getPlayerProgressionsResponse.items.Find(x => x.progression_key == progressionKey1);
127+
var progression2 = getPlayerProgressionsResponse.items.Find(x => x.progression_key == progressionKey2);
128128
UpdateProgressionUI1(progression1.step, progression1.points, progression1.previous_threshold, progression1.next_threshold);
129129
UpdateProgressionUI2(progression2.step, progression2.points, progression2.previous_threshold, progression2.next_threshold);
130130
}
@@ -141,32 +141,32 @@ public void AddPointsToProgression2()
141141
// Add X amount of points to the progression
142142
// All progressions uses ulong as the type for the points, so you need to cast the value to ulong.
143143
// Progressions will not be able to go below 0 (no negative progressions).
144-
LootLockerSDKManager.AddPointsToPlayerProgression(progressionKey2, (ulong)pointsAmountSlider2.value, (response) =>
144+
LootLockerSDKManager.AddPointsToPlayerProgression(progressionKey2, (ulong)pointsAmountSlider2.value, (addPointsToPlayerProgressionResponse) =>
145145
{
146-
if (response.success)
146+
if (addPointsToPlayerProgressionResponse.success)
147147
{
148148
Debug.Log("Points added to progression");
149149

150150
// If the player leveled up, the count of awarded_tiers will be greater than 0
151-
if (response.awarded_tiers.Count > 0)
151+
if (addPointsToPlayerProgressionResponse.awarded_tiers.Count > 0)
152152
{
153153
Debug.Log("Player leveled up");
154154
}
155155

156-
UpdateProgressionUI2(response.step, response.points, response.previous_threshold, response.next_threshold);
156+
UpdateProgressionUI2(addPointsToPlayerProgressionResponse.step, addPointsToPlayerProgressionResponse.points, addPointsToPlayerProgressionResponse.previous_threshold, addPointsToPlayerProgressionResponse.next_threshold);
157157

158158
// Since progression 1 is connected to progression 2, we need to update it as well
159-
LootLockerSDKManager.GetPlayerProgression(progressionKey1, (response) =>
159+
LootLockerSDKManager.GetPlayerProgression(progressionKey1, (getPlayerProgressionResponse) =>
160160
{
161-
if (response.success)
161+
if (getPlayerProgressionResponse.success)
162162
{
163163
/*
164-
* response.step is the current tier of the progression
165-
* response.points is the current amount of points taht the player has in the progression
166-
* response.previous_threshold is the amount of points needed to reach the previous tier
167-
* response.next_threshold is the amount of points needed to reach the next tier
164+
* getPlayerProgressionResponse.step is the current tier of the progression
165+
* getPlayerProgressionResponse.points is the current amount of points taht the player has in the progression
166+
* getPlayerProgressionResponse.previous_threshold is the amount of points needed to reach the previous tier
167+
* getPlayerProgressionResponse.next_threshold is the amount of points needed to reach the next tier
168168
* */
169-
UpdateProgressionUI1(response.step, response.points, response.previous_threshold, response.next_threshold);
169+
UpdateProgressionUI1(getPlayerProgressionResponse.step, getPlayerProgressionResponse.points, getPlayerProgressionResponse.previous_threshold, getPlayerProgressionResponse.next_threshold);
170170
}
171171
else
172172
{
@@ -184,12 +184,12 @@ public void AddPointsToProgression2()
184184
public void ResetProgression1()
185185
{
186186
// Reset the progression to 0
187-
LootLockerSDKManager.ResetPlayerProgression(progressionKey1, (response) =>
187+
LootLockerSDKManager.ResetPlayerProgression(progressionKey1, (resetPlayerProgressionResponse) =>
188188
{
189-
if(response.success)
189+
if(resetPlayerProgressionResponse.success)
190190
{
191191
Debug.Log("Progression reset");
192-
UpdateProgressionUI1(response.step, response.points, response.previous_threshold, response.next_threshold);
192+
UpdateProgressionUI1(resetPlayerProgressionResponse.step, resetPlayerProgressionResponse.points, resetPlayerProgressionResponse.previous_threshold, resetPlayerProgressionResponse.next_threshold);
193193
}
194194
else
195195
{
@@ -201,12 +201,12 @@ public void ResetProgression1()
201201
public void ResetProgression2()
202202
{
203203
// Reset the progression to 0
204-
LootLockerSDKManager.ResetPlayerProgression(progressionKey2, (response) =>
204+
LootLockerSDKManager.ResetPlayerProgression(progressionKey2, (resetPlayerProgressionResponse) =>
205205
{
206-
if (response.success)
206+
if (resetPlayerProgressionResponse.success)
207207
{
208208
Debug.Log("Progression reset");
209-
UpdateProgressionUI2(response.step, response.points, response.previous_threshold, response.next_threshold);
209+
UpdateProgressionUI2(resetPlayerProgressionResponse.step, resetPlayerProgressionResponse.points, resetPlayerProgressionResponse.previous_threshold, resetPlayerProgressionResponse.next_threshold);
210210
}
211211
else
212212
{

0 commit comments

Comments
 (0)