//getting the items declared in PlayFab's catalog and converting them to Unity IAP format private void OnCatalogRetrieved(GetCatalogItemsResult result) { for (int i = 0; i < result.Catalog.Count; i++) { CatalogItem catalogItem = result.Catalog[i]; string itemId = IAPManager.GetIAPIdentifier(catalogItem.ItemId); if (!IAPManager.GetIAPKeys().Contains(itemId) || products.ContainsKey(itemId)) { continue; } ApplyCatalogItem(itemId, catalogItem); decimal price = 0; string priceString = ""; string currency = catalogItem.VirtualCurrencyPrices.Keys.First(); if (currency == "RM") { price = (decimal)catalogItem.VirtualCurrencyPrices[currency] / 100m; priceString = price.ToString("C"); } else { price = catalogItem.VirtualCurrencyPrices[currency]; priceString = price.ToString(); } products.Add(itemId, new ProductDescription(itemId, new ProductMetadata(priceString, catalogItem.DisplayName, catalogItem.Description, "USD", price))); } if (callback != null) { callback.OnProductsRetrieved(products.Values.ToList()); } }
private static void OnGetCatalogSuccess(GetCatalogItemsResult result) { catalogItems.Clear(); foreach (var eachItem in result.Catalog) { catalogItems[eachItem.ItemId] = eachItem; } PF_PlayerData.GetUserAccountInfo(); }
public void GetCatalogItemsResult(GetCatalogItemsResult _result) { for (int i = 0; i < _result.Catalog.Count; i++) { Debug.Log(TestUtilities.PrintCatalogItem(_result.Catalog[i])); } if (_result.Catalog.Count > 0) { PruchaseItem(_result.Catalog[0]); } }
private static void GetCatalogItemsCallback_Single(GetCatalogItemsResult result) { Callbacks.Add("GetCatalogItemsCallback_Single"); var testContext = (UUnitTestContext)result.CustomData; // NOTE: This depends on the global callbacks happening before the local callback CheckCallbacks(testContext, "GetCatalogItemsCallback_Single", Callbacks); CheckCallbacks(testContext, "SuccessCallback_Global", Callbacks); testContext.IntEquals(2, Callbacks.Count, string.Join(",", Callbacks.ToArray())); testContext.EndTest(UUnitFinishState.PASSED, ""); }
private void ConstructCatalog(GetCatalogItemsResult result) { items = result.Catalog; renderCatalog = true; itemIcons = new Dictionary <string, Texture2D>(); for (int x = 0; x < items.Count; x++) { Dictionary <string, string> customData = JsonReader.Deserialize <Dictionary <string, string> >(items[x].CustomData); itemIcons.Add(items[x].ItemId, icons[customData["Icon"]]); if (listEquipments && items[x].ItemClass.Equals("Mainhand") && !PlayFabGameBridge.mainhandType.ContainsKey(items[x].ItemId)) { // Use unique id of weapon to add new item. // float.Parse(customData["Frequency"]) string newMainhandName = items[x].ItemId; Weapon newMainhand = new Weapon { /*Parse custom data here*/ }; PlayFabGameBridge.mainhandName.Add(newMainhandName); PlayFabGameBridge.mainhandType.Add(newMainhandName, newMainhand); } if (listEquipments && items[x].ItemClass.Equals("Offhand") && !PlayFabGameBridge.offhandType.ContainsKey(items[x].ItemId)) { // Use unique id of offhand to add new item. string newOffhandName = items[x].ItemId; Offhand newOffhand = new Offhand { /*Parse custom data here*/ }; PlayFabGameBridge.offhandName.Add(newOffhandName); PlayFabGameBridge.offhandType.Add(newOffhandName, newOffhand); } if (listEquipments && items[x].ItemClass.Equals("Armor") && !PlayFabGameBridge.armorType.ContainsKey(items[x].ItemId)) { // Use unique id of armor to add new item. string newArmorName = items[x].ItemId; Armor newArmor = new Armor { /*Parse custom data here*/ }; PlayFabGameBridge.armorName.Add(newArmorName); PlayFabGameBridge.armorType.Add(newArmorName, newArmor); } if (listPotions && items[x].ItemClass.Equals("Potions") && !PlayFabGameBridge.potionType.ContainsKey(items[x].ItemId)) { // Use unique id of potion to add new item. string newPotionName = items[x].ItemId; Potion newPotion = new Potion { /*Parse custom data here*/ }; PlayFabGameBridge.potionName.Add(newPotionName); PlayFabGameBridge.potionType.Add(newPotionName, newPotion); } } Time.timeScale = 1; }
private void OnGetCatalogItemSuccess(GetCatalogItemsResult result) { // CatalogItem info: https://api.playfab.com/documentation/Server/datatype/PlayFab.Server.Models/PlayFab.Server.Models.CatalogItem //Debug //Debug.Log("PlayFab - GetCatalogItemSuccess"); DebugText.text += "\nPlayFab - GetCatalogItemSuccess"; //Set Catalog of items to the shop list Scriptable CharacterReferences.instance.charactersInfo.GetItemList(result.Catalog); //Get User Inventory from Server GetPlayFabInventory(); }
void RetrieveCallback(GetCatalogItemsResult result) { Items = result.Catalog; if (OnRetrieved != null) { OnRetrieved(this); } Respond(null); if (IsOnline) { Save(result, FileName); } }
///// /// /// /// Construct and Render the Catalog based on the Catalog Version /// /// ///// private void ConstructCatalog(GetCatalogItemsResult result) { items = result.Catalog; renderCatalog = true; itemIcons = new Dictionary <string, Texture2D> (); PlayFabGameBridge.itemNames = new List <string> (); // construct the default gun type PlayFabGameBridge.gunNames = new List <string> (); PlayFabGameBridge.gunTypes = new Dictionary <string, Gun> (); PlayFabGameBridge.currentGunName = "Default"; PlayFabGameBridge.itemNames.Add(PlayFabGameBridge.currentGunName); PlayFabGameBridge.gunNames.Add(PlayFabGameBridge.currentGunName); PlayFabGameBridge.gunTypes.Add(PlayFabGameBridge.currentGunName, new Gun { Frequency = 10.0F, ConeAngle = 1.5F, DamagePerSecond = 20.0F, HitSoundVolume = 0.5F, Pitch = 1.0F }); // default gun PlayFabGameBridge.currentGun = PlayFabGameBridge.gunTypes [PlayFabGameBridge.currentGunName]; for (int x = 0; x < items.Count; x++) { Dictionary <string, string> customData = JsonReader.Deserialize <Dictionary <string, string> >(items[x].CustomData); itemIcons.Add(items[x].ItemId, icons[customData["Icon"]]); if (items [x].ItemClass.StartsWith("AmmoPack") && !PlayFabGameBridge.gunTypes.ContainsKey(items[x].ItemClass)) { // add a new gun type string newGunName = items[x].ItemClass; // Gun newGun = JsonReader.Deserialize<Gun>(items[x].CustomData); Gun newGun = new Gun { Frequency = float.Parse(customData["Frequency"]), ConeAngle = float.Parse(customData["ConeAngle"]), DamagePerSecond = float.Parse(customData["DamagePerSecond"]), HitSoundVolume = float.Parse(customData["HitSoundVolume"]), Pitch = float.Parse(customData["Pitch"]) }; PlayFabGameBridge.gunNames.Add(newGunName); PlayFabGameBridge.gunTypes.Add(newGunName, newGun); } if (!PlayFabGameBridge.itemNames.Contains(items[x].ItemClass) && !items [x].ItemClass.StartsWith("GearBundle")) { PlayFabGameBridge.itemNames.Add(items [x].ItemClass); } } Time.timeScale = 1; }
private void ConstructCatalog(GetCatalogItemsResult result) { items = result.Catalog; //adding default skin and missile PlayFabGameBridge.Instance.skins.Add(PlayFabGameBridge.Instance.defaultSkin.skinID, PlayFabGameBridge.Instance.defaultSkin); PlayFabGameBridge.Instance.missiles.Add(PlayFabGameBridge.Instance.defaultMissile.missileID, PlayFabGameBridge.Instance.defaultMissile); //Now, inserting items to dictionaries for (int i = 0; i < items.Count; i++) { Dictionary <string, uint> priceList = items[i].VirtualCurrencyPrices; if (items[i].ItemClass.StartsWith("Skin") && !PlayFabGameBridge.Instance.skins.ContainsKey(items[i].ItemId)) { //Creating a new skin object Skin newSkin = new Skin { skinID = items[i].ItemId, skinName = items[i].DisplayName, price = priceList["GC"] }; PlayFabGameBridge.Instance.skins.Add(items[i].ItemId, newSkin); } if (items[i].ItemClass.StartsWith("Missile") && !PlayFabGameBridge.Instance.missiles.ContainsKey(items[i].ItemId)) { Missile newMissile = new Missile { missileID = items[i].ItemId, missileName = items[i].DisplayName, price = priceList["GC"] }; PlayFabGameBridge.Instance.missiles.Add(items[i].ItemId, newMissile); } } if (!catalogLoaded) { Debug.Log("CatalogLoaded" + catalogLoaded); InitMarketItems(); } catalogLoaded = true; }
private void OnGetCatalogItemsSuccess(GetCatalogItemsResult result) { Debug.Log("Catalog items retrieved successfully"); var item = result.Catalog.Find(x => x.ItemId == "apple"); if (item != null) { var request = new PurchaseItemRequest { ItemId = item.ItemId, CatalogVersion = item.CatalogVersion, VirtualCurrency = "GO", Price = Convert.ToInt32(item.VirtualCurrencyPrices["GO"]) }; PlayFabClientAPI.PurchaseItem(request, OnPurchaseItemSuccess, OnPurchaseItemFailure); } }
private void parseItems(string id, GetCatalogItemsResult result, Action <CatalogModel> successHandler) { IJsonParser jsonParser = new PlayFabClientJsonParser(); CatalogModel catalogModel = new CatalogModel(id); for (int i = 0; i < result.Catalog.Count; i++) { CatalogItem catalogItem = result.Catalog[i]; catalogModel.AddItemWithStackCount( PlayFabItemFactory.GetItemModelFromCatalogItem( catalogItem.ItemId, catalogItem.ItemClass, catalogItem.DisplayName, catalogItem.Description, catalogItem.CustomData, jsonParser)); } successHandler(catalogModel); }
private void ShowAllDeck(GetCatalogItemsResult result) { numberLign = (int)(result.Catalog.Count / numberCardsByLign); Debug.Log(numberLign); for (int i = 0; i < numberLign; i++) { GameObject go = Instantiate(prefabsLign, containsLign.transform); for (int j = 0; j < numberCardsByLign; j++) { if (result.Catalog[j + i * numberCardsByLign].ItemClass == "Cards") { GameObject go2 = Instantiate(prefabsCards, go.transform); go2.transform.GetChild((int)CardsInfo.Text).GetComponent <Text>().text = result.Catalog[j + i * numberCardsByLign].ItemId; for (int k = 0; k < result.Catalog[j + i * numberCardsByLign].Tags.Count; k++) { if (result.Catalog[j + i * numberCardsByLign].Tags[k].Equals("Commun")) { go2.transform.GetChild((int)CardsInfo.Text).GetComponent <Text>().color = Color.black; } if (result.Catalog[j + i * numberCardsByLign].Tags[k].Equals("Rare")) { go2.transform.GetChild((int)CardsInfo.Text).GetComponent <Text>().color = Color.blue; } if (result.Catalog[j + i * numberCardsByLign].Tags[k].Equals("Epic")) { go2.transform.GetChild((int)CardsInfo.Text).GetComponent <Text>().color = Color.magenta; } if (result.Catalog[j + i * numberCardsByLign].Tags[k].Equals("Legendaire")) { go2.transform.GetChild((int)CardsInfo.Text).GetComponent <Text>().color = Color.red; } } } } } canvasDeck.SetActive(true); /*if (result.Catalog[i].ItemClass == "Cards") * Debug.Log(result.Catalog[i].DisplayName);*/ }
//商城道具列表获取成功后调用 void OnGetCatalogItems(GetCatalogItemsResult result) { List <CatalogItem> temp = result.Catalog; for (int i = temp.Count - 1; i >= 0; i--) { if (temp[i].VirtualCurrencyPrices.ContainsKey("FR")) //剔除AK47在商店中的显示(AK47是免费枪支) { temp.RemoveAt(i); } } //计算商城道具个数,计算商城面板页数 shopItems = temp; itemsLength = temp.Count; currentPageNumber = 1; maxPageNumber = (itemsLength - 1) / itemsPerPage + 1; pageMessage.text = currentPageNumber.ToString() + "/" + maxPageNumber.ToString(); ButtonControl(); //翻页按钮控制 ShowItems(); //显示商城道具 shopLoadingWindow.SetActive(false); }
private static void OnGetEventsSuccess(GetCatalogItemsResult result) { // process the catalog items returned; put these into the "events" object // then go and get the rest of the title data Events.Clear(); foreach (var eachItem in result.Catalog) { var newEvent = new UB_EventData { EventName = eachItem.DisplayName, EventDescription = eachItem.Description, StoreToUse = eachItem.ItemClass, BundleId = eachItem.ItemImageUrl, EventKey = eachItem.ItemId }; Events[eachItem.ItemId] = newEvent; Debug.Log("Loaded event: " + eachItem.ItemId); } GetActiveEventData(); }
//商城道具列表获取成功后调用 void OnGetCatalogItems(GetCatalogItemsResult result) { GameInfo.catalogItems = result.Catalog; List <CatalogItem> temp = result.Catalog; for (int i = temp.Count - 1; i >= 0; i--) { if (temp[i].VirtualCurrencyPrices.ContainsKey("JB") && temp[i].VirtualCurrencyPrices.ContainsValue(0)) //剔除普通炮弹在商店中的显示(普通炮弹是免费的) { temp.RemoveAt(i); } } //计算商城道具个数,计算商城面板页数 shopItems = temp; itemsLength = temp.Count; currentPageNumber = 1; maxPageNumber = (itemsLength - 1) / itemsPerPage + 1; pageMessage.text = currentPageNumber.ToString() + "/" + maxPageNumber.ToString(); ButtonControl(); //翻页按钮控制 ShowItems(); //显示商城道具 shopLoadingInfo.gameObject.SetActive(false); }
private void AquiredCatalogItems(GetCatalogItemsResult result) { var list = new List <ICatalogItem>(); foreach (var item in result.Catalog) { if (item.VirtualCurrencyPrices != null && item.VirtualCurrencyPrices.ContainsKey("TC")) { var catalogItem = new PlayFabCatalogItem { item = item }; catalog.Add(item.ItemId, catalogItem); list.Add(catalogItem); } } #if UNITY_ANDROID && !UNITY_EDITOR list.Add(catalog["100tc"]); list.Add(catalog["1000tc"]); #endif catalogView.AquiredCatalogItems(list); // The prices of catalog items might have changed due to user possible user segment changes based on purchase PlayFabClientAPI.GetStoreItems(new GetStoreItemsRequest() { StoreId = cStoreId }, storeResult => { foreach (var item in storeResult.Store) { ((PlayFabCatalogItem)catalog[item.ItemId]).item.VirtualCurrencyPrices = item.VirtualCurrencyPrices; catalogView.RefreshStorePrices(); } }, OnError); }
private static void GetCatalogCallback(GetCatalogItemsResult catalogResult) { PfSharedModelEx.clientCatalog.Clear(); foreach (var catalogItem in catalogResult.Catalog) { PfSharedModelEx.clientCatalog[catalogItem.ItemId] = catalogItem; } PfSharedModelEx.consumableItemIds.Clear(); PfSharedModelEx.containerItemIds.Clear(); foreach (var each in catalogResult.Catalog) { if (each.Container != null) { PfSharedModelEx.containerItemIds.Add(each.ItemId); } else if (each.Consumable != null && each.Consumable.UsageCount > 0) { PfSharedModelEx.consumableItemIds.Add(each.ItemId); } } PfSharedControllerEx.PostEventMessage(PfSharedControllerEx.EventType.OnCatalogLoaded, null, null, PfSharedControllerEx.Api.Client, false); }
private void OnGotCatalog(GetCatalogItemsResult result) { GetCommonItemsCommandArgs localArgs = _args as GetCommonItemsCommandArgs; foreach (CatalogItem catalogItem in result.Catalog) { localArgs .DataStore .SetItem(catalogItem.ItemId, new CommonItem { ID = catalogItem.ItemId, Title = catalogItem.DisplayName, Description = catalogItem.Description, ImageUrl = catalogItem.ItemImageUrl }); } GetCommonItemsCommandResult getCatalogItemsResult = new GetCommonItemsCommandResult { // empty }; Callback?.Invoke(getCatalogItemsResult); }
private void onCatalogueResult(GetCatalogItemsResult result) { Debug.Log("Got items from Catalogue. No of items returned is:" + result.Catalog.Count); int iCount = result.Catalog.Count; catalogueSkus = new List <sku>(); //now add to sku list //NOTE: only supports dollars uint Cash; for (int i = 0; i < iCount; i++) { result.Catalog [i].VirtualCurrencyPrices.TryGetValue("RM", out Cash); catalogueSkus.Add(new sku(false, result.Catalog[i].ItemId, result.Catalog[i].DisplayName, result.Catalog[i].Description, Cash)); } //Check rights GetInventory(); }
private void AddColors(GetCatalogItemsResult res) { ClearChildren(); for (int i = 0; i < res.Catalog.Count; i++) { var item = res.Catalog[i]; if (_uiCustomizationManager.inventoryItemsIds.Contains(item.ItemId)) { continue; } var colorGameObject = colorPrefab; colorGameObject.GetComponent <BuyableColor>().color = GameController.MapIdToColor(item.ItemId); var colorInstance = Instantiate(colorGameObject, transform); var buyableColor = colorInstance.GetComponent <BuyableColor>(); buyableColor.target = target; buyableColor.itemData = new UICustomization.ItemData { sbPrice = item.VirtualCurrencyPrices["SB"], itemId = item.ItemId }; } }
/// <summary> /// Catalog items loaded. /// </summary> /// <param name="result">Catalog.</param> void OnCatalogItemsLoaded(GetCatalogItemsResult result) { catalogItems = result.Catalog; OnCatalogLoadedCallback(catalogItems); }
private static void OnGetOffersCatalogSuccess(GetCatalogItemsResult result) { offersCataogItems = result.Catalog; PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.GetOffersCatalog, MessageDisplayStyle.none); }
private void ShowMyDeck(GetCatalogItemsResult resultCatalog, GetUserInventoryResult resultInventory) { numberLign = (int)(resultCatalog.Catalog.Count / numberCardsByLign); for (int i = 0; i < numberLign; i++) { GameObject go = Instantiate(prefabsLign, containsLign.transform); for (int j = 0; j < numberCardsByLign; j++) { if (resultCatalog.Catalog[j + i * numberCardsByLign].ItemClass == "Cards") { haveThisCards = false; GameObject go2 = Instantiate(prefabsCards, go.transform); go2.transform.GetChild((int)CardsInfo.Text).GetComponent <Text>().text = resultCatalog.Catalog[j + i * numberCardsByLign].ItemId; for (int k = 0; k < resultCatalog.Catalog[j + i * numberCardsByLign].Tags.Count; k++) { if (resultCatalog.Catalog[j + i * numberCardsByLign].Tags[k].Equals("Commun")) { go2.transform.GetChild((int)CardsInfo.Text).GetComponent <Text>().color = Color.black; } if (resultCatalog.Catalog[j + i * numberCardsByLign].Tags[k].Equals("Rare")) { go2.transform.GetChild((int)CardsInfo.Text).GetComponent <Text>().color = Color.blue; } if (resultCatalog.Catalog[j + i * numberCardsByLign].Tags[k].Equals("Epic")) { go2.transform.GetChild((int)CardsInfo.Text).GetComponent <Text>().color = Color.magenta; } if (resultCatalog.Catalog[j + i * numberCardsByLign].Tags[k].Equals("Legendaire")) { go2.transform.GetChild((int)CardsInfo.Text).GetComponent <Text>().color = Color.red; } } for (int k = 0; k < resultInventory.Inventory.Count; k++) { if (resultInventory.Inventory[k].ItemId == resultCatalog.Catalog[j + i * numberCardsByLign].ItemId) { haveThisCards = true; go2.transform.GetChild((int)CardsInfo.NumberCards).GetComponent <Text>().text = resultInventory.Inventory[k].RemainingUses.Value.ToString(); k = resultInventory.Inventory.Count; } } if (!haveThisCards) { Debug.Log("JetBrains rentre ici"); go2.GetComponent <Image>().color = new Color(1, 1, 1, 0.4f); go2.transform.GetChild((int)CardsInfo.NumberCards).GetComponent <Text>().text = "0"; } } } } canvasDeck.SetActive(true); /*if (result.Catalog[i].ItemClass == "Cards") * Debug.Log(result.Catalog[i].DisplayName);*/ }
private static void OnGetCatalogSuccess(GetCatalogItemsResult result) { catalogItems = result.Catalog; PF_PlayerData.GetUserAccountInfo(); }
private void OnSuccess(GetCatalogItemsResult result) { items.Values = result.Catalog.ToArray(); Fsm.Event(successEvent); }
/// <summary> /// Callback called when PlayFab request completes. /// </summary> /// <param name="result">Catalog list.</param> void OnCatalogItemsLoaded(GetCatalogItemsResult result) { catalogItems = result.Catalog; GameplayUI.instance.CreateStoreButtons(this.GetCatalog()); }
//游戏道具数据接收成功后调用 void OnGetCatalogItems(GetCatalogItemsResult result) { //在GameInfo中保存游戏道具信息 GameInfo.catalogItems = result.Catalog; OnMessageResponse(); //PlayFab的数据是否接收完毕 }
private static void GetCatalogItemsCallback_Single(GetCatalogItemsResult result) { callbacks.Add("GetCatalogItemsCallback_Single"); throw new Exception("Non-PlayFab callback error"); }