Ejemplo n.º 1
0
        /// <summary>
        /// Handles the <c>onMarketRefund</c> event, which is fired when a Market refund has been issued.
        /// </summary>
        /// <param name="message">Message that contains information about the market refund that has occurred.</param>
        public void onMarketRefund(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketRefund:" + message);

            var eventJSON = new JSONObject(message);

            PurchasableVirtualItem pvi = (PurchasableVirtualItem)StoreInfo.GetItemByItemId(eventJSON["itemId"].str);

            StoreEvents.OnMarketRefund(pvi);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the <c>onMarketItemsRefreshFailed</c> event, which is fired when items associated with market
        /// refresh process has failed.
        /// </summary>
        /// <param name="message">Message that contains information about the <c>market refresh</c> process that
        /// has failed.</param>
        public void onMarketItemsRefreshFailed(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFailed");

            var eventJSON = new JSONObject(message);

            string errorMessage = eventJSON["errorMessage"].str;

            StoreEvents.OnMarketItemsRefreshFailed(errorMessage);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the <c>onRestoreTransactionsFinished</c> event, which is fired when the restore transactions
        /// process has finished.
        /// </summary>
        /// <param name="message">Message that contains information about the <c>restoreTransactions</c> process that
        /// has finished.</param>
        public void onRestoreTransactionsFinished(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onRestoreTransactionsFinished:" + message);

            var eventJSON = new JSONObject(message);

            bool success = eventJSON["success"].b;

            StoreEvents.OnRestoreTransactionsFinished(success);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles an <c>onCurrencyBalanceChanged</c> event, which is fired when the balance of a specific
        /// <c>VirtualCurrency</c> has changed.
        /// </summary>
        /// <param name="message">Message that contains information about the currency whose balance has
        /// changed.</param>
        public void onCurrencyBalanceChanged(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onCurrencyBalanceChanged:" + message);

            string[] vars = Regex.Split(message, "#SOOM#");

            VirtualCurrency vc          = (VirtualCurrency)StoreInfo.GetItemByItemId(vars[0]);
            int             balance     = int.Parse(vars[1]);
            int             amountAdded = int.Parse(vars[2]);

            StoreEvents.OnCurrencyBalanceChanged(vc, balance, amountAdded);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes StoreEvents before the game starts.
 /// </summary>
 void Awake()
 {
     if (Instance == null)               // making sure we only initialize one instance.
     {
         Instance = this;
         GameObject.DontDestroyOnLoad(this.gameObject);
         Initialize();
     }
     else                                                // Destroying unused instances.
     {
         GameObject.Destroy(this.gameObject);
     }
 }
Ejemplo n.º 6
0
        public void onUnexpectedErrorInStore(string message, bool alsoPush)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onUnexpectedErrorInStore");

            StoreEvents.OnUnexpectedErrorInStore(message);

            if (alsoPush)
            {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                sep.PushEventSoomlaStoreInitialized();
#endif
            }
        }
Ejemplo n.º 7
0
        public static void onMarketPurchase(MarketPurchaseEvent _Event)
        {
            SoomlaWpStore.domain.PurchasableVirtualItem purchasableVirtualItem = _Event.GetPurchasableVirtualItem();
            String payload = _Event.GetPayload();
            String token   = _Event.GetToken();

            Debug.Log("SOOMLA/UNITY onMarketPurchase:" + purchasableVirtualItem.getItemId() + " " + payload + " " + token);

            PurchasableVirtualItem pvi = (PurchasableVirtualItem)StoreInfo.GetItemByItemId(purchasableVirtualItem.getItemId());
            //TODO Implement extra on WP8 onMarketPurchase
            Dictionary <string, string> extra = new Dictionary <string, string>();

            StoreEvents.OnMarketPurchase(pvi, payload, extra);
        }
Ejemplo n.º 8
0
        public static void onItemPurchaseStarted(ItemPurchaseStartedEvent _Event, bool alsoPush)
        {
            SoomlaWpStore.domain.PurchasableVirtualItem purchasableVirtualItem = _Event.GetPurchasableVirtualItem();
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onItemPurchaseStarted:" + purchasableVirtualItem.getItemId());

            PurchasableVirtualItem pvi = (PurchasableVirtualItem)StoreInfo.GetItemByItemId(purchasableVirtualItem.getItemId());

            StoreEvents.OnItemPurchaseStarted(pvi);

            if (alsoPush)
            {
                sep.PushEventOnItemPurchaseStarted(_Event);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes the SOOMLA SDK.
        /// </summary>
        /// <param name="storeAssets">Your game's economy.</param>
        /// <exception cref="ExitGUIException">Thrown if soomlaSecret is missing or has not been changed.</exception>
        public static bool Initialize(IStoreAssets storeAssets)
        {
            StoreEvents.Initialize();
            if (string.IsNullOrEmpty(CoreSettings.SoomlaSecret))
            {
                SoomlaUtils.LogError(TAG, "MISSING SoomlaSecret !!! Stopping here !!");
                throw new ExitGUIException();
            }

            if (CoreSettings.SoomlaSecret == CoreSettings.ONLY_ONCE_DEFAULT)
            {
                SoomlaUtils.LogError(TAG, "You have to change SoomlaSecret !!! Stopping here !!");
                throw new ExitGUIException();
            }

            var storeEvents = GameObject.FindObjectOfType <StoreEvents> ();

            if (storeEvents == null)
            {
                SoomlaUtils.LogDebug(TAG, "StoreEvents Component not found in scene. We're continuing from here but you won't get many events.");
            }

            if (Initialized)
            {
                StoreEvents.Instance.onUnexpectedStoreError("{\"errorCode\": 0}", true);
                SoomlaUtils.LogError(TAG, "SoomlaStore is already initialized. You can't initialize it twice!");
                return(false);
            }

            SoomlaUtils.LogDebug(TAG, "SoomlaStore Initializing ...");

            StoreInfo.SetStoreAssets(storeAssets);

            instance._loadBillingService();

                        #if UNITY_IOS
            // On iOS we only refresh market items
            instance._refreshMarketItemsDetails();
#elif UNITY_ANDROID
            // On Android we refresh market items and restore transactions
            instance._refreshInventory();
#elif UNITY_WP8
            instance._refreshInventory();
#endif

            Initialized = true;
            StoreEvents.Instance.onSoomlaStoreInitialized("", true);

            return(true);
        }
Ejemplo n.º 10
0
        public static void onGoodUnequipped(GoodUnEquippedEvent _Event, bool alsoPush)
        {
            SoomlaWpStore.domain.virtualGoods.EquippableVG good = _Event.GetEquippableVG();
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onVirtualGoodUnEquipped:" + good.getItemId());

            EquippableVG vg = (EquippableVG)StoreInfo.GetItemByItemId(good.getItemId());

            StoreInventory.RefreshOnGoodUnEquipped(vg);
            StoreEvents.OnGoodUnEquipped(vg);

            if (alsoPush)
            {
                sep.PushEventOnGoodUnequipped(_Event);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Handles the <c>onMarketPurchaseDeferred</c> event, which is fired when a Market purchase was deferred
        /// until it can be finished by the family delegate.
        /// Note that this is an iOS only event for when users have set up "Ask to Buy" and the purchaser is
        /// selected as a family member that needs "family organizer" permission to buy.
        /// <see href="https://support.apple.com/en-us/HT201089">Apple's explanation of "Ask to Buy"</see>
        /// </summary>
        /// <param name="message">Message that contains information about the market purchase that is being
        /// deferred.</param>
        public void onMarketPurchaseDeferred(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketPurchaseDeferred: " + message);

            var eventJSON = new JSONObject(message);

            PurchasableVirtualItem pvi = (PurchasableVirtualItem)StoreInfo.GetItemByItemId(eventJSON["itemId"].str);
            string payload             = "";

            if (eventJSON.HasField("payload"))
            {
                payload = eventJSON["payload"].str;
            }
            StoreEvents.OnMarketPurchaseDeferred(pvi, payload);
        }
Ejemplo n.º 12
0
        public void onUnexpectedStoreError(string message, bool alsoPush)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY OnUnexpectedStoreError");

            JSONObject eventJSON = new JSONObject(message);

            StoreEvents.OnUnexpectedStoreError((int)eventJSON ["errorCode"].n);

            if (alsoPush)
            {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                sep.PushEventSoomlaStoreInitialized();
#endif
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Handles an <c>onGoodUpgrade</c> event, which is fired when a specific <c>UpgradeVG</c> has
        /// been upgraded/downgraded.
        /// </summary>
        /// <param name="message">Message that contains information about the good that has been
        /// upgraded/downgraded.</param>
        public void onGoodUpgrade(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodUpgrade:" + message);

            string[] vars = Regex.Split(message, "#SOOM#");

            VirtualGood vg  = (VirtualGood)StoreInfo.GetItemByItemId(vars[0]);
            UpgradeVG   vgu = null;

            if (vars.Length > 1)
            {
                vgu = (UpgradeVG)StoreInfo.GetItemByItemId(vars[1]);
            }
            StoreEvents.OnGoodUpgrade(vg, vgu);
        }
Ejemplo n.º 14
0
        public void onSoomlaStoreInitialized(string message, bool alsoPush)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onSoomlaStoreInitialized");

            StoreInventory.RefreshLocalInventory();

            StoreEvents.OnSoomlaStoreInitialized();

            if (alsoPush)
            {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                sep.PushEventSoomlaStoreInitialized();
#endif
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Handles an <c>onItemPurchased</c> event, which is fired when a specific
        /// <c>PurchasableVirtualItem</c> has been purchased.
        /// </summary>
        /// <param name="message">Message that contains information about the good that has been purchased.</param>
        public void onItemPurchased(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onItemPurchased:" + message);

            string[] vars = Regex.Split(message, "#SOOM#");

            PurchasableVirtualItem pvi = (PurchasableVirtualItem)StoreInfo.GetItemByItemId(vars[0]);
            string payload             = "";

            if (vars.Length > 1)
            {
                payload = vars[1];
            }

            StoreEvents.OnItemPurchased(pvi, payload);
        }
Ejemplo n.º 16
0
        public void onItemPurchaseStarted(string message, bool alsoPush)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onItemPurchaseStarted:" + message);

            var eventJSON = new JSONObject(message);

            PurchasableVirtualItem pvi = (PurchasableVirtualItem)StoreInfo.GetItemByItemId(eventJSON["itemId"].str);

            StoreEvents.OnItemPurchaseStarted(pvi);

            if (alsoPush)
            {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                sep.PushEventOnItemPurchaseStarted(pvi);
#endif
            }
        }
Ejemplo n.º 17
0
        public static void onGoodBalanceChanged(GoodBalanceChangedEvent _Event, bool alsoPush)
        {
            SoomlaWpStore.domain.virtualGoods.VirtualGood good = _Event.GetGood();
            int balance     = _Event.GetBalance();
            int amountAdded = _Event.GetAmountAdded();

            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodBalanceChanged:" + good.getItemId() + " " + balance.ToString() + " " + amountAdded.ToString());

            VirtualGood vg = (VirtualGood)StoreInfo.GetItemByItemId(good.getItemId());

            StoreInventory.RefreshOnGoodBalanceChanged(vg, balance, amountAdded);
            StoreEvents.OnGoodBalanceChanged(vg, balance, amountAdded);

            if (alsoPush)
            {
                sep.PushEventOnGoodBalanceChanged(_Event);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Handles the <c>onMarketPurchaseVerifyStarted</c> event, which is fired after a puchase has started
        /// and the native level is requesting for the client to verify the purchase with the server.
        /// </summary>
        /// <param name="message">Contains info for the verification.</param>
        public void onMarketPurchaseVerifyStarted(string message)
        {
            var eventJSON = new JSONObject(message);

            int    transactionId = (int)eventJSON["transactionId"].n;
            string signature     = "";
            string receipt       = "";

            if (eventJSON.HasField("receipt"))
            {
                receipt = eventJSON["receipt"].str;
            }
            if (eventJSON.HasField("signature"))
            {
                signature = eventJSON["signature"].str;
            }

            StoreEvents.OnMarketPurchaseVerifyStarted(transactionId, receipt, signature);
        }
Ejemplo n.º 19
0
        public void onGoodUnequipped(string message, bool alsoPush)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onVirtualGoodUnEquipped:" + message);

            var eventJSON = new JSONObject(message);

            EquippableVG vg = (EquippableVG)StoreInfo.GetItemByItemId(eventJSON["itemId"].str);

            StoreInventory.RefreshOnGoodUnEquipped(vg);

            StoreEvents.OnGoodUnEquipped(vg);

            if (alsoPush)
            {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                sep.PushEventOnGoodUnequipped(vg);
#endif
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Handles the <c>onMarketItemsRefreshFinished</c> event, which is fired when items associated with market are
        /// refreshed (prices, titles ...).
        /// </summary>
        /// <param name="message">Message that contains information about the process that is occurring.</param>
        public void onMarketItemsRefreshFinished(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + message);

            var eventJSON = new JSONObject(message);

            List <VirtualItem> virtualItems = new List <VirtualItem>();
            List <MarketItem>  marketItems  = new List <MarketItem>();

            foreach (var micJSON in eventJSON.list)
            {
                string productId          = micJSON[StoreJSONConsts.MARKETITEM_PRODUCT_ID].str;
                string marketPrice        = micJSON[StoreJSONConsts.MARKETITEM_MARKETPRICE].str;
                string marketTitle        = micJSON[StoreJSONConsts.MARKETITEM_MARKETTITLE].str;
                string marketDescription  = micJSON[StoreJSONConsts.MARKETITEM_MARKETDESC].str;
                string marketCurrencyCode = micJSON[StoreJSONConsts.MARKETITEM_MARKETCURRENCYCODE].str;
                long   marketPriceMicros  = System.Convert.ToInt64(micJSON[StoreJSONConsts.MARKETITEM_MARKETPRICEMICROS].n);
                try {
                    PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(productId);
                    MarketItem             mi  = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem;
                    mi.MarketPriceAndCurrency = marketPrice;
                    mi.MarketTitle            = marketTitle;
                    mi.MarketDescription      = marketDescription;
                    mi.MarketCurrencyCode     = marketCurrencyCode;
                    mi.MarketPriceMicros      = marketPriceMicros;

                    marketItems.Add(mi);
                    virtualItems.Add(pvi);
                } catch (VirtualItemNotFoundException ex) {
                    SoomlaUtils.LogDebug(TAG, ex.Message);
                }
            }

            if (virtualItems.Count > 0)
            {
                // no need to save to DB since it's already saved in native
                // before this event is received
                StoreInfo.Save(virtualItems, false);
            }

            StoreEvents.OnMarketItemsRefreshFinished(marketItems);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Handles the <c>onMarketPurchase</c> event, which is fired when a Market purchase has occurred.
        /// </summary>
        /// <param name="message">Message that contains information about the market purchase.</param>
        public void onMarketPurchase(string message)
        {
            Debug.Log("SOOMLA/UNITY onMarketPurchase:" + message);

            string[] vars = Regex.Split(message, "#SOOM#");

            PurchasableVirtualItem pvi = (PurchasableVirtualItem)StoreInfo.GetItemByItemId(vars[0]);
            string payload             = "";
            string purchaseToken       = "";

            if (vars.Length > 1)
            {
                payload = vars[1];
            }
            if (vars.Length > 2)
            {
                purchaseToken = vars[2];
            }

            StoreEvents.OnMarketPurchase(pvi, purchaseToken, payload);
        }
Ejemplo n.º 22
0
        public void onGoodBalanceChanged(string message, bool alsoPush)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodBalanceChanged:" + message);

            JSONObject eventJSON = new JSONObject(message);

            VirtualGood vg          = (VirtualGood)StoreInfo.GetItemByItemId(eventJSON["itemId"].str);
            int         balance     = (int)eventJSON["balance"].n;
            int         amountAdded = (int)eventJSON["amountAdded"].n;

            StoreInventory.RefreshOnGoodBalanceChanged(vg, balance, amountAdded);

            StoreEvents.OnGoodBalanceChanged(vg, balance, amountAdded);

            if (alsoPush)
            {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                sep.PushEventOnGoodBalanceChanged(vg, balance, amountAdded);
#endif
            }
        }
Ejemplo n.º 23
0
        public static void onGoodUpgrade(GoodUpgradeEvent _Event, bool alsoPush)
        {
            SoomlaWpStore.domain.virtualGoods.VirtualGood good      = _Event.GetGood();
            SoomlaWpStore.domain.virtualGoods.UpgradeVG   upgradeVG = _Event.GetUpgradeVG();
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGoodUpgrade:" + good.getItemId() + " " + upgradeVG.getItemId());

            VirtualGood vg  = (VirtualGood)StoreInfo.GetItemByItemId(good.getItemId());
            UpgradeVG   vgu = null;

            if (upgradeVG != null)
            {
                vgu = (UpgradeVG)StoreInfo.GetItemByItemId(upgradeVG.getItemId());
            }
            StoreInventory.RefreshOnGoodUpgrade(vg, vgu);
            StoreEvents.OnGoodUpgrade(vg, vgu);

            if (alsoPush)
            {
                sep.PushEventOnGoodUpgrade(_Event);
            }
        }
Ejemplo n.º 24
0
        public static void onCurrencyBalanceChanged(CurrencyBalanceChangedEvent _Event, bool alsoPush)
        {
            SoomlaWpStore.domain.virtualCurrencies.VirtualCurrency currency = _Event.GetCurrency();
            int balance     = _Event.GetBalance();
            int amountAdded = _Event.GetAmountAdded();

            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onCurrencyBalanceChanged" + currency.getItemId() + " " + balance.ToString() + " " + amountAdded.ToString());

            VirtualCurrency vc = (VirtualCurrency)StoreInfo.GetItemByItemId(currency.getItemId());

            StoreEvents.OnCurrencyBalanceChanged(vc, balance, amountAdded);

            StoreInventory.RefreshOnCurrencyBalanceChanged(vc, balance, amountAdded);

            //Why this line was added twice ??
            //StoreEvents.OnCurrencyBalanceChanged(vc, balance, amountAdded);

            if (alsoPush)
            {
                sep.PushEventOnCurrencyBalanceChanged(_Event);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Handles the <c>onMarketItemsRefreshFinished</c> event, which is fired when items associated with market are
        /// refreshed (prices, titles ...).
        /// </summary>
        /// <param name="message">Message that contains information about the process that is occurring.</param>
        public void onMarketItemsRefreshFinished(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + message);

            string[]          marketItemsChanges = Regex.Split(message, "#SOOM#");
            List <MarketItem> marketItems        = new List <MarketItem>();

            foreach (string mic in marketItemsChanges)
            {
                if (string.IsNullOrEmpty(mic.Trim()))
                {
                    continue;
                }

                JSONObject micJSON            = new JSONObject(mic);
                string     productId          = micJSON[JSONConsts.MARKETITEM_PRODUCT_ID].str;
                string     marketPrice        = micJSON[JSONConsts.MARKETITEM_MARKETPRICE].str;
                string     marketTitle        = micJSON[JSONConsts.MARKETITEM_MARKETTITLE].str;
                string     marketDescription  = micJSON[JSONConsts.MARKETITEM_MARKETDESC].str;
                string     marketCurrencyCode = micJSON[JSONConsts.MARKETITEM_MARKETCURRENCYCODE].str;
                long       marketPriceMicros  = System.Convert.ToInt64(micJSON[JSONConsts.MARKETITEM_MARKETPRICEMICROS].n);
                try {
                    PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(productId);
                    MarketItem             mi  = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem;
                    mi.MarketPriceAndCurrency = marketPrice;
                    mi.MarketTitle            = marketTitle;
                    mi.MarketDescription      = marketDescription;
                    mi.MarketCurrencyCode     = marketCurrencyCode;
                    mi.MarketPriceMicros      = marketPriceMicros;
                    pvi.save();

                    marketItems.Add(mi);
                } catch (VirtualItemNotFoundException ex) {
                    SoomlaUtils.LogDebug(TAG, ex.Message);
                }
            }

            StoreEvents.OnMarketItemsRefreshFinished(marketItems);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Buys the purchasable virtual item.
        /// Implementation in subclasses will be according to specific type of purchase.
        /// </summary>
        /// <param name="payload">a string you want to be assigned to the purchase. This string
        /// is saved in a static variable and will be given bacl to you when the
        ///  purchase is completed.</param>
        /// <exception cref="Soomla.Store.InsufficientFundsException">throws InsufficientFundsException</exception>
        public override void Buy(string payload)
        {
            SoomlaUtils.LogDebug("SOOMLA PurchaseWithVirtualItem", "Trying to buy a " + AssociatedItem.Name + " with "
                                 + Amount + " pieces of " + TargetItemId);

            VirtualItem item = getTargetVirtualItem();

            if (item == null)
            {
                return;
            }


            JSONObject eventJSON = new JSONObject();

            eventJSON.AddField("itemId", AssociatedItem.ItemId);
            StoreEvents.Instance.onItemPurchaseStarted(eventJSON.print(), true);

            if (!checkTargetBalance(item))
            {
                StoreEvents.OnNotEnoughTargetItem(StoreInfo.VirtualItems["seed_ID"]);
                return;
//				throw new InsufficientFundsException (TargetItemId);
            }

            item.Take(Amount);

            AssociatedItem.Give(1);

            // We have to make sure the ItemPurchased event will be fired AFTER the balance/currency-changed events.
            StoreEvents.Instance.RunLater(() => {
                eventJSON = new JSONObject();
                eventJSON.AddField("itemId", AssociatedItem.ItemId);
                eventJSON.AddField("payload", payload);
                StoreEvents.Instance.onItemPurchased(eventJSON.print(), true);
            });
        }
Ejemplo n.º 27
0
        /// <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
            }
        }
Ejemplo n.º 28
0
        public void onIabServiceStopped(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onIabServiceStopped");

            StoreEvents.OnIabServiceStopped();
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Handles the <c>onRestoreTransactionsStarted</c> event, which is fired when the restore transactions
        /// process has started.
        /// </summary>
        /// <param name="message">Message that contains information about the <c>restoreTransactions</c> process that
        /// has started.</param>
        public void onRestoreTransactionsStarted(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onRestoreTransactionsStarted");

            StoreEvents.OnRestoreTransactionsStarted();
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Initializes game state before the game starts.
 /// </summary>
 void Awake()
 {
     if(instance == null){ 	// making sure we only initialize one instance.
         instance = this;
         GameObject.DontDestroyOnLoad(this.gameObject);
         Initialize();
     } else {				// Destroying unused instances.
         GameObject.Destroy(this.gameObject);
     }
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Handles the <c>onMarketItemsRefreshStarted</c> event, which is fired when items associated with market
        /// refresh process has started.
        /// </summary>
        /// <param name="message">Message that contains information about the <c>market refresh</c> process that
        /// has started.</param>
        public void onMarketItemsRefreshStarted(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshStarted");

            StoreEvents.OnMarketItemsRefreshStarted();
        }