// Update is called once per frame void Update() { if (Input.touchCount > 0) { if (Input.GetTouch(0).phase == TouchPhase.Began) { tempbox = checkTouch(Input.GetTouch(0).position); } } if (tempbox == shopbutton) { tempbox = null; shopbutton.SetActive(false); shopoption.SetActive(true); removeads.GetComponent <Animator>().SetBool("off", false); removeads.GetComponent <Collider2D>().enabled = true; start.SetActive(false); balance = StoreInventory.GetItemBalance(ShapeValeStore.NO_ADS_LIFETIME_PRODUCT_ID); } if (tempbox == close) { tempbox = null; shopbutton.SetActive(true); shopoption.SetActive(false); start.SetActive(true); removeads.GetComponent <Collider2D>().enabled = false; removeads.GetComponent <Animator>().SetBool("off", true); balance = StoreInventory.GetItemBalance(ShapeValeStore.NO_ADS_LIFETIME_PRODUCT_ID); } if (tempbox == removeads) { Debug.Log("test"); tempbox = null; VirtualGood no_ads = ShapeValeStore.NO_ADS_LTVG; try{ StoreInventory.BuyItem(no_ads.ItemId); }catch (Exception e) { Debug.Log("error occured: " + e); } } if (balance > 0) { if ((removeads.activeSelf) && (!done)) { removeads.GetComponent <Animator>().SetBool("purchased", true); removeads.GetComponent <Collider2D>().enabled = false; done = true; } } else { } }
///Devolve Todas os Produtos Vendidos do Jogo, para ser alimentado no Soomla public VirtualGood[] AllVirtualGoods() { VirtualGood[] goods = new VirtualGood[powliticos.Length - 1]; for (int i = 0; i < powliticos.Length - 1; i++) { goods[i] = powliticos[i].storeValues.PowliticoVirtualProduct(); } return(goods); }
/** * Retrieves the itemId of the current upgrade of the virtual good with the given * <code>goodItemId</code>. * * @param goodItemId id of the virtual good whose upgrade id we want to know * @return upgrade id if exists, or empty string otherwise * @throws VirtualItemNotFoundException */ public static String getGoodCurrentUpgrade(String goodItemId) { VirtualGood good = (VirtualGood)StoreInfo.getVirtualItem(goodItemId); UpgradeVG upgradeVG = StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(good); if (upgradeVG == null) { return(""); } return(upgradeVG.getItemId()); }
public void onGoodUpgrade(string message) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodUpgrade:" + message); string[] vars = Regex.Split(message, "#SOOM#"); VirtualGood vg = (VirtualGood)StoreInfo.GetItemByItemId(vars[0]); UpgradeVG vgu = (UpgradeVG)StoreInfo.GetItemByItemId(vars[1]); Events.OnGoodUpgrade(vg, vgu); }
/** * Removes all upgrades from the virtual good with the given <code>goodItemId</code>. * * @param goodItemId id of the virtual good we want to remove all upgrades from * @throws VirtualItemNotFoundException */ public static void removeUpgrades(String goodItemId) { List <UpgradeVG> upgrades = StoreInfo.getGoodUpgrades(goodItemId); foreach (UpgradeVG upgrade in upgrades) { StorageManager.getVirtualGoodsStorage().remove(upgrade, 1, true); } VirtualGood good = (VirtualGood)StoreInfo.getVirtualItem(goodItemId); StorageManager.getVirtualGoodsStorage().removeUpgrades(good); }
public void BuyVirtualGood(VirtualGood virtualGood) { Debug.Log("SOOMLA/UNITY wants to buy: " + virtualGood.Name); try { StoreInventory.BuyItem(virtualGood.ItemId); } catch (Exception e) { Debug.LogError("SOOMLA/UNITY " + e.Message); } }
public void onGoodBalanceChanged(string message) { StoreUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodBalanceChanged:" + message); string[] vars = Regex.Split(message, "#SOOM#"); VirtualGood vg = (VirtualGood)StoreInfo.GetItemByItemId(vars[0]); int balance = int.Parse(vars[1]); int amountAdded = int.Parse(vars[2]); Events.OnGoodBalanceChanged(vg, balance, amountAdded); }
/* * public void Initialize() * { * StoreEvents.OnSoomlaStoreInitialized += onSoomlaStoreInitialized; * }*/ /* * public void InitializeSoomlaStore() * { * SoomlaStore.Initialize(ourIAPAssets); * }*/ //----------------------------------------------- // FUNCTIONS //----------------------------------------------- public void onSoomlaStoreInitialized() { // this is the plugin ListVirtualGoods = StoreInfo.Goods; Debug.Log("Soomla Store initialized with: " + VirtualGoods.Count + " items"); VirtualGood[] vgs = new VirtualGood[VirtualGoods.Count]; VirtualGoods.Values.CopyTo(vgs, 0); for (int i = 0; i < VirtualGoods.Count; ++i) { Debug.Log("Name: " + vgs[i].Name + " --- Item ID: " + vgs[i].ID); } }
/** * Adds the given virtual good to <code>StoreInfo</code>'s <code>mGoods</code>, * <code>mVirtualItems</code>, and if the good has purchase type <code>PurchaseWithMarket</code> * then it is also added to <code>mPurchasableItems</code>. * * @param g virtual good to be added */ private static void addVG(VirtualGood g) { mGoods.Add(g); mVirtualItems.Add(g.getItemId(), g); PurchaseType purchaseType = g.GetPurchaseType(); if (purchaseType is PurchaseWithMarket) { mPurchasableItems.Add(((PurchaseWithMarket)purchaseType) .getMarketItem().getProductId(), g); } }
/** * Removes any upgrade associated with the given VirtualGood. * * @param good the virtual good to remove the upgrade from * @param notify if true post event to bus */ public void removeUpgrades(VirtualGood good, bool notify) { SoomlaUtils.LogDebug(mTag, "Removing upgrade information from virtual good: " + good.getName()); String itemId = good.getItemId(); String key = keyGoodUpgrade(itemId); KeyValueStorage.DeleteKeyValue(key); if (notify) { BusProvider.Instance.Post(new GoodUpgradeEvent(good, null)); } }
public void OnGoodPurchased(VirtualGood virtualGood, int balance, int amountAdded) { string pviItemId = virtualGood.ItemId; if (pviItemId.Contains("_CoinsPack")) { return; } if (pviItemId == "charsoo_doubler") { var playerController = Singleton.Instance.PlayerController; PlayerInfo playerInfo = playerController.PlayerInfo; playerInfo.HasDubler = true; Singleton.Instance.PlayerController.ChangePlayerInfo(playerInfo); } }
/* * Obtiene todos los Goods registrados en el MAPA y los devuelve en forma de Array. * Este método es necesario ya que el IAPManager necesita una array de VirtualGood para hacer hacer comprobaciones * de items con la AppStore o la PlayStore. */ public VirtualGood[] GetGoods() { /* * int total = 0; * total += Map_LifetimeVirtualGoods.Count; * total += Map_SingleUseVirtualGoods.Count; * total += Map_EquippableVirtualGoods.Count; * * VirtualGood[] goods = new VirtualGood[total]; * Map_LifetimeVirtualGoods.Values.CopyTo(goods, 0); * Map_SingleUseVirtualGoods.Values.CopyTo(goods, Map_LifetimeVirtualGoods.Count); * Map_EquippableVirtualGoods.Values.CopyTo(goods, Map_SingleUseVirtualGoods.Count);*/ VirtualGood[] goods = new VirtualGood[Map_VirtualGoods.Count]; Map_VirtualGoods.Values.CopyTo(goods, 0); return(goods); }
void bought(VirtualGood arg1, UpgradeVG arg2) { if (upgrades) { int upgdLevel = StoreInventory.GetGoodUpgradeLevel(id); if (upgdLevel == 5) { el_desc.text = LanguageManager.current.getText(LanguageNode.FullUpgraded); buy.gameObject.SetActive(false); el_upgradeMeter.fillAmount = 1f; } else { el_upgradeMeter.fillAmount = upgdLevel / 5f; el_price.text = AnimineStoreAssets.UPGRADE_PRICE [upgdLevel] + ""; } } }
public void Buy(string id) { switch (id) { case "socko_450_coins": VirtualGood item = goods[0]; try { StoreInventory.BuyItem(item.ItemId); } catch (Exception e) { } break; case "socko_1000_coins": VirtualGood coins1000 = goods[1]; try { StoreInventory.BuyItem(coins1000.ItemId); } catch (Exception e) { } break; case "socko_2750_coins": VirtualGood coins2750 = goods[2]; try { StoreInventory.BuyItem(coins2750.ItemId); } catch (Exception e) { } break; case "socko_6000_coins": VirtualGood coins6000 = goods[3]; try { StoreInventory.BuyItem(coins6000.ItemId); } catch (Exception e) { } break; case "socko_10000_coins": VirtualGood coins10000 = goods[4]; try { StoreInventory.BuyItem(coins10000.ItemId); } catch (Exception e) { } break; case "socko_remove_ads": VirtualGood remove_ads = goods[5]; try { StoreInventory.BuyItem(remove_ads.ItemId); } catch (Exception e) { } break; } }
/** * Retrieves the upgrade level of the virtual good with the given <code>goodItemId</code>. * * For Example: * Let's say there's a strength attribute to one of the characters in your game and you provide * your users with the ability to upgrade that strength on a scale of 1-3. * This is what you've created: * 1. <code>SingleUseVG</code> for "strength" * 2. <code>UpgradeVG</code> for strength 'level 1'. * 3. <code>UpgradeVG</code> for strength 'level 2'. * 4. <code>UpgradeVG</code> for strength 'level 3'. * In the example, this function will retrieve the upgrade level for "strength" (1, 2, or 3). * * @param goodItemId id of the virtual good whose upgrade level we want to know * @return upgrade level of the good with the given id * @throws VirtualItemNotFoundException */ public static int getGoodUpgradeLevel(String goodItemId) { VirtualGood good = (VirtualGood)StoreInfo.getVirtualItem(goodItemId); UpgradeVG upgradeVG = StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(good); if (upgradeVG == null) { return(0); //no upgrade } UpgradeVG first = StoreInfo.getGoodFirstUpgrade(goodItemId); int level = 1; while (!first.Equal(upgradeVG)) { first = (UpgradeVG)StoreInfo.getVirtualItem(first.getNextItemId()); level++; } return(level); }
/** * Assigns a specific upgrade to the given virtual good. * * @param good the VirtualGood to upgrade * @param upgradeVG the upgrade to assign * @param notify if true post event to bus */ public void assignCurrentUpgrade(VirtualGood good, UpgradeVG upgradeVG, bool notify) { if (getCurrentUpgrade(good) != null && getCurrentUpgrade(good).getItemId() == upgradeVG.getItemId()) { return; } SoomlaUtils.LogDebug(mTag, "Assigning upgrade " + upgradeVG.getName() + " to virtual good: " + good.getName()); String itemId = good.getItemId(); String key = keyGoodUpgrade(itemId); String upItemId = upgradeVG.getItemId(); KeyValueStorage.SetValue(key, upItemId); if (notify) { BusProvider.Instance.Post(new GoodUpgradeEvent(good, upgradeVG)); } }
// Function to parse a virtual good into an Item object Item ParseToItem(VirtualGood item, ItemType type) { // Create a new item object Item new_item = new Item(); // retrieve the id, name and description new_item.itemId = item.ItemId; new_item.name = item.Name; new_item.description = item.Description; // place the sprite of the item new_item.icon = (Texture2D)Resources.Load(item.ItemId); // retrieve quantity owned new_item.balance = StoreInventory.GetItemBalance(item.ItemId); // retrieve the currency type and price if (item.PurchaseType is PurchaseWithVirtualItem && ((PurchaseWithVirtualItem)item.PurchaseType).TargetItemId == CrapTrapAssets.NORMAL_TOILET_PAPER_ID) { new_item.currency = CurrencyType.NTP; new_item.price = ((PurchaseWithVirtualItem)item.PurchaseType).Amount; } else if (item.PurchaseType is PurchaseWithVirtualItem && ((PurchaseWithVirtualItem)item.PurchaseType).TargetItemId == CrapTrapAssets.GOLDEN_TOILET_PAPER_ID) { new_item.currency = CurrencyType.GTP; new_item.price = ((PurchaseWithVirtualItem)item.PurchaseType).Amount; } else if (item.PurchaseType is PurchaseWithMarket) { new_item.currency = CurrencyType.Dollar; new_item.dollarPrice = ((PurchaseWithMarket)item.PurchaseType).MarketItem.Price; } // set the type new_item.type = type; return(new_item); }
/** * Upgrades the virtual good with the given <code>goodItemId</code> by doing the following: * 1. Checks if the good is currently upgraded or if this is the first time being upgraded. * 2. If the good is currently upgraded, upgrades to the next upgrade in the series, or in * other words, <code>buy()</code>s the next upgrade. In case there are no more upgrades * available(meaning the current upgrade is the last available), the function returns. * 3. If the good has never been upgraded before, the function upgrades it to the first * available upgrade, or in other words, <code>buy()</code>s the first upgrade in the series. * * @param goodItemId the id of the virtual good to be upgraded * @throws VirtualItemNotFoundException * @throws InsufficientFundsException */ public static void upgradeVirtualGood(String goodItemId) { VirtualGood good = (VirtualGood)StoreInfo.getVirtualItem(goodItemId); UpgradeVG upgradeVG = StorageManager.getVirtualGoodsStorage().getCurrentUpgrade(good); if (upgradeVG != null) { String nextItemId = upgradeVG.getNextItemId(); if (String.IsNullOrEmpty(nextItemId)) { return; } UpgradeVG vgu = (UpgradeVG)StoreInfo.getVirtualItem(nextItemId); vgu.buy(""); } else { UpgradeVG first = StoreInfo.getGoodFirstUpgrade(goodItemId); if (first != null) { first.buy(""); } } }
/// <summary> /// Handles a good upgraded event. /// </summary> /// <param name="good">Virtual good that is being upgraded.</param> /// <param name="currentUpgrade">The current upgrade that the given virtual /// good is being upgraded to.</param> public void onGoodUpgrade(VirtualGood good, UpgradeVG currentUpgrade) { }
public void onGoodUpgrade(VirtualGood good, UpgradeVG currentUpgrade) { //AndyUtils.LogDebug(TAG, "The current uprade of " + good.ItemId + " is " + currentUpgrade.ItemId); }
public void onGoodBalanceChanged( VirtualGood good, int balance, int amountAdded) { //AndyUtils.LogDebug(TAG, "New balance of VirtualGood " + good.Name + " is " + balance); //LocalStoreInfo.UpdateBalances(); }
public void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded) { ExampleLocalStoreInfo.UpdateBalances(); }
private void GoodUpgrade(VirtualGood arg1, UpgradeVG arg2) { Debug.Log(arg1); }
public void onVirtualGoodPurchased(VirtualGood good) { }
/** * Replaces an old virtual item with a new one by doing the following: * 1. Determines the type of the given virtual item. * 2. Looks for the given virtual item in the relevant list, according to its type. * 3. If found, removes it. * 4. Adds the given virtual item. * * @param virtualItem the virtual item that replaces the old one if exists. */ public static void replaceVirtualItem(VirtualItem virtualItem) { mVirtualItems.Add(virtualItem.getItemId(), virtualItem); if (virtualItem is VirtualCurrency) { for (int i = 0; i < mCurrencies.Count; i++) { if (mCurrencies[i].getItemId() == virtualItem.getItemId()) { mCurrencies.RemoveAt(i); break; } } mCurrencies.Add((VirtualCurrency)virtualItem); } if (virtualItem is VirtualCurrencyPack) { VirtualCurrencyPack vcp = (VirtualCurrencyPack)virtualItem; PurchaseType purchaseType = vcp.GetPurchaseType(); if (purchaseType is PurchaseWithMarket) { mPurchasableItems.Add(((PurchaseWithMarket)purchaseType).getMarketItem() .getProductId(), vcp); } for (int i = 0; i < mCurrencyPacks.Count; i++) { if (mCurrencyPacks[i].getItemId() == vcp.getItemId()) { mCurrencyPacks.RemoveAt(i); break; } } mCurrencyPacks.Add(vcp); } if (virtualItem is VirtualGood) { VirtualGood vg = (VirtualGood)virtualItem; if (vg is UpgradeVG) { List <UpgradeVG> upgrades = mGoodsUpgrades[((UpgradeVG)vg).getGoodItemId()]; if (upgrades == null) { upgrades = new List <UpgradeVG>(); mGoodsUpgrades.Add(((UpgradeVG)vg).getGoodItemId(), upgrades); } upgrades.Add((UpgradeVG)vg); } PurchaseType purchaseType = vg.GetPurchaseType(); if (purchaseType is PurchaseWithMarket) { mPurchasableItems.Add(((PurchaseWithMarket)purchaseType).getMarketItem() .getProductId(), vg); } for (int i = 0; i < mGoods.Count; i++) { if (mGoods[i].getItemId() == vg.getItemId()) { mGoods.RemoveAt(i); break; } } mGoods.Add(vg); } /* * if (virtualItem is NonConsumableItem) { * NonConsumableItem non = (NonConsumableItem) virtualItem; * * PurchaseType purchaseType = non.GetPurchaseType(); * if (purchaseType is PurchaseWithMarket) { * mPurchasableItems.Add(((PurchaseWithMarket) purchaseType).getMarketItem() * .getProductId(), non); * } * * for(int i=0; i<mNonConsumables.Count; i++) { * if (mNonConsumables[i].getItemId() == non.getItemId()) { * mNonConsumables.RemoveAt(i); * break; * } * } * mNonConsumables.Add(non); * }*/ }
public void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded) { //AndyUtils.LogDebug(TAG, "New balance of VirtualGood " + good.Name + " is " + balance); //LocalStoreInfo.UpdateBalances(); }
public void onVirtualGoodUnequipped(VirtualGood good) { }
// updating counters, when balance of goods changed void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded) { ItemCounter.RefreshAll(); }
/// <summary> /// Handles a good balance changed event. /// </summary> /// <param name="good">Virtual good whose balance has changed.</param> /// <param name="balance">Balance.</param> /// <param name="amountAdded">Amount added.</param> public void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded) { }
/// <summary> /// Adds to the character goods list. /// </summary> /// <param name="vg">The character virtual good to add.</param> public void AddToCharacterGoodsList(VirtualGood vg) { // Add to character goods list as well as to virtual goods list m_charCategoryGoodsList.Add(vg.ItemId); m_virtualGoodsList.Add(vg); }
// Update is called once per frame void Update() { if ((balance > 0) && (adz != null)) { ads.destroystarting(); } if ((balance > 0) && (adz != null) && (ads.destroyending())) { Destroy(adz); adz = null; } if (Input.touchCount > 0) { if (Input.GetTouch(0).phase == TouchPhase.Began) { tempbox = checkTouch(Input.GetTouch(0).position); } } if ((defeat.activeSelf) && (!defeated)) { balance = StoreInventory.GetItemBalance(ShapeValeStore.NO_ADS_LIFETIME_PRODUCT_ID); if (balance > 0) { defeated = true; } else { defeated = true; removeads.SetActive(true); } } if ((!defeat.activeSelf) && (defeated)) { defeated = false; removeads.SetActive(false); } if ((victory.activeSelf) && (!victorious)) { balance = StoreInventory.GetItemBalance(ShapeValeStore.NO_ADS_LIFETIME_PRODUCT_ID); if (balance > 0) { victorious = true; } else { victorious = true; removeads.SetActive(true); } } if ((!victory.activeSelf) && (victorious)) { victorious = false; removeads.SetActive(false); } if ((pause.activeSelf) && (!paused)) { balance = StoreInventory.GetItemBalance(ShapeValeStore.NO_ADS_LIFETIME_PRODUCT_ID); if (balance > 0) { paused = true; } else { paused = true; removeads.SetActive(true); } } if ((!pause.activeSelf) && (paused)) { paused = false; removeads.SetActive(false); } if (tempbox == removeads) { tempbox = null; VirtualGood no_ads = ShapeValeStore.NO_ADS_LTVG; try{ StoreInventory.BuyItem(no_ads.ItemId); }catch (Exception e) { Debug.Log("error occured: " + e); } } }
/// <summary> /// Opens this <c>Gate</c> if the good-balance changed event causes the <c>Gate</c>'s /// criteria to be met. /// </summary> /// <param name="good">Virtual good whose balance has changed.</param> /// <param name="balance">New balance.</param> /// <param name="amountAdded">Amount added.</param> public void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded) { checkItemIdBalance(good.ItemId, balance); }
private void UpdateGoodBalance(VirtualGood good, int balance, int amountAdded) { TextBlock balanceText = (TextBlock)MainStackPanel.FindName(good.getItemId() + "balance"); balanceText.Text = "balance: " + balance.ToString(); }
// // Various event handling methods // public void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded) { SoomlaUtils.LogDebug("TAG", good.ID + " now has a balance of " + balance); }