Exemplo n.º 1
0
        public void OnGetInfoForProducts(string value)
        {
            Dictionary <string, InAppPurchaseTypeVO> allIAPTypesByProductID = this.GetAllIAPTypesByProductID();
            IDictionary <string, object>             dictionary             = new JsonParser(value).Parse() as Dictionary <string, object>;

            if (dictionary != null && dictionary.ContainsKey("products"))
            {
                List <object> list = dictionary.get_Item("products") as List <object>;
                if (list != null)
                {
                    int count = list.Count;
                    for (int i = 0; i < count; i++)
                    {
                        InAppPurchaseProductInfo inAppPurchaseProductInfo = InAppPurchaseProductInfo.Parse(list[i]);
                        Service.Get <StaRTSLogger>().Debug("IAP Product: " + inAppPurchaseProductInfo.ToString());
                        if (allIAPTypesByProductID.ContainsKey(inAppPurchaseProductInfo.AppStoreId))
                        {
                            InAppPurchaseTypeVO inAppPurchaseTypeVO = allIAPTypesByProductID[inAppPurchaseProductInfo.AppStoreId];
                            if (!inAppPurchaseTypeVO.IsPromo)
                            {
                                if (!this.products.ContainsKey(inAppPurchaseProductInfo.AppStoreId))
                                {
                                    this.products.Add(inAppPurchaseProductInfo.AppStoreId, inAppPurchaseProductInfo);
                                }
                                if (!this.validIAPTypes.ContainsKey(inAppPurchaseTypeVO.ProductId))
                                {
                                    this.validIAPTypes.Add(inAppPurchaseTypeVO.ProductId, inAppPurchaseTypeVO);
                                }
                            }
                        }
                        else
                        {
                            Service.Get <StaRTSLogger>().Debug("IAP Item no longer supported: " + inAppPurchaseProductInfo.AppStoreId);
                        }
                    }
                    Service.Get <StaRTSLogger>().Debug("Number of valid products: " + count);
                }
            }
            this.ValidateIAPItems(false);
            if (this.products.Count == this.expectedIAPCount)
            {
                if (this.numStoreRetryAttempts < 1)
                {
                    int num = this.numStoreRetryAttempts - 1;
                    Service.Get <BILoggingController>().TrackGameAction("iap", "get_products_init_success", num.ToString(), "");
                }
                else
                {
                    Service.Get <BILoggingController>().TrackGameAction("iap", "get_products_store_success", this.numStoreRetryAttempts.ToString(), "");
                }
                this.AreProductIdsReady = true;
                Service.Get <EventManager>().SendEvent(EventId.IAPProductIDsReady, null);
            }
        }
Exemplo n.º 2
0
        private void ParseProductsFromJson(string value)
        {
            Dictionary <string, InAppPurchaseTypeVO> allIAPTypesByProductID = this.GetAllIAPTypesByProductID();
            IDictionary <string, object>             dictionary             = new JsonParser(value).Parse() as Dictionary <string, object>;

            if (dictionary != null && dictionary.ContainsKey("products"))
            {
                List <object> list = dictionary["products"] as List <object>;
                if (list != null)
                {
                    int count = list.Count;
                    for (int i = 0; i < count; i++)
                    {
                        InAppPurchaseProductInfo inAppPurchaseProductInfo = InAppPurchaseProductInfo.Parse(list[i]);
                        Service.Logger.Debug("IAP Product: " + inAppPurchaseProductInfo.ToString());
                        if (allIAPTypesByProductID.ContainsKey(inAppPurchaseProductInfo.AppStoreId))
                        {
                            InAppPurchaseTypeVO inAppPurchaseTypeVO = allIAPTypesByProductID[inAppPurchaseProductInfo.AppStoreId];
                            if (!inAppPurchaseTypeVO.IsPromo)
                            {
                                if (!this.products.ContainsKey(inAppPurchaseProductInfo.AppStoreId))
                                {
                                    this.products.Add(inAppPurchaseProductInfo.AppStoreId, inAppPurchaseProductInfo);
                                }
                                if (!this.validIAPTypes.ContainsKey(inAppPurchaseTypeVO.ProductId))
                                {
                                    this.validIAPTypes.Add(inAppPurchaseTypeVO.ProductId, inAppPurchaseTypeVO);
                                }
                            }
                        }
                        else
                        {
                            Service.Logger.Debug("IAP Item no longer supported: " + inAppPurchaseProductInfo.AppStoreId);
                        }
                    }
                    Service.Logger.Debug("Number of valid products: " + count);
                }
            }
        }
 public unsafe static long $Invoke6(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(InAppPurchaseProductInfo.Parse(GCHandledObjects.GCHandleToObject(*args))));
 }