Skip to content

Commit f84508f

Browse files
committed
Fixed issue with retieving other players data
1 parent 1912fa4 commit f84508f

File tree

7 files changed

+167
-40
lines changed

7 files changed

+167
-40
lines changed

Assets/LootLocker/Common/BaseServerAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ IEnumerator coroutine()
6666

6767
//Build the URL that we will hit based on the specified endpoint, query params, etc
6868
string url = BuildURL(request.endpoint, request.queryParams);
69-
#if UNITY_EDIROR
69+
#if UNITY_EDITOR
7070
Debug.Log("ServerRequest URL: " + url);
7171
#endif
7272

Assets/LootLocker/Common/ServerRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public ServerRequest(string endpoint, HTTPMethod httpMethod = HTTPMethod.GET, st
252252
public void Send(System.Action<LootLockerResponse> OnServerResponse)
253253
{
254254
#if UNITY_EDITOR
255-
Debug.Log("Sending Request: " + httpMethod.ToString() + " " + endpoint + " -- queryParams: " + queryParams?.Count);
255+
Debug.Log("Sending Request: " + httpMethod.ToString() + " " + endpoint + " -- queryParams: " + jsonPayload);
256256
#endif
257257
BaseServerAPI.I.SendRequest(this, (response) =>
258258
{

Assets/LootLocker/Game/Requests/PersitentPlayerStorageRequest.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ public class GetPersistentSingle : LootLockerResponse
2929

3030
{
3131
public bool success { get; set; }
32-
public string payload { get; set; }
32+
public Payload payload { get; set; }
3333
}
34-
34+
[Serializable]
3535
public class Payload
3636
{
37-
public string key { get; set; }
38-
public string value { get; set; }
39-
public int order { get; set; }
37+
public string key;
38+
public string value;
39+
public int order;
40+
public bool is_public;
4041
}
4142
}
4243

@@ -76,9 +77,9 @@ public static void GetSingleKeyPersistentStorage(Action<GetPersistentSingle> onC
7677
GetPersistentSingle response = new GetPersistentSingle();
7778
if (string.IsNullOrEmpty(serverResponse.Error))
7879
{
80+
response = JsonConvert.DeserializeObject<GetPersistentSingle>(serverResponse.text);
7981
response.text = serverResponse.text;
8082
response.success = true;
81-
response.payload = serverResponse.text;
8283
onComplete?.Invoke(response);
8384
}
8485
else

Assets/LootLocker/Game/Resources/Config/LootLockerConfig.asset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ MonoBehaviour:
1414
m_EditorClassIdentifier:
1515
gameName: LootLocker Demo Game
1616
apiKey: 280eec0a84e48b19de43ae3997597019585f7e1d
17-
token: 597627c523878909d33fd7b542bccdccd733fc9d
17+
token: d591157e17073e51ad417e58bc05aac3ef0a784c
1818
gameID: 230
1919
game_version: 1.0.0.0
20-
deviceID: gddfgmhfgmfhghg
20+
deviceID: eba81300-cf2f-42dc-b798-0d09613eb74e
2121
email: emmanuel@cradaptive.com
2222
password: Ihatefacebuk101!
2323
playerName: fbbrtebtr

Assets/LootLocker/Game/Samples/Scenes/GameTestScenes/PersistentScene.unity

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ RenderSettings:
4343
--- !u!157 &3
4444
LightmapSettings:
4545
m_ObjectHideFlags: 0
46-
serializedVersion: 11
46+
serializedVersion: 12
4747
m_GIWorkflowMode: 1
4848
m_GISettings:
4949
serializedVersion: 2
@@ -98,7 +98,7 @@ LightmapSettings:
9898
m_TrainingDataDestination: TrainingData
9999
m_LightProbeSampleCountMultiplier: 4
100100
m_LightingDataAsset: {fileID: 0}
101-
m_UseShadowmask: 1
101+
m_LightingSettings: {fileID: 972318320}
102102
--- !u!196 &4
103103
NavMeshSettings:
104104
serializedVersion: 2
@@ -118,6 +118,8 @@ NavMeshSettings:
118118
manualTileSize: 0
119119
tileSize: 256
120120
accuratePlacement: 0
121+
maxJobWorkers: 0
122+
preserveTilesOutsideBounds: 0
121123
debug:
122124
m_Flags: 0
123125
m_NavMeshData: {fileID: 0}
@@ -204,6 +206,67 @@ Transform:
204206
m_Father: {fileID: 0}
205207
m_RootOrder: 0
206208
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
209+
--- !u!850595691 &972318320
210+
LightingSettings:
211+
m_ObjectHideFlags: 0
212+
m_CorrespondingSourceObject: {fileID: 0}
213+
m_PrefabInstance: {fileID: 0}
214+
m_PrefabAsset: {fileID: 0}
215+
m_Name: Settings.lighting
216+
serializedVersion: 2
217+
m_GIWorkflowMode: 1
218+
m_EnableBakedLightmaps: 0
219+
m_EnableRealtimeLightmaps: 0
220+
m_RealtimeEnvironmentLighting: 1
221+
m_BounceScale: 1
222+
m_AlbedoBoost: 1
223+
m_IndirectOutputScale: 1
224+
m_UsingShadowmask: 1
225+
m_BakeBackend: 1
226+
m_LightmapMaxSize: 1024
227+
m_BakeResolution: 40
228+
m_Padding: 2
229+
m_TextureCompression: 1
230+
m_AO: 0
231+
m_AOMaxDistance: 1
232+
m_CompAOExponent: 1
233+
m_CompAOExponentDirect: 0
234+
m_ExtractAO: 0
235+
m_MixedBakeMode: 2
236+
m_LightmapsBakeMode: 1
237+
m_FilterMode: 1
238+
m_LightmapParameters: {fileID: 0}
239+
m_ExportTrainingData: 0
240+
m_TrainingDataDestination: TrainingData
241+
m_RealtimeResolution: 2
242+
m_ForceWhiteAlbedo: 0
243+
m_ForceUpdates: 0
244+
m_FinalGather: 0
245+
m_FinalGatherRayCount: 256
246+
m_FinalGatherFiltering: 1
247+
m_PVRCulling: 1
248+
m_PVRSampling: 1
249+
m_PVRDirectSampleCount: 32
250+
m_PVRSampleCount: 512
251+
m_PVREnvironmentSampleCount: 256
252+
m_PVREnvironmentReferencePointCount: 2048
253+
m_LightProbeSampleCountMultiplier: 4
254+
m_PVRBounces: 2
255+
m_PVRRussianRouletteStartBounce: 2
256+
m_PVREnvironmentMIS: 1
257+
m_PVRFilteringMode: 1
258+
m_PVRDenoiserTypeDirect: 1
259+
m_PVRDenoiserTypeIndirect: 1
260+
m_PVRDenoiserTypeAO: 1
261+
m_PVRFilterTypeDirect: 0
262+
m_PVRFilterTypeIndirect: 0
263+
m_PVRFilterTypeAO: 0
264+
m_PVRFilteringGaussRadiusDirect: 1
265+
m_PVRFilteringGaussRadiusIndirect: 5
266+
m_PVRFilteringGaussRadiusAO: 2
267+
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
268+
m_PVRFilteringAtrousPositionSigmaIndirect: 2
269+
m_PVRFilteringAtrousPositionSigmaAO: 1
207270
--- !u!1001 &1108173152
208271
PrefabInstance:
209272
m_ObjectHideFlags: 0
@@ -266,6 +329,36 @@ PrefabInstance:
266329
propertyPath: m_LocalEulerAnglesHint.z
267330
value: 0
268331
objectReference: {fileID: 0}
332+
- target: {fileID: 5758474329524581125, guid: 64953beff5972d944b8e5178fbba456e,
333+
type: 3}
334+
propertyPath: dataToSave.Array.size
335+
value: 0
336+
objectReference: {fileID: 0}
337+
- target: {fileID: 5758474329524581125, guid: 64953beff5972d944b8e5178fbba456e,
338+
type: 3}
339+
propertyPath: dataToSave.Array.data[0].key
340+
value: TestKeyOne
341+
objectReference: {fileID: 0}
342+
- target: {fileID: 5758474329524581125, guid: 64953beff5972d944b8e5178fbba456e,
343+
type: 3}
344+
propertyPath: dataToSave.Array.data[0].value
345+
value: TestkdataOne
346+
objectReference: {fileID: 0}
347+
- target: {fileID: 5758474329524581125, guid: 64953beff5972d944b8e5178fbba456e,
348+
type: 3}
349+
propertyPath: dataToSave.Array.data[1].key
350+
value: TestKeyTwo
351+
objectReference: {fileID: 0}
352+
- target: {fileID: 5758474329524581125, guid: 64953beff5972d944b8e5178fbba456e,
353+
type: 3}
354+
propertyPath: dataToSave.Array.data[1].value
355+
value: TestkdataTwo
356+
objectReference: {fileID: 0}
357+
- target: {fileID: 5758474329524581125, guid: 64953beff5972d944b8e5178fbba456e,
358+
type: 3}
359+
propertyPath: otherPlayerId
360+
value: 4JNTAK5V
361+
objectReference: {fileID: 0}
269362
- target: {fileID: 5758474329524581126, guid: 64953beff5972d944b8e5178fbba456e,
270363
type: 3}
271364
propertyPath: m_Name

Assets/LootLocker/Game/Samples/Scripts/PersistentPlayerStorageTest.cs

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,25 @@
22
using Newtonsoft.Json;
33
using System.Collections;
44
using System.Collections.Generic;
5+
using System.Linq;
56
using System.Text.RegularExpressions;
67
using UnityEngine;
78

8-
[System.Serializable]
9-
public class TestDataToSave
10-
{
11-
public string key;
12-
public string value;
13-
public int order;
14-
public TestSubDataToSave testSubDataToSave;
15-
}
16-
[System.Serializable]
17-
public class TestSubDataToSave
18-
{
19-
public string secondTest;
20-
public string roomWaterCount;
21-
}
22-
239
public class PersistentPlayerStorageTest : MonoBehaviour
2410
{
2511
[Header("Save Data")]
26-
public List<TestDataToSave> dataToSave;
12+
public List<Payload> dataToSave;
2713
[Header("Delete Data")]
2814
public string keyToDelete;
2915
public string labelText;
3016
Vector2 scrollPosition, scrollPosition2;
3117
public string otherPlayerId;
18+
bool started;
19+
20+
private void Awake()
21+
{
22+
GetEntirePersistentStorage();
23+
}
3224

3325
private void OnGUI()
3426
{
@@ -61,15 +53,15 @@ private void OnGUI()
6153
GUILayout.BeginHorizontal();
6254

6355
if (GUILayout.Button("New Data", GUILayout.ExpandWidth(true)))
64-
dataToSave.Add(new TestDataToSave { key = "", value = "1", order = 1, testSubDataToSave = new TestSubDataToSave { roomWaterCount = "1", secondTest = "test" } });
56+
dataToSave.Add(new Payload { key = "", value = "1", order = 1 });
6557

6658
GUILayout.EndHorizontal();
6759

6860
GUILayout.BeginHorizontal();
6961

7062
scrollPosition2 = GUILayout.BeginScrollView(scrollPosition2);
7163

72-
List<TestDataToSave> dataToDelete = new List<TestDataToSave>();
64+
List<Payload> dataToDelete = new List<Payload>();
7365

7466
for (int i = 0; i < dataToSave.Count; i++)
7567
{
@@ -96,25 +88,26 @@ private void OnGUI()
9688

9789
GUILayout.BeginHorizontal();
9890

99-
GUILayout.Label("Order");
10091

101-
string o = GUILayout.TextField(dataToSave[i].order.ToString(), GUILayout.ExpandWidth(true), GUILayout.MaxWidth(1000));
102-
o = Regex.Replace(o, @"[^0-9 ]", "");
103-
dataToSave[i].order = int.Parse(o);
92+
bool isPublic = GUILayout.Toggle(dataToSave[i].is_public,"Make Public", GUILayout.MaxWidth(1000));
93+
dataToSave[i].is_public = isPublic;
94+
10495

10596
GUILayout.EndHorizontal();
10697

10798
GUILayout.BeginHorizontal();
10899

109100
if (GUILayout.Button("Delete Data #" + i.ToString(), GUILayout.ExpandWidth(true)))
110-
dataToDelete.Add(dataToSave[i]);
101+
DeleteKeyValue(dataToSave[i].key);
102+
//if (GUILayout.Button("Update #" + i.ToString(), GUILayout.ExpandWidth(true)))
103+
// DeleteKeyValue(dataToSave[i].key);
111104

112105
GUILayout.EndHorizontal();
113106

114107
}
115108

116-
for (int i = 0; i < dataToDelete.Count; i++)
117-
dataToSave.Remove(dataToDelete[i]);
109+
//for (int i = 0; i < dataToDelete.Count; i++)
110+
// dataToSave.Remove(dataToDelete[i]);
118111

119112
GUILayout.EndScrollView();
120113

@@ -170,6 +163,20 @@ public void GetEntirePersistentStorage()
170163
if (getPersistentStoragResponse.success)
171164
{
172165
labelText = "Success\n" + getPersistentStoragResponse.text;
166+
dataToSave.Clear();
167+
for (int i = 0; i < getPersistentStoragResponse.payload.Length; i++)
168+
{
169+
dataToSave.Add(getPersistentStoragResponse.payload[i]);
170+
}
171+
dataToSave = getPersistentStoragResponse.payload.ToList();
172+
if (!started)
173+
{
174+
started = true;
175+
if (dataToSave.Count > 0)
176+
{
177+
keyToDelete = dataToSave[0].key;
178+
}
179+
}
173180
}
174181
else
175182
{
@@ -186,6 +193,7 @@ public void GetSingleKeyPersistentStorage()
186193
if (getPersistentStoragResponse.success)
187194
{
188195
labelText = "Success\n" + getPersistentStoragResponse.text;
196+
// dataToSave = getPersistentStoragResponse.payload;
189197
}
190198
else
191199
{
@@ -198,18 +206,20 @@ public void GetSingleKeyPersistentStorage()
198206
[ContextMenu("UpdateOrCreateKeyValue")]
199207
public void UpdateOrCreateKeyValue()
200208
{
201-
string json = JsonConvert.SerializeObject(dataToSave);
209+
202210
GetPersistentStoragRequest data = new GetPersistentStoragRequest();
211+
203212
for (int i = 0; i < dataToSave.Count; i++)
204213
{
205-
data.AddToPayload(new Payload { key = dataToSave[i].key, value = dataToSave[i].value });
214+
data.AddToPayload(dataToSave[i]);
206215
}
207216

208217
LootLockerSDKManager.UpdateOrCreateKeyValue(data, (getPersistentStoragResponse) =>
209218
{
210219
if (getPersistentStoragResponse.success)
211220
{
212221
labelText = "Success\n" + getPersistentStoragResponse.text;
222+
dataToSave = getPersistentStoragResponse.payload.ToList();
213223
}
214224
else
215225
{
@@ -226,6 +236,7 @@ public void DeleteKeyValue()
226236
if (getPersistentStoragResponse.success)
227237
{
228238
labelText = "Success\n" + getPersistentStoragResponse.text;
239+
dataToSave = getPersistentStoragResponse.payload.ToList();
229240
}
230241
else
231242
{
@@ -235,14 +246,32 @@ public void DeleteKeyValue()
235246
});
236247
}
237248

238-
[ContextMenu("DeleteKeyValue")]
249+
public void DeleteKeyValue(string key)
250+
{
251+
LootLockerSDKManager.DeleteKeyValue(key, (getPersistentStoragResponse) =>
252+
{
253+
if (getPersistentStoragResponse.success)
254+
{
255+
labelText = "Success\n" + getPersistentStoragResponse.text;
256+
dataToSave = getPersistentStoragResponse.payload.ToList();
257+
}
258+
else
259+
{
260+
labelText = "Failed\n" + getPersistentStoragResponse.text;
261+
}
262+
263+
});
264+
}
265+
266+
[ContextMenu("GetOtherPlayerKeyValue")]
239267
public void GetOtherPlayersPublicKeyValuePairs()
240268
{
241269
LootLockerSDKManager.GetOtherPlayersPublicKeyValuePairs(otherPlayerId, (getPersistentStoragResponse) =>
242270
{
243271
if (getPersistentStoragResponse.success)
244272
{
245273
labelText = "Success\n" + getPersistentStoragResponse.text;
274+
dataToSave = getPersistentStoragResponse.payload.ToList();
246275
}
247276
else
248277
{

Assets/LootLocker/SampleApp/Scripts/StorageScreen.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public void Refresh()
3434

3535
public void UpdateScreen(Payload[] payload)
3636
{
37+
foreach (Transform tr in content.transform)
38+
{
39+
Destroy(tr.gameObject);
40+
}
3741
for (int i = 0; i < payload.Length; i++)
3842
{
3943
GameObject go = Instantiate(keyValueElement, content.transform);

0 commit comments

Comments
 (0)