public static void GetUserInventory(Action callback = null) { DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GetUserInventory); PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest(), (GetUserInventoryResult result) => { virtualCurrency.Clear(); playerInventory.Clear(); foreach (var pair in result.VirtualCurrency) { virtualCurrency.Add(pair.Key, pair.Value); } foreach (var eachItem in result.Inventory) { playerInventory.Add(eachItem); } inventoryByCategory.Clear(); if (PF_GameData.catalogItems.Count > 0) { foreach (var item in playerInventory) { if (inventoryByCategory.ContainsKey(item.ItemId)) { continue; } var catalogItem = PF_GameData.GetCatalogItemById(item.ItemId); if (catalogItem == null) { continue; } var items = playerInventory.FindAll(x => { return(x.ItemId.Equals(item.ItemId)); }); var customIcon = PF_GameData.GetIconByItemById(catalogItem.ItemId); var icon = GameController.Instance.iconManager.GetIconById(customIcon, IconManager.IconTypes.Item); inventoryByCategory.Add(item.ItemId, new InventoryCategory(item.ItemId, catalogItem, items, icon)); } } if (callback != null) { callback(); } PF_Bridge.RaiseCallbackSuccess("", PlayFabAPIMethods.GetUserInventory, MessageDisplayStyle.none); }, PF_Bridge.PlayFabErrorCallback); }
public void AfterUnlock(UnlockContainerItemResult result) { // unlocking a container will automatically add the returned items, this ensures that items are not added twice. PF_GamePlay.QuestProgress.ItemsFound.Remove(selectedItem.ItemId); // build our list for displaying the container results List <ContainerResultItem> items = new List <ContainerResultItem>(); foreach (var award in result.GrantedItems) { var awardIcon = PF_GameData.GetIconByItemById(award.ItemId); items.Add(new ContainerResultItem { displayIcon = GameController.Instance.iconManager.GetIconById(awardIcon, IconManager.IconTypes.Item), displayName = award.DisplayName }); } if (result.VirtualCurrency != null) { foreach (var award in result.VirtualCurrency) { string friendlyName; switch (award.Key) { case GlobalStrings.GOLD_CURRENCY: friendlyName = "Gold"; break; case GlobalStrings.HEART_CURRENCY: friendlyName = "Lives"; break; case GlobalStrings.GEM_CURRENCY: friendlyName = "Gems"; break; default: friendlyName = ""; break; } items.Add(new ContainerResultItem { displayIcon = GameController.Instance.iconManager.GetIconById(award.Key, IconManager.IconTypes.Item), displayName = award.Value + " " + friendlyName }); } } CurrentIcon.overrideSprite = GameController.Instance.iconManager.GetIconById(currentIconId + "_Open", IconManager.IconTypes.Item); openedBoxes.Add(selectedIndex, items); EnableUnlockedItemsView(items); DialogCanvasController.RequestInventoryPrompt(); }
public void SetupSlider(UnityAction <UnlockContainerItemResult> callback = null) { afterUnlock = callback; ItemDescription.text = controller.selectedItem.Description; if (controller.selectedItem.Container != null) { var keyId = controller.selectedItem.Container.KeyItemId; var keyReference = PF_GameData.GetCatalogItemById(keyId); endIcon.gameObject.SetActive(keyReference != null); if (keyReference != null) { var chestQty = PF_PlayerData.GetItemQty(controller.selectedItem.ItemId); var keyQty = PF_PlayerData.GetItemQty(keyId); var useColor = (chestQty > 0 && keyQty > 0) ? Color.cyan : Color.red; endIcon.color = useColor; sliderMessage.text = string.Format("{0} Required ({1} available)", keyReference.DisplayName, Mathf.Min(chestQty, keyQty)); sliderMessage.color = useColor; var iconName = PF_GameData.GetIconByItemById(keyReference.ItemId, GlobalStrings.BRONZE_KEY_ICON); var icon = GameController.Instance.iconManager.GetIconById(iconName, IconManager.IconTypes.Item); handle.overrideSprite = icon; } else { handle.overrideSprite = GameController.Instance.iconManager.GetIconById(GlobalStrings.DARKSTONE_LOCK_ICON, IconManager.IconTypes.Misc); sliderMessage.text = GlobalStrings.UNLOCKED_MSG; } } else { sliderMessage.text = GlobalStrings.UNLOCKED_MSG; // set default key icon or lock or something... } }
private static void OnGetUserAccountInfoSuccess(GetPlayerCombinedInfoResult result) { playerInventory.Clear(); foreach (var eachItem in result.InfoResultPayload.UserInventory) { playerInventory.Add(eachItem); } accountInfo = result.InfoResultPayload.AccountInfo; if (result.InfoResultPayload.UserData.ContainsKey("IsRegisteredForPush")) { isRegisteredForPush = result.InfoResultPayload.UserData["IsRegisteredForPush"].Value == "1"; } else { isRegisteredForPush = false; } if (result.InfoResultPayload.UserData.ContainsKey("ShowAccountOptionsOnLogin") && result.InfoResultPayload.UserData["ShowAccountOptionsOnLogin"].Value == "0") { showAccountOptionsOnLogin = false; } else //if (PF_Authentication.hasLoggedInOnce == false) { //PF_Authentication.hasLoggedInOnce = true; DialogCanvasController.RequestAccountSettings(); } inventoryByCategory.Clear(); if (PF_GameData.catalogItems.Count > 0) { foreach (var item in playerInventory) { if (inventoryByCategory.ContainsKey(item.ItemId)) { continue; } var catalogItem = PF_GameData.GetCatalogItemById(item.ItemId); if (catalogItem == null) { continue; } var items = new List <ItemInstance>(playerInventory.FindAll((x) => { return(x.ItemId.Equals(item.ItemId)); })); var customIcon = PF_GameData.GetIconByItemById(catalogItem.ItemId); var icon = GameController.Instance.iconManager.GetIconById(customIcon, IconManager.IconTypes.Item); inventoryByCategory.Add(item.ItemId, new InventoryCategory(item.ItemId, catalogItem, items, icon)); } } if (PF_Authentication.GetDeviceId(true)) { Debug.Log("Mobile Device ID Found!"); var deviceId = string.IsNullOrEmpty(PF_Authentication.android_id) ? PF_Authentication.ios_id : PF_Authentication.android_id; PlayerPrefs.SetString("LastDeviceIdUsed", deviceId); } else { Debug.Log("Custom Device ID Found!"); if (string.IsNullOrEmpty(PF_Authentication.custom_id)) { PlayerPrefs.SetString("LastDeviceIdUsed", PF_Authentication.custom_id); } } virtualCurrency.Clear(); foreach (var eachPair in result.InfoResultPayload.UserVirtualCurrency) { virtualCurrency.Add(eachPair.Key, eachPair.Value); } PF_Bridge.RaiseCallbackSuccess("Player Account Info Loaded", PlayFabAPIMethods.GetAccountInfo, MessageDisplayStyle.none); }
public void SetSelectedItem(CatalogItem item) { selectedItem = item; CurrentItemName.text = selectedItem.DisplayName; CurrentItemDesc.text = selectedItem.Description; ItemCount.text = string.Format("{0}/{1}", selectedIndex + 1, pfItems.Count); // refresh the UI currentIconId = PF_GameData.GetIconByItemById(item.ItemId); var icon = GameController.Instance.iconManager.GetIconById(currentIconId, IconManager.IconTypes.Item); CurrentIcon.overrideSprite = icon; if (openedBoxes.ContainsKey(selectedIndex)) { // this container has been opened, show the items... if (PF_GameData.IsContainer(selectedItem.ItemId)) { CurrentIcon.overrideSprite = GameController.Instance.iconManager.GetIconById(currentIconId + "_Open", IconManager.IconTypes.Item); } EnableContainerMode(true); return; } // test bundles here.... // if bundle, we need to show the contents, but not remove it from the list, as it will be unpacked and added automatically if (selectedItem.Bundle != null && (selectedItem.Bundle.BundledItems != null || selectedItem.Bundle.BundledResultTables != null || selectedItem.Bundle.BundledVirtualCurrencies != null)) { var bundleItems = new List <ContainerResultItem>(); if (selectedItem.Bundle.BundledItems != null && selectedItem.Bundle.BundledItems.Count > 0) { foreach (var award in selectedItem.Bundle.BundledItems) { var catalogItem = PF_GameData.GetCatalogItemById(award); var awardIcon = PF_GameData.GetIconByItemById(award); bundleItems.Add(new ContainerResultItem { displayIcon = GameController.Instance.iconManager.GetIconById(awardIcon, IconManager.IconTypes.Item), displayName = catalogItem.DisplayName }); } } if (selectedItem.Bundle.BundledResultTables != null && selectedItem.Bundle.BundledResultTables.Count > 0) { foreach (var award in selectedItem.Bundle.BundledResultTables) { bundleItems.Add(new ContainerResultItem { displayIcon = GameController.Instance.iconManager.GetIconById("DropTable", IconManager.IconTypes.Misc), displayName = string.Format("Drop Table: {0}", award) }); } } if (selectedItem.Bundle.BundledVirtualCurrencies != null && selectedItem.Bundle.BundledVirtualCurrencies.Count > 0) { foreach (var award in selectedItem.Bundle.BundledVirtualCurrencies) { bundleItems.Add(new ContainerResultItem { displayIcon = GameController.Instance.iconManager.GetIconById(award.Key, IconManager.IconTypes.Item), displayName = string.Format("{1} Award: {0:n0}", award.Value, award.Key) }); } } if (bundleItems.Count > 0) { openedBoxes.Add(selectedIndex, bundleItems); EnableContainerMode(true); // dont fall through the rest of the logic. return; } } if (PF_GameData.IsContainer(selectedItem.ItemId)) { EnableContainerMode(); } else { DisableContainerMode(); } }
private static void GetItemIcon(StoreItem storeItem, out Sprite icon) { var iconName = PF_GameData.GetIconByItemById(storeItem.ItemId); icon = GameController.Instance.iconManager.GetIconById(iconName, IconManager.IconTypes.Item); }