//TODO solve the confusion with what VC balances are checked player VS character // close also needs to fire a callback to the calling area of the code public void InitiateStore(GetStoreItemsResult storeResult) { if (_inventory.Count == 0) { foreach (var child in gameObject.GetComponentsInChildren <StoreDisplayItem>()) { _inventory.Add(child); } } activeStoreId = storeResult.StoreId; Dictionary <string, object> eventData = new Dictionary <string, object> { { "store_name", activeStoreId } }; PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_StoreVisit, eventData); //reset currenciesInUse.Clear(); currentPage = 1; pageCount = Mathf.CeilToInt((float)storeResult.Store.Count / (float)itemsPerPage); pageDisplay.text = string.Format("{0} / {1}", currentPage, pageCount); foreach (var item in _inventory) { item.ClearButton(); } itemsToDisplay = storeResult.Store; StoreName.text = storeResult.MarketingData != null && !string.IsNullOrEmpty(storeResult.MarketingData.DisplayName) ? storeResult.MarketingData.DisplayName : storeResult.StoreId + " (ID)"; StoreDescription.text = storeResult.MarketingData != null && !string.IsNullOrEmpty(storeResult.MarketingData.Description) ? storeResult.MarketingData.Description : ""; nextPage.interactable = pageCount > 1; prevPage.interactable = false; for (var z = 0; z < itemsToDisplay.Count && z < itemsPerPage; z++) { Sprite icon; GetItemIcon(itemsToDisplay[z], out icon); _inventory[z].Init(this); _inventory[z].SetButton(icon, activeStoreId, itemsToDisplay[z]); // keep track of what currencies are being used in the store. var vcPrices = itemsToDisplay[z].VirtualCurrencyPrices.Keys; foreach (var eachVc in vcPrices) { var index = currenciesInUse.FindIndex((key) => { return(string.Equals(key, eachVc)); }); // make sure not already in the list. if (index < 0) { currenciesInUse.Add(eachVc); } } } //hide selected Currencies.Init(); gameObject.SetActive(true); }
void GetStoreItemsSuccess(GetStoreItemsResult result) { storeItems = result.Store; if (!store.gameObject.activeInHierarchy) { ToStore(); } if (!storeScrollList.Temp) { storeScrollList.RefreshDisplay(); } }
private void resultCallback(GetStoreItemsResult obj) { for (int i = 0; i < obj.Store.Count; i++) { Debug.Log(TestUtilities.PrintStoreItem(obj.Store[i])); } if (automaticButFirstItem) { if (obj.Store.Count > 0) { BuyStoreItem(obj.Store[0]); } } }
private static void OnGetActiveEventsSuccess(GetStoreItemsResult result) { // now process the results of the store to determine what events are active ActiveEventKeys.Clear(); foreach (var eachItem in result.Store) { ActiveEventKeys.Add(eachItem.ItemId); } Debug.Log("Active events: " + String.Join(", ", ActiveEventKeys.ToArray())); //Use pre-cached Assets or Load from CDN decided by title data. GameController.Instance.cdnController.useCDN = UseCDN != 0; BuildCDNRequests(); PF_Bridge.RaiseCallbackSuccess("Events Loaded", PlayFabAPIMethods.GetEvents, MessageDisplayStyle.none); }
private void OnGetStoreItemsSuccess(GetStoreItemsResult result) { Debug.Log("Get Store Items"); result.Store.ForEach(Print); StoreItem item = result.Store.Find(storeItem => storeItem.ItemId == "pear"); if (item != null) { var request = new PurchaseItemRequest { CatalogVersion = "main", StoreId = "fruits", ItemId = item.ItemId, VirtualCurrency = "GO", Price = Convert.ToInt32(item.VirtualCurrencyPrices["GO"]) }; PlayFabClientAPI.PurchaseItem(request, OnPurchaseItemSuccess, OnPurchaseItemFailure); } }
private void OnGotCatalog(GetStoreItemsResult result) { GetStoreItemsCommandArgs localArgs = _args as GetStoreItemsCommandArgs; foreach (PlayFab.ClientModels.StoreItem storeItem in result.Store) { localArgs .DataStore .SetItem(storeItem.ItemId, new StoreItem { ID = storeItem.ItemId, VirtualCurrencyPrices = storeItem.VirtualCurrencyPrices }); } GetStoreItemsCommandResult getStoreItemsResult = new GetStoreItemsCommandResult { // empty }; Callback?.Invoke(getStoreItemsResult); }
/// <summary> /// Raises the retrieve store items success event. /// </summary> /// <param name="result">Result.</param> private static void OnRetrieveStoreItemsSuccess(GetStoreItemsResult result) { mostRecentStore = result.Store; PF_Bridge.RaiseCallbackSuccess("Store Retrieved", PlayFabAPIMethods.GetStoreItems, MessageDisplayStyle.none); }