Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        /**
         * 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);
            }
        }
Exemplo n.º 3
0
        /**
         * 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);
            }
        }
Exemplo n.º 4
0
        // 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();
        }
Exemplo n.º 5
0
        /**
         * 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);
            }
        }
Exemplo n.º 6
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
			}
        }
Exemplo n.º 7
0
        /**
         * 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);
                }
            }
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 10
0
 public override void Connect()
 {
     StoreEvents.Connect();
 }
Exemplo n.º 11
0
 public override void Disconnect()
 {
     StoreEvents.Disconnect();
 }
Exemplo n.º 12
0
 public abstract Task StoreEvent(StoreEvents storeEvent, WorkflowInstance instance);
Exemplo n.º 13
0
 /**
  * @{inheritDoc}
  */
 protected override void postBalanceChangeEvent(VirtualItem item, int balance, int amountAdded)
 {
     StoreEvents.GetInstance().PostGoodBalanceChangedEvent((VirtualGood)item, balance, amountAdded);
 }
Exemplo n.º 14
0
 public override async Task StoreEvent(StoreEvents storeEvent, WorkflowInstance instance)
 {
 }