public void OnElementClicked() { string[] names = itemToCollect.Split('.'); Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("Collectable", names[0]); data.Add("Group Name", names[1]); data.Add("Item Name", names[2]); string header = ""; item.url = groupName + "_Active"; PopupSystem.ShowPopup("Collectable", data, "Collect", () => { LoadingManager.ShowLoadingScreen(); LootLockerSDKManager.CollectingAnItem(itemToCollect, (response) => { LoadingManager.HideLoadingScreen(); if (response.success) { Debug.Log("Success\n" + response.text); header = "Success"; data.Clear(); AppDemoLootLockerRequests.CollectingAnItemResponse mainResponse = JsonConvert.DeserializeObject <AppDemoLootLockerRequests.CollectingAnItemResponse>(response.text); string[] collectableStrings = itemToCollect.Split('.'); string collectable = collectableStrings[0]; string group = collectableStrings[1]; string tempItem = collectableStrings[2]; mainResponse.mainCollectable = mainResponse.collectables?.FirstOrDefault(x => x.name == collectable); mainResponse.mainGroup = mainResponse.mainCollectable?.groups?.FirstOrDefault(x => x.name == group); mainResponse.mainItem = mainResponse.mainGroup?.items?.FirstOrDefault(x => x.name == tempItem); //Preparing data to display or error messages we have data.Add("1", "You successfully collected: " + itemToCollect); PopupSystem.ShowApprovalFailPopUp(header, data, item.url, false, onComplete: () => { ShowRewards(mainResponse.mainItem, mainResponse.mainGroup, mainResponse.mainCollectable); }); UpdateButtonAppearance(mainResponse.mainItem); } else { header = "Collection Failed"; data.Clear(); //Preparing data to display or error messages we have data.Add("1", "Collection of item failed"); PopupSystem.ShowApprovalFailPopUp(header, data, item.url, true); Debug.Log("Failed\n" + response.text); } }); }, groupName + "_Active"); }
public void CollectAnItem() { LootLockerSDKManager.CollectingAnItem(itemToCollect, (response) => { if (response.success) { labelText = "Success\n" + response.text; } else { labelText = "Failed\n" + response.text; } }); }