private void InitializeIAP(List <string> productIds) { Debug.Log("Product IDs: " + productIds[0]); QuartersIAP.Instance.Initialize(productIds, delegate(Product[] products) { items = new List <ShopItemData>(); int i = 0; // loop trough the array of products we fetched from the server foreach (Product product in products) { // create a ShopItemData object using the data of each fetched iAP product... ShopItemData d = new ShopItemData(); //d.id = "test" + i; d.id = product.definition.storeSpecificId; d.name = product.metadata.localizedTitle; Debug.Log("Product title: " + product.metadata.localizedTitle); d.cost = product.metadata.localizedPrice; d.localizedCost = product.metadata.localizedPriceString; string quantityAsString = d.id.Replace("Quarters", string.Empty); int quantity; int.TryParse(quantityAsString, out quantity); d.quantity = quantity; // ...and add it to the temp items array items.Add(d); i++; } //refresh the Shop }, delegate(InitializationFailureReason reason) { Debug.LogError(reason.ToString()); }); }
public void Buy(ShopItemData item) { Debug.Log("Selected Quantity" + item.quantity); Debug.Log("Selected " + item.id); foreach (Product p in QuartersIAP.Instance.products) { if (p.definition.storeSpecificId == item.id) { Debug.Log("Buying... " + p.metadata.localizedTitle); // Buy iAP product QuartersIAP.Instance.BuyProduct(p, (Product product, string txId) => { Debug.Log("Purchase complete"); Debug.Log("Quantity: " + item.quantity); //elos.slot.gameInfo.AddBalance(item.quantity); waitModal.Activate(); this.Deactivate(); }, (string error) => { Debug.LogError("Purchase error: " + error); }); break; } } //test //LoadingView.instance.Show(); }
private void LoadProducts(List <String> productsToLoad) { QuartersIAP.Instance.Initialize(productsToLoad, delegate(Product[] products) { List <ShopItemData> items = new List <ShopItemData>(); foreach (Product product in products) { ShopItemData d = new ShopItemData(); d.id = product.definition.storeSpecificId; d.name = product.metadata.localizedTitle; d.hint = product.metadata.localizedDescription; d.cost = product.metadata.localizedPrice; d.localizedCost = product.metadata.localizedPriceString; string quantityAsString = d.id.Replace("Quarters", string.Empty); int quantity; int.TryParse(quantityAsString, out quantity); d.quantity = quantity; items.Add(d); } shop.items = items; shop.Refresh(); }, delegate(InitializationFailureReason reason) { Debug.LogError(reason.ToString()); }); }
public void ApplyData(ShopItemData item, ElosShop shop) { this.item = item; item.actor = this; button.onClick.AddListener(() => { shop.Buy(item); }); }
public void Buy(ShopItemData item) { if (balance >= item.cost) { Talk(talks.bought_EN, talks.bought_JP); elos.slot.gameInfo.AddBalance(-item.cost); Refresh(); } else { assets.audioBeep.Play(); } }
public void Buy(ShopItemData item) { Debug.Log("Selected... " + item.id); foreach (Product p in QuartersIAP.Instance.products) { if (p.definition.storeSpecificId == item.id) { Debug.Log("Buying... " + p.metadata.localizedTitle); QuartersIAP.Instance.BuyProduct(p, (Product product, string txId) => { Debug.Log("Purchase complete"); Debug.Log("Quantity: " + item.quantity); elos.slot.gameInfo.AddBalance(item.quantity); }, (string error) => { Debug.LogError("Purchase error: " + error); }); } } }
public void ApplyData(ShopItemData data, ElosShop shop) { this.data = data; data.actor = this; button.onClick.AddListener(() => { shop.Buy(data); }); }