void Awake() { if (instance == null) // making sure we only initialize one instance. { instance = this; GameObject.DontDestroyOnLoad(this.gameObject); } else // Destroying unused instances. { GameObject.Destroy(this.gameObject); } }
/** * Buys the virtual item with real money (from the Market). * * @throws com.soomla.store.exceptions.InsufficientFundsException */ public override void buy(String payload) { SoomlaUtils.LogDebug(TAG, "Starting in-app purchase for productId: " + mMarketItem.getProductId()); StoreEvents.GetInstance().PostItemPurchaseStartedEvent(getAssociatedItem()); try { SoomlaStore.GetInstance().buyWithMarket(mMarketItem, payload); } catch (Exception e) { SoomlaUtils.LogError(TAG, "Error when purchasing item " + e.Message); } }
/** * 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) { StoreEvents.GetInstance().PostGoodUpgradeEvent(good, null); } }
// Constructeur public MainPage() { InitializeComponent(); StoreEvents.GetInstance().OnCurrencyBalanceChangedEvent += new CurrencyBalanceChangedEventHandler(UpdateCurrencyBalance); StoreEvents.GetInstance().OnGoodBalanceChangedEvent += new GoodBalanceChangedEventHandler(UpdateGoodBalance); StoreEvents.GetInstance().OnGoodEquippedEvent += new GoodEquippedEventHandler(UpdateGoodEquip); StoreEvents.GetInstance().OnGoodUnEquippedEvent += new GoodUnEquippedEventHandler(UpdateGoodUnequip); SoomlaConfig.logDebug = true; Soomla.initialize("this_is_my_secret"); SoomlaStore.GetInstance().initialize(new StoreAssets(), true); /// Update the currencies balance on the GUI UpdateCurrencyBalance(null, 0, 0); buildShop(); }
/** * 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) { StoreEvents.GetInstance().PostGoodUpgradeEvent(good, upgradeVG); } }
/// <summary> /// Initializes the different native event handlers in Android / iOS /// </summary> public static void Initialize() { if (Instance == null) { CoreEvents.Initialize(); Instance = GetSynchronousCodeGeneratedInstance<StoreEvents>(); SoomlaUtils.LogDebug (TAG, "Initializing StoreEvents ..."); #if UNITY_ANDROID && !UNITY_EDITOR AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniEventHandler = new AndroidJavaClass("com.soomla.unity.StoreEventHandler")) { jniEventHandler.CallStatic("initialize"); } AndroidJNI.PopLocalFrame(IntPtr.Zero); sep = new StoreEventPusherAndroid(); #elif UNITY_IOS && !UNITY_EDITOR eventDispatcher_Init(); sep = new StoreEventPusherIOS(); #elif UNITY_WP8 && !UNITY_EDITOR BusProvider.Instance.Register(StoreEvents.Instance); sep = new StoreEventPusherWP(); #endif } }
/** * Helper function for <code>equip</code> and <code>unequip</code> functions. */ private void equipPriv(EquippableVG good, bool equip, bool notify) { SoomlaUtils.LogDebug(mTag, (!equip ? "unequipping " : "equipping ") + good.getName() + "."); String itemId = good.getItemId(); String key = keyGoodEquipped(itemId); if (equip) { KeyValueStorage.SetValue(key, ""); if (notify) { StoreEvents.GetInstance().PostGoodEquippedEvent(good); } } else { KeyValueStorage.DeleteKeyValue(key); if (notify) { StoreEvents.GetInstance().PostGoodUnEquippedEvent(good); } } }
/// <summary> Loads Windows Store IAP informations. </summary> public async void LoadListingInfo() { StoreEvents.GetInstance().PostMarketItemsRefreshStartedEvent(); try { if (StoreConfig.STORE_TEST_MODE) { listingInfosMock = await MockStore.CurrentApp.LoadListingInformationAsync(); marketProductInfos.Clear(); if (listingInfosMock.ProductListings.Count > 0) { foreach (KeyValuePair <string, MockStore.ProductListing> pair in listingInfosMock.ProductListings) { MarketProductInfos marketProduct = new MarketProductInfos(); marketProduct.Name = pair.Value.Name; marketProduct.Description = pair.Value.Description; marketProduct.FormattedPrice = pair.Value.FormattedPrice; marketProduct.ImageUri = pair.Value.ImageUri; marketProduct.Keywords = pair.Value.Keywords; marketProduct.ProductId = pair.Value.ProductId; switch (pair.Value.ProductType) { case Windows.ApplicationModel.Store.ProductType.Consumable: marketProduct.ProductType = MarketProductInfos.MarketProductType.CONSUMABLE; break; case Windows.ApplicationModel.Store.ProductType.Durable: marketProduct.ProductType = MarketProductInfos.MarketProductType.DURABLE; break; case Windows.ApplicationModel.Store.ProductType.Unknown: marketProduct.ProductType = MarketProductInfos.MarketProductType.UNKNOWN; break; } marketProduct.Tag = pair.Value.Tag; marketProductInfos.Add(pair.Key, marketProduct); } } } else { listingInfos = await Store.CurrentApp.LoadListingInformationAsync(); IReadOnlyDictionary <string, Store.ProductListing> productListing; productListing = listingInfos.ProductListings; marketProductInfos.Clear(); if (productListing.Count > 0) { foreach (KeyValuePair <string, Store.ProductListing> pair in listingInfos.ProductListings) { MarketProductInfos marketProduct = new MarketProductInfos(); marketProduct.Name = pair.Value.Name; marketProduct.Description = pair.Value.Description; marketProduct.FormattedPrice = pair.Value.FormattedPrice; marketProduct.ImageUri = pair.Value.ImageUri; marketProduct.Keywords = pair.Value.Keywords; marketProduct.ProductId = pair.Value.ProductId; switch (pair.Value.ProductType) { case Windows.ApplicationModel.Store.ProductType.Consumable: marketProduct.ProductType = MarketProductInfos.MarketProductType.CONSUMABLE; break; case Windows.ApplicationModel.Store.ProductType.Durable: marketProduct.ProductType = MarketProductInfos.MarketProductType.DURABLE; break; case Windows.ApplicationModel.Store.ProductType.Unknown: marketProduct.ProductType = MarketProductInfos.MarketProductType.UNKNOWN; break; } marketProduct.Tag = pair.Value.Tag; marketProductInfos.Add(pair.Key, marketProduct); } } } } catch (Exception e) { SoomlaUtils.LogDebug(TAG, e.Message); } OnListingLoadedCB(marketProductInfos); }
void Awake() { if(instance == null){ // making sure we only initialize one instance. instance = this; GameObject.DontDestroyOnLoad(this.gameObject); } else { // Destroying unused instances. GameObject.Destroy(this.gameObject); } }
public override void Connect() { StoreEvents.Connect(); }
public override void Disconnect() { StoreEvents.Disconnect(); }
public abstract Task StoreEvent(StoreEvents storeEvent, WorkflowInstance instance);
/** * @{inheritDoc} */ protected override void postBalanceChangeEvent(VirtualItem item, int balance, int amountAdded) { StoreEvents.GetInstance().PostGoodBalanceChangedEvent((VirtualGood)item, balance, amountAdded); }
public override async Task StoreEvent(StoreEvents storeEvent, WorkflowInstance instance) { }