コード例 #1
0
        public void Delete()
        {
            if (string.IsNullOrEmpty(key.text) || string.IsNullOrEmpty(key.text))
            {
                PopupSystem.ShowPopup("Please enter valid text for key and value", null, "Close", () =>
                {
                }, url: keySucces, isError: true);

                return;
            }
            LoadingManager.ShowLoadingScreen();
            LootLockerSDKManager.DeleteKeyValue(key.text, (response) =>
            {
                LoadingManager.HideLoadingScreen();
                if (response.success)
                {
                    Dictionary <string, string> data = new Dictionary <string, string>();
                    data.Add("Key", key.text);

                    PopupSystem.ShowPopup("Deletion Successful", data, "Close", () =>
                    {
                        StagesManager.instance.GoToStage(StagesManager.StageID.Storage, null);
                        GetComponent <ScreenCloser>()?.Close();
                        PopupSystem.CloseNow();
                    }, url: keySucces);
                }
            });
        }
コード例 #2
0
        public void ShowRewards(AppDemoLootLockerRequests.Item item, AppDemoLootLockerRequests.Group group, AppDemoLootLockerRequests.Collectable collectable)
        {
            if (item.collected)
            {
                for (int i = 0; i < item.rewards.Length; i++)
                {
                    PopupSystem.ShowScheduledPopup(item.rewards[i]);
                }
            }

            if (group.completion_percentage >= 100)
            {
                for (int i = 0; i < group.rewards.Length; i++)
                {
                    PopupSystem.ShowScheduledPopup(group.rewards[i]);
                }
            }

            if (collectable.completion_percentage >= 100)
            {
                for (int i = 0; i < collectable.rewards.Length; i++)
                {
                    PopupSystem.ShowScheduledPopup(collectable.rewards[i]);
                }
            }
        }
コード例 #3
0
        public void Save()
        {
            if (string.IsNullOrEmpty(key.text) || string.IsNullOrEmpty(key.text))
            {
                PopupSystem.ShowPopup("Please enter valid text for key and value", null, "Close", () =>
                {
                }, url: keySucces, isError: true);

                return;
            }
            LoadingManager.ShowLoadingScreen();
            LootLockerSDKManager.UpdateOrCreateKeyValue(key.text, value.text, (response) =>
            {
                LoadingManager.HideLoadingScreen();
                if (response.success)
                {
                    Dictionary <string, string> data = new Dictionary <string, string>();
                    data.Add("Key", key.text);
                    data.Add("Value", value.text);
                    DemoAppGetPersistentStoragResponse mainResponse = JsonConvert.DeserializeObject <DemoAppGetPersistentStoragResponse>(response.text);
                    PopupSystem.ShowPopup("Save Successful", data, "Close", () =>
                    {
                        StagesManager.instance.GoToStage(StagesManager.StageID.Storage, mainResponse);
                        GetComponent <ScreenCloser>()?.Close();
                        PopupSystem.CloseNow();
                    }, url: keySucces);
                }
            });
        }
コード例 #4
0
        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");
        }
コード例 #5
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         Debug.LogError("Found Another" + gameObject.name);
         Destroy(this.transform.parent.gameObject);
     }
 }
コード例 #6
0
        public void ButtonClicked()
        {
            if (currentAsset.asset != null)
            {
                if (currentAsset.asset.files != null && currentAsset.asset.files.Length > 0)
                {
                    StagesManager.instance.GoToStage(StagesManager.StageID.Files, currentAsset.asset);
                    return;
                }
            }

            string header  = "Equip";
            string btnText = "Equip";
            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("Asset Name", currentAsset.asset.name);
            data.Add("Asset Context", currentAsset.asset.context);

            PopupSystem.ShowPopup(header, data, btnText, () =>
            {
                LoadingManager.ShowLoadingScreen();
                LootLockerSDKManager.EquipIdAssetToDefaultCharacter(currentAsset.inventory.instance_id.ToString(), (response) =>
                {
                    LoadingManager.HideLoadingScreen();
                    if (response.success)
                    {
                        header = "Success";
                        data.Clear();
                        //Preparing data to display or error messages we have
                        data.Add("1", "You successfully equipped: " + currentAsset.inventory.asset.name);
                        LoadingManager.ShowLoadingScreen();
                        StagesManager.instance.GoToStage(StagesManager.StageID.Inventory, null);
                        PopupSystem.ShowApprovalFailPopUp(header, data, currentAsset.asset.url, false);
                    }
                    else
                    {
                        Debug.LogError(response.Error);
                        header = "Failed";
                        data.Clear();

                        //Preparing data to display or error messages we have
                        string correctedResponse         = response.Error.First() == '{' ? response.Error : response.Error.Substring(response.Error.IndexOf('{'));
                        ResponseError equipErrorResponse = new ResponseError();
                        equipErrorResponse = JsonConvert.DeserializeObject <ResponseError>(correctedResponse);

                        data.Add("1", equipErrorResponse.messages[0]);
                        PopupSystem.ShowApprovalFailPopUp(header, data, currentAsset.asset.url, true);
                    }
                });
            }, currentAsset.asset.url);
        }
コード例 #7
0
        public void ButtonClicked()
        {
            string header  = "Buy Item";
            string btnText = "Buy";
            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("Asset Name", currentAsset.name);
            data.Add("Asset Context", currentAsset.context);
            data.Add("Cost", currentAsset.price.ToString());
            PopupSystem.ShowPopup(header, data, btnText, () =>
            {
                LoadingManager.ShowLoadingScreen();
                LootLockerSDKManager.NormalPurchaseCall(currentAsset.id, currentAsset.variations.First().id, (response) =>
                {
                    LoadingManager.HideLoadingScreen();

                    if (response.success)
                    {
                        Debug.Log(response.text);
                        UpdateBalanceDisplay();

                        header = "Success";
                        data.Clear();
                        //Preparing data to display or error messages we have
                        data.Add("1", "You successfully bought: " + currentAsset.name);
                        PopupSystem.ShowApprovalFailPopUp(header, data, currentAsset.url, false);
                    }
                    else
                    {
                        Debug.Log(response.Error);

                        //making object from error json
                        string correctedResponse            = response.Error.First() == '{' ? response.Error : response.Error.Substring(response.Error.IndexOf('{'));
                        ResponseError purchaseErrorResponse = new ResponseError();
                        purchaseErrorResponse = JsonConvert.DeserializeObject <ResponseError>(correctedResponse);

                        header = "Purchase Failed";
                        data.Clear();
                        //Preparing data to display or error messages we have
                        data.Add("1", purchaseErrorResponse.messages[0]);
                        PopupSystem.ShowApprovalFailPopUp(header, data, currentAsset.url, true);
                    }
                });
            }, currentAsset.url);
        }
コード例 #8
0
        public void Grant1000XP()
        {
            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("Credits", "1000");
            PopupSystem.ShowPopup("Credits Reward", data, "Continue", () =>
            {
                LoadingManager.ShowLoadingScreen();
                LootLockerSDKManager.TriggeringAnEvent("1000 Credits", (response) =>
                {
                    if (response.success)
                    {
                        SelectPlayer(Grant.Credits);
                    }
                    else
                    {
                        Close();
                    }
                });
            }, url: creditsSprite);
        }
コード例 #9
0
        public void Grant250XP()
        {
            List <LootLockerRewardObject> rewardObjects = new List <LootLockerRewardObject>();
            Dictionary <string, string>   data          = new Dictionary <string, string>();

            data.Add("XP", "250");
            PopupSystem.ShowPopup("XP Reward", data, "Continue", () =>
            {
                LoadingManager.ShowLoadingScreen();
                LootLockerSDKManager.TriggeringAnEvent("250 XP", (response) =>
                {
                    Debug.Log("Response: " + response.message);
                    if (response.success)
                    {
                        //if (response.check_grant_notifications)
                        //{
                        LootLockerSDKManager.GetAssetNotification((res) =>
                        {
                            if (res.success)
                            {
                                for (int i = 0; i < res.objects.Length; i++)
                                {
                                    if (res.objects[i].acquisition_source == "reward_level_up")
                                    {
                                        rewardObjects.Add(res.objects[i]);
                                    }
                                }
                            }
                        });
                        //   }
                        SelectPlayer(Grant.XP, rewardObjects);
                    }
                    else
                    {
                        Close();
                    }
                });
            }, url: xpSprite);
        }
コード例 #10
0
        private void SelectPlayer(Grant grant, List <LootLockerRewardObject> rewardObjects = null)
        {
            string header                    = "";
            string normalTextMessage         = "";
            Dictionary <string, string> data = new Dictionary <string, string>();
            string icon = grant == Grant.Credits ? creditsSprite : xpSprite;

            LootLockerSDKManager.StartSession(LootLockerConfig.current.deviceID, (response) =>
            {
                LoadingManager.HideLoadingScreen();
                if (response.success)
                {
                    header = "Success";

                    if (grant == Grant.Credits)
                    {
                        normalTextMessage = "Successfully granted Credits.";
                    }
                    if (grant == Grant.XP)
                    {
                        normalTextMessage = "Successfully granted XP.";
                    }

                    data.Clear();
                    //Preparing data to display or error messages we have
                    data.Add("1", normalTextMessage);
                    StagesManager.instance.GoToStage(StagesManager.StageID.Home, response);
                    if (rewardObjects != null && rewardObjects.Count > 0)
                    {
                        for (int i = 0; i < rewardObjects.Count; i++)
                        {
                            PopupData PopupData  = new PopupData();
                            PopupData.buttonText = "Ok";
                            PopupData.url        = rewardObjects[i].asset.links.thumbnail;
                            PopupData.withKey    = true;
                            PopupData.normalText = new Dictionary <string, string>()
                            {
                                { "Reward", rewardObjects[i].asset.name }
                            };
                            PopupData.header = "You got a reward";
                            PopupSystem.ShowScheduledPopup(PopupData);
                        }
                    }
                }
                else
                {
                    header = "Failed";

                    string correctedResponse   = response.Error.First() == '{' ? response.Error : response.Error.Substring(response.Error.IndexOf('{'));
                    ResponseError errorMessage = new ResponseError();
                    errorMessage = JsonConvert.DeserializeObject <ResponseError>(correctedResponse);

                    normalTextMessage = errorMessage.messages[0];

                    data.Clear();
                    //Preparing data to display or error messages we have
                    data.Add("1", normalTextMessage);
                }
                PopupSystem.ShowApprovalFailPopUp(header, data, icon);
            });
        }
コード例 #11
0
 public void Close()
 {
     LoadingManager.HideLoadingScreen();
     PopupSystem.CloseNow();
 }