/// <summary> /// Retrieves the specified character's current inventory of virtual goods /// </summary> public static void GetCharacterInventory(GetCharacterInventoryRequest request, ProcessApiCallback<GetCharacterInventoryResult> resultCallback, ErrorCallback errorCallback, object customData = null) { if (_authKey == null) throw new Exception("Must be logged in to call this method"); string serializedJson = SimpleJson.SerializeObject(request, Util.ApiSerializerStrategy); Action<CallRequestContainer> callback = delegate(CallRequestContainer requestContainer) { ResultContainer<GetCharacterInventoryResult>.HandleResults(requestContainer, resultCallback, errorCallback, null); }; PlayFabHTTP.Post("/Client/GetCharacterInventory", serializedJson, "X-Authorization", _authKey, callback, request, customData); }
/// <summary> /// Retrieves the specified character's current inventory of virtual goods /// </summary> public static void GetCharacterInventory(GetCharacterInventoryRequest request, GetCharacterInventoryCallback resultCallback, ErrorCallback errorCallback) { if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); string serializedJSON = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings); Action<string,string> callback = delegate(string responseStr, string errorStr) { GetCharacterInventoryResult result = null; PlayFabError error = null; ResultContainer<GetCharacterInventoryResult>.HandleResults(responseStr, errorStr, out result, out error); if(error != null && errorCallback != null) { errorCallback(error); } if(result != null) { if(resultCallback != null) { resultCallback(result); } } }; PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Client/GetCharacterInventory", serializedJSON, "X-Authorization", AuthKey, callback); }
//Gets all the quests that player completed public static void GetCharacterCompletedQuests() { var request = new GetCharacterInventoryRequest() { CharacterId = PlayFabDataStore.characterId }; PlayFabClientAPI.GetCharacterInventory(request, (result) => { foreach (var item in result.Inventory) { if(item.ItemClass == "Quest") { if (!PlayFabDataStore.playerCompletedQuests.Contains(item.ItemId)) { PlayFabDataStore.playerCompletedQuests.Add(item.ItemId); } } } Debug.Log("Character Quests are retrieved"); //RuneWindow.SortAllRunes(); }, (error) => { Debug.Log("Character Quests can't retrieved!"); Debug.Log(error.ErrorMessage); Debug.Log(error.ErrorDetails); }); }
//Gets all the items that player completed public static void GetAllCharacterItems() { var request = new GetCharacterInventoryRequest() { CharacterId = PlayFabDataStore.characterId }; PlayFabClientAPI.GetCharacterInventory(request, (result) => { foreach (var item in result.Inventory) { if (item.ItemClass == "Item") { List<PlayerItemInfo> itemInfoList = new List<PlayerItemInfo>(); if (item.CustomData == null) { PlayerItemInfo itemInfo = new PlayerItemInfo(item.ItemId, item.ItemInstanceId, "0"); PlayFabDataStore.playerInventory.Add(item.ItemId); if(PlayFabDataStore.playerInventoryInfo.ContainsKey(item.ItemId)) { PlayFabDataStore.playerInventoryInfo[item.ItemId].Add(itemInfo); } else { PlayFabDataStore.playerInventoryInfo.Add(item.ItemId, itemInfoList); PlayFabDataStore.playerInventoryInfo[item.ItemId].Add(itemInfo); } } else { PlayerItemInfo itemInfo = new PlayerItemInfo(item.ItemId, item.ItemInstanceId, item.CustomData["IsEquipped"].ToString()); if (PlayFabDataStore.playerInventoryInfo.ContainsKey(item.ItemId)) { PlayFabDataStore.playerInventoryInfo[item.ItemId].Add(itemInfo); } else { PlayFabDataStore.playerInventoryInfo.Add(item.ItemId, itemInfoList); PlayFabDataStore.playerInventoryInfo[item.ItemId].Add(itemInfo); } if (item.CustomData["IsEquipped"] == "1") { Debug.Log("Equipped item added to the equipped dictionary"); PlayFabDataStore.playerEquippedItems.Add(PlayFabDataStore.catalogItems[item.ItemId].itemType, itemInfo); } else { PlayFabDataStore.playerInventory.Add(item.ItemId); } } } } Debug.Log("Character Items are retrieved"); }, (error) => { Debug.Log("Character Items can't retrieved!"); Debug.Log(error.ErrorMessage); Debug.Log(error.ErrorDetails); }); }
public static void GetAllCharacterRunes() { var request = new GetCharacterInventoryRequest() { CharacterId = PlayFabDataStore.characterId }; PlayFabClientAPI.GetCharacterInventory(request, (result) => { foreach (var item in result.Inventory) { if (item.ItemClass == "Skill" || item.ItemClass == "Modifier") { if (!PlayFabDataStore.playerAllRunes.ContainsKey(item.ItemId)) { if (item.CustomData == null) { PlayFabDataStore.playerAllRunes.Add(item.ItemId, new PlayerRune(item.ItemId, item.ItemInstanceId, item.ItemClass, item.DisplayName, "0")); } else { PlayFabDataStore.playerAllRunes.Add(item.ItemId, new PlayerRune(item.ItemId, item.ItemInstanceId, item.ItemClass, item.DisplayName, item.CustomData["Active"])); } } } } Debug.Log("Runes are retrieved"); RuneWindow.SortAllRunes(); }, (error) => { Debug.Log("Catalog can't retrieved!"); Debug.Log(error.ErrorMessage); Debug.Log(error.ErrorDetails); }); }
//Receives all items in characters inventory public static void GetCharacterInventory() { var request = new GetCharacterInventoryRequest() { CharacterId = PlayFabDataStore.characterId }; PlayFabClientAPI.GetCharacterInventory(request, (result) => { Debug.Log("Inventory Count: " + result.Inventory.Count); foreach (var item in result.Inventory) { Debug.Log(item.DisplayName); Debug.Log(item.ItemInstanceId); } }, (error) => { Debug.Log("Listing Inventory Failed!"); Debug.Log(error.ErrorMessage); Debug.Log(error.ErrorDetails); }); }
private void GetCharacterInventory_C() { var getRequest = new ClientModels.GetCharacterInventoryRequest(); getRequest.CharacterId = characterId; PlayFabClientAPI.GetCharacterInventory(getRequest, GetCharacterItemsCallback_C, SharedFailCallback("GetCharacterInventory_C")); }
/// <summary> /// Retrieves the specified character's current inventory of virtual goods /// </summary> public static async Task<PlayFabResult<GetCharacterInventoryResult>> GetCharacterInventoryAsync(GetCharacterInventoryRequest request) { if (AuthKey == null) throw new Exception ("Must be logged in to call this method"); object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Client/GetCharacterInventory", request, "X-Authorization", AuthKey); if(httpResult is PlayFabError) { PlayFabError error = (PlayFabError)httpResult; if (PlayFabSettings.GlobalErrorHandler != null) PlayFabSettings.GlobalErrorHandler(error); return new PlayFabResult<GetCharacterInventoryResult> { Error = error, }; } string resultRawJson = (string)httpResult; var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings); var resultData = serializer.Deserialize<PlayFabJsonSuccess<GetCharacterInventoryResult>>(new JsonTextReader(new StringReader(resultRawJson))); GetCharacterInventoryResult result = resultData.data; return new PlayFabResult<GetCharacterInventoryResult> { Result = result }; }
private Action GetCharacterInventory(string characterId) { Action output = () => { var getRequest = new ClientModels.GetCharacterInventoryRequest(); getRequest.CharacterId = characterId; PlayFabClientAPI.GetCharacterInventory(getRequest, GetCharInventoryCallback, SharedFailCallback("GetCharacterInventory: " + characterId)); }; return output; }