Beispiel #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);
                }
            });
        }
Beispiel #2
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);
                }
            });
        }
Beispiel #3
0
        public void StartSession()
        {
            Guid guid = Guid.NewGuid();

            LoadingManager.ShowLoadingScreen();
            //Starting a new session using the new id that has been created
            LootLockerSDKManager.StartSession(guid.ToString(), (response) =>
            {
                if (response.success)
                {
                    Debug.Log("Created Session for new player with id: " + guid.ToString());
                    LocalPlayer localPlayer = new LocalPlayer {
                        playerName = newPlayerName.text, uniqueID = guid.ToString(), characterClass = null
                    };
                    List <LocalPlayer> localPlayers = JsonConvert.DeserializeObject <List <LocalPlayer> >(PlayerPrefs.GetString(playerStorageKeyNameToUse));
                    localPlayers.Add(localPlayer);
                    PlayerPrefs.SetString(playerStorageKeyNameToUse, JsonConvert.SerializeObject(localPlayers));
                    ListPlayers();
                    LoadingManager.HideLoadingScreen();
                }
                else
                {
                    Debug.LogError("Session failure: " + response.text);
                }
            });
        }
Beispiel #4
0
        public void SelectPlayer(LocalPlayer selectedPlayer)
        {
            if (isEasyPrefab)
            {
                Debug.LogError("You clicked on player " + selectedPlayer.playerName + " thats all we know :) ");
                return;
            }
            playersScreen.SetActive(false);

            createPlayerScreen.SetActive(false);

            LoadingManager.ShowLoadingScreen();

            LootLockerConfig.current.deviceID = selectedPlayer.uniqueID;

            LootLockerSDKManager.StartSession(selectedPlayer.uniqueID, (response) =>
            {
                if (response.success)
                {
                    playersScreen.SetActive(true);
                    Debug.Log("Logged in successfully.");
                    LoadingManager.HideLoadingScreen();
                    LootLockerConfig.current.playerName  = selectedPlayer.playerName;
                    LootLockerConfig.current.playerClass = selectedPlayer.characterClass.type.ToString();
                    StagesManager.instance.GoToStage(StagesManager.StageID.Home, response);
                }
                else
                {
                    playersScreen.SetActive(true);
                    Debug.LogError("Log in failure.");
                    LoadingManager.HideLoadingScreen();
                }
            });
        }
Beispiel #5
0
 void ListMessages()
 {
     LoadingManager.ShowLoadingScreen();
     LootLockerSDKManager.GetMessages((response) =>
     {
         LoadingManager.HideLoadingScreen();
         if (response.success)
         {
             Debug.Log("Successful got all messages: " + response.text);
             for (int i = 0; i < messagesParent.childCount; i++)
             {
                 Destroy(messagesParent.GetChild(i).gameObject);
             }
             foreach (LootLockerGMMessage message in response.messages)
             {
                 GameObject messageObject = Instantiate(messagePrefab, messagesParent);
                 messageObject.GetComponent <MessageElement>().InitMessage(message);
                 messageObject.GetComponent <Button>().onClick.AddListener(() => SelectMessage(message));
             }
         }
         else
         {
             Debug.LogError("failed to get all messages: " + response.Error);
         }
     });
 }
Beispiel #6
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");
        }
Beispiel #7
0
        IEnumerator DelayShowing()
        {
            LoadingManager.ShowLoadingScreen();
            yield return(new WaitForSeconds(1f));

            for (int i = 0; i < objects.Count; i++)
            {
                objects[i].transform.SetParent(scrollViewContent);
                objects[i].transform.localScale = new Vector3(1, 1, 1);
            }
            LoadingManager.HideLoadingScreen();
        }
Beispiel #8
0
 public void Refresh()
 {
     LoadingManager.ShowLoadingScreen();
     foreach (Transform tr in content.transform)
     {
         Destroy(tr.gameObject);
     }
     LootLockerSDKManager.GetEntirePersistentStorage((response) =>
     {
         LoadingManager.HideLoadingScreen();
         UpdateScreen(response.payload);
     });
 }
Beispiel #9
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);
        }
Beispiel #10
0
 public void UpdateScreenData(ILootLockerStageData stageData)
 {
     asset = stageData as InventoryAssetResponse.DemoAppAsset;
     if (asset != null)
     {
         if (asset.files != null && asset.files.Length > 0)
         {
             url = asset.files.Last().url;
             TypeOfFile filetype = GetFileType(url);
             downloadFileBtn.onClick.AddListener(() =>
             {
                 LoadingManager.ShowLoadingScreen();
                 DownloadFile(filetype);
             });
         }
     }
 }
Beispiel #11
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);
        }
Beispiel #12
0
        public void CreateNewSession()
        {
            LoadingManager.ShowLoadingScreen();
            string defaultUser = LootLockerConfig.current != null && string.IsNullOrEmpty(LootLockerConfig.current.deviceID) ? LootLockerConfig.current.deviceID : "NewUserDefault";

            //Starting a new session using the new id that has been created
            LootLockerSDKManager.StartSession(defaultUser, (response) =>
            {
                if (response.success)
                {
                    UpdateScreenData(response);
                    Debug.Log("Created Session for new player with id: " + defaultUser);
                }
                else
                {
                    Debug.LogError("Session failure: " + response.text);
                }
            });
        }
Beispiel #13
0
        public void UpdateScreenData(ILootLockerStageData stageData)
        {
            LoadingManager.ShowLoadingScreen();
            LootLockerGMMessage selectedMessage = stageData as LootLockerGMMessage;

            if (!string.IsNullOrEmpty(selectedMessage.image))
            {
                messageImage.gameObject.SetActive(true);
                _ = DownloadImage(selectedMessage.image, messageImage);
            }
            else
            {
                messageImage.gameObject.SetActive(false);
                LoadingManager.HideLoadingScreen();
            }
            messageSummary.text = selectedMessage.summary ?? "";
            messageBody.text    = selectedMessage.body ?? "";
            messageTitle.text   = selectedMessage.title ?? "";
        }
Beispiel #14
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);
        }
Beispiel #15
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);
        }
Beispiel #16
0
        public void StartSession(Action OnCompletedSessionStart)
        {
            guid = Guid.NewGuid();

            LoadingManager.ShowLoadingScreen();
            //Starting a new session using the new id that has been created
            LootLockerSDKManager.StartSession(guid.ToString(), (response) =>
            {
                if (response.success)
                {
                    sessionResponse = response;
                    Debug.Log("Session success: " + response.text);
                    OnCompletedSessionStart?.Invoke();
                }
                else
                {
                    failResponse?.Invoke();
                    Debug.LogError("Session failure: " + response.text);
                    LoadingManager.HideLoadingScreen();
                }
            });
        }
Beispiel #17
0
        public void UpdateScreenData(ILootLockerStageData stageData)
        {
            if (stageData != null)
            {
                createPlayerRequest = stageData as CreatePlayerRequest;
                LootLockerConfig.current.playerName = createPlayerRequest.playerName;
                LoadingManager.ShowLoadingScreen();
                failResponse = () => { StagesManager.instance.GoToStage(StagesManager.StageID.Player, null); };
                //Starting session first before character is chosen
                StartSession(() =>
                {
                    foreach (Transform tr in parent)
                    {
                        Destroy(tr.gameObject);
                    }

                    LootLockerSDKManager.GetCharacterLoadout((response) =>
                    {
                        if (response.success)
                        {
                            foreach (LootLockerLootLockerLoadout loadout in response.loadouts)
                            {
                                GameObject selectionButton = Instantiate(characterClassPrefab, parent);
                                selectionButton.GetComponent <ClassSelectionButton>()?.Init(loadout);
                            }
                        }
                        else
                        {
                            StagesManager.instance.GoToStage(StagesManager.StageID.CreatePlayer, null);
                        }
                        LoadingManager.HideLoadingScreen();
                    });
                });
                //if we are creating a new character then we want to set character details once it is created
                button.onClick.RemoveAllListeners();
                button.onClick.AddListener(() =>
                {
                    UpdateDefaultCharacterClass(() =>
                    {
                        if (!isEasyPrefab)
                        {
                            LocalPlayer localPlayer = new LocalPlayer {
                                playerName = createPlayerRequest.playerName, uniqueID = guid.ToString(), characterClass = loadout?.character
                            };
                            List <LocalPlayer> localPlayers = JsonConvert.DeserializeObject <List <LocalPlayer> >(PlayerPrefs.GetString("localplayers"));
                            localPlayers.Add(localPlayer);
                            PlayerPrefs.SetString("localplayers", JsonConvert.SerializeObject(localPlayers));
                            LootLockerConfig.current.deviceID    = localPlayer.uniqueID;
                            LootLockerConfig.current.playerClass = loadout.character.type.ToString();
                            //Character has been set, we can now load the home page
                            StagesManager.instance.GoToStage(StagesManager.StageID.Home, sessionResponse);
                        }
                        else
                        {
                            Debug.Log("Updated the default class for the current player");
                        }
                    });
                });
            }
            else
            {
                failResponse = () => { StagesManager.instance.GoToStage(StagesManager.StageID.Settings, null); };

                foreach (Transform tr in parent)
                {
                    Destroy(tr.gameObject);
                }

                LootLockerSDKManager.GetCharacterLoadout((response) =>
                {
                    if (response.success)
                    {
                        foreach (LootLockerLootLockerLoadout loadout in response.loadouts)
                        {
                            GameObject selectionButton = Instantiate(characterClassPrefab, parent);
                            selectionButton.GetComponent <ClassSelectionButton>()?.Init(loadout);
                        }
                    }
                    else
                    {
                        StagesManager.instance.GoToStage(StagesManager.StageID.Settings, null);
                    }
                    LoadingManager.HideLoadingScreen();
                });
                //if we are just updating the character class for player, then after it is completed. We want to return to the inventory screen
                button.onClick.RemoveAllListeners();
                button.onClick.AddListener(() =>
                {
                    UpdateDefaultCharacterClass(() =>
                    {
                        //Character has been set, we can now load inventory
                        StagesManager.instance.GoToStage(StagesManager.StageID.Settings, null);
                    });
                });
            }
        }
Beispiel #18
0
 public void ViewCollectables()
 {
     LoadingManager.ShowLoadingScreen();
     StagesManager.instance.GoToStage(StagesManager.StageID.Collectables, null);
 }
Beispiel #19
0
 public void ViewStore()
 {
     LoadingManager.ShowLoadingScreen();
     StagesManager.instance.GoToStage(StagesManager.StageID.Store, null);
 }
Beispiel #20
0
 public void ViewInventory()
 {
     LoadingManager.ShowLoadingScreen();
     StagesManager.instance.GoToStage(StagesManager.StageID.Inventory, null);
 }
Beispiel #21
0
 public void OpenPlayerStorage()
 {
     LoadingManager.ShowLoadingScreen();
     StagesManager.instance.GoToStage(StagesManager.StageID.Storage, null);
 }