public void ViewCollectables() { LoadingManager.ShowLoadingScreen(); StagesManager.instance.GoToStage(StagesManager.StageID.Collectables, null); }
public void ViewInventory() { LoadingManager.ShowLoadingScreen(); StagesManager.instance.GoToStage(StagesManager.StageID.Inventory, null); }
public void ViewStore() { LoadingManager.ShowLoadingScreen(); StagesManager.instance.GoToStage(StagesManager.StageID.Store, null); }
public void ViewInventory() { this.normalText.text = ""; this.normalText.text += "Asset Name" + " : " + "" + "\n"; this.normalText.text += "Asset Context" + " : " + "" + "\n"; LootLockerSDKManager.GetCurrentLoadOutToDefaultCharacter((response) => { if (response.success) { foreach (Transform tr in inventoryParent) { Destroy(tr.gameObject); } contextControllers.Clear(); LootLockerSDKManager.GetEquipableContextToDefaultCharacter((contextResponse) => { if (contextResponse.success) { string[] contexts = contextResponse.contexts.Select(x => x.name).ToArray(); LootLockerCommonAsset[] assets = response.GetAssets(); for (int i = 0; i < contexts.Length; i++) { GameObject contextObject = Instantiate(contextsPrefab, inventoryParent); ContextController contextController = contextObject.GetComponent <ContextController>(); contextController.Init(contexts[i], assets.FirstOrDefault(x => x.context == contexts[i])?.id.ToString()); contextControllers.Add(contextController); } this.headerText.text = "Inventory"; selectText.text = "Equip"; this.normalText.text = ""; this.normalText.text += "Asset Name" + " : " + "" + "\n"; this.normalText.text += "Asset Context" + " : " + "" + "\n"; LootLockerSDKManager.GetInventory((res) => { LoadingManager.HideLoadingScreen(); if (res.success) { InventoryAssetResponse.InventoryResponse mainResponse = JsonConvert.DeserializeObject <InventoryAssetResponse.InventoryResponse>(res.text); Debug.Log("Successful got inventory: " + res.text); for (int j = 0; j < contextControllers.Count; j++) { InventoryAssetResponse.Inventory[] inventories = mainResponse.inventory.Where(x => x.asset?.context == contextControllers[j].context)?.ToArray(); Dictionary <int, int> numberOfInventories = new Dictionary <int, int>();//It will contain amount of each inventory we have for (int i = 0; i < inventories.Length; i++) { if (numberOfInventories.ContainsKey(inventories[i].asset.id))//Increase amount of inventory if we already have it in our dictionary { numberOfInventories[inventories[i].asset.id]++; } else { numberOfInventories.Add(inventories[i].asset.id, 1); } } inventories = inventories.GroupBy(x => x.asset.id).Select(x => x.First()).ToArray();//Grouping inventories, so we won't have duplicates contextControllers[j].Populate(inventories, numberOfInventories); } } else { Debug.LogError("failed to get all inventory items: " + res.Error); } }); } else { Debug.LogError("failed to get all inventory items: " + contextResponse.Error); } }); } }); }
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); }); }); } }
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); }); }
public void OpenPlayerStorage() { LoadingManager.ShowLoadingScreen(); StagesManager.instance.GoToStage(StagesManager.StageID.Storage, null); }
public void Close() { LoadingManager.HideLoadingScreen(); PopupSystem.CloseNow(); }