예제 #1
0
        public void ShowMainStorePopup(Vector3 clickPosition, CocoStoreID storeID)
        {
                        #if ABTEST
            switch (globalRecordModel.CurGPType)
            {
            case GPType.Test_A:
                CocoMainStorePopManager.MiniStoreID = storeID;
                ShowPopup(CocoStoreKey.MainStorePopupPath_TypeA);
                FindObjectOfType <CocoMainStorePopManager>().m_ClickButtonPos = clickPosition;
                break;

            case GPType.Test_B:
                CocoMainStorePopManager.MiniStoreID = storeID;
                ShowPopup(CocoStoreKey.MainStorePopupPath_TypeB);
                FindObjectOfType <CocoMainStorePopManager>().m_ClickButtonPos = clickPosition;
                break;

            default:
                CocoMainStorePopManager.MiniStoreID = storeID;
                ShowPopup(CocoStoreKey.MainStorePopupPath);
                FindObjectOfType <CocoMainStorePopManager>().m_ClickButtonPos = clickPosition;
                break;
            }
                        #else
//			CocoMainStorePopManager.MiniStoreID = storeID;
//			FindObjectOfType<CocoMainStorePopManager>().m_ClickButtonPos = clickPosition;
                        #endif
        }
예제 #2
0
        public void Purchase(CocoStoreID id, Action <BuyItemResult> doneAction = null)
        {
            var itemData = StoreConfigData.GetItemData(id);

            if (itemData == null)
            {
                if (doneAction != null)
                {
                    doneAction(new BuyItemResult(BuyItemResultCode.Error));
                }
                return;
            }

            if (!IsBillingAvailable)
            {
                if (doneAction != null)
                {
                    doneAction(new BuyItemResult(BuyItemResultCode.Error));
                }
//				CocoMainController.ShowNoInternetPopup ();
                return;
            }

            StoreManager.BuyItem(itemData.Key).Done(result => OnPurchaseDone(itemData, result, doneAction));
        }
예제 #3
0
        private bool IsPurchased(CocoStoreID id, bool legacyNoAds)
        {
            if (IsGodModeEnabled)
            {
                return(true);
            }

            // for backward compatibility, will remove in future
 #pragma warning disable 618
            if (IsLegacyFullVersionPurchased)
            {
 #pragma warning restore 618
                return(true);
            }

            // for backward compatibility, will remove in future
 #pragma warning disable 618
            if (legacyNoAds && IsLegacyNoAdsPurchased(id))
            {
 #pragma warning restore 618
                return(true);
            }

            var purchased = IsPurchased(id, new HashSet <CocoStoreID> (), true);
            // Debug.LogError ("-------- " + id + " -------- " + purchased);
            return(purchased);
        }
예제 #4
0
        private CocoStoreItem GetStoreItemById(CocoStoreID pProductId)
        {
            if (CocoStoreData.Instance.allProductItemsDic.ContainsKey(pProductId))
            {
                return(CocoStoreData.Instance.allProductItemsDic [pProductId]);
            }

            return(null);
        }
예제 #5
0
        public string GetProductIapString(CocoStoreID pProductId)
        {
            if (CocoStoreData.Instance.allProductItemsDic.ContainsKey(pProductId))
            {
                return(CocoStoreData.Instance.allProductItemsDic [pProductId].iosIapString);
            }

            return(string.Empty);
        }
예제 #6
0
        //通过GameProductId 判断是否已经购买, 优先判断最大包
        public bool IsPurchasedByProductId(CocoStoreID pId)
        {
            CocoStoreItem pStoreItem = GetStoreItemById(pId);

            if (pStoreItem == null)
            {
                Debug.LogError("There is no CocoStoreItem for the product. Please check !(该商品不存在,检查设置): " + pId);
                return(false);
            }

            return(inventoryStateModel.HasItem(pStoreItem.iosIapString) || billingService.IsPurchased(iapConfigModel.GetIAPId(pStoreItem.iosIapString)));
        }
예제 #7
0
        //购买一个商品。(会设置关联数据)
        public void PurchasedProduct(CocoStoreID pId)
        {
            CocoStoreItem pStoreItem = GetStoreItemById(pId);

            if (pStoreItem == null)
            {
                Debug.LogError("There is no CocoStoreItem for the product. Please check !(该商品不存在,检查设置): " + pId);
                return;
            }

            inventoryStateModel.SetQuantity(pStoreItem.iosIapString, 1);

            //Unlock all related store iap items
            //解锁相关联的商品
            for (int i = 0; i < pStoreItem.relatedStoreItems.Count; i++)
            {
                CocoStoreItem pRelatedItem = GetStoreItemById(pStoreItem.relatedStoreItems [i]);

                if (pStoreItem == null)
                {
                    Debug.LogError("There is no CocoStoreItem for the product. Please check !(该商品不存在,检查设置): " + pStoreItem.relatedStoreItems [i]);
                    continue;
                }

                inventoryStateModel.SetQuantity(pRelatedItem.iosIapString, 1);
            }

            foreach (CocoStoreItem pItem in CocoStoreData.Instance.allProductItems)
            {
                if (pItem.productId == pId)
                {
                    continue;
                }

                bool pAllRelatedItemsUnlocked = pItem.relatedStoreItems.Count > 0 ? true : false;
                for (int i = 0; i < pItem.relatedStoreItems.Count; i++)
                {
                    if (!IsPurchasedByProductId(pItem.relatedStoreItems [i]))
                    {
                        pAllRelatedItemsUnlocked = false;
                        break;
                    }
                }

                if (pAllRelatedItemsUnlocked)
                {
                    inventoryStateModel.SetQuantity(pItem.iosIapString, 1);
                }
            }
        }
예제 #8
0
        protected void AddItem(CocoStoreID id, string key)
        {
            if (_itemDatas.ContainsKey(id))
            {
                _itemDatas [id].Key = key;
                return;
            }

            var itemData = new CocoStoreItemData {
                Id  = id,
                Key = key
            };

            _itemDatas.Add(id, itemData);
        }
예제 #9
0
        private bool IsPurchased(CocoStoreID id, HashSet <CocoStoreID> excludedParentIds, bool checkSlots)
        {
            var itemData = StoreConfigData.GetItemData(id);

            if (itemData == null)
            {
                return(false);
            }

            // check if self is purchased
            if (itemData.IsPurchased)
            {
                return(true);
            }

            excludedParentIds.Add(itemData.Id);

            // check if any parent is purchased
            foreach (var parentId in itemData.ParentIds)
            {
                if (excludedParentIds.Contains(parentId))
                {
                    continue;
                }

                if (IsPurchased(parentId, excludedParentIds, false))
                {
                    return(true);
                }
            }

            // check slots
            if (!checkSlots || itemData.SlotIds.Count <= 0)
            {
                return(false);
            }

            // check if all slots are purchased
            foreach (var slotId in itemData.SlotIds)
            {
                if (!IsPurchased(slotId, excludedParentIds, true))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #10
0
        public string GetPriceString(CocoStoreID id, bool useISOCurrencySymbol = false)
        {
            var itemData = StoreConfigData.GetItemData(id);

            if (itemData == null)
            {
                return(string.Empty);
            }

            if (!useISOCurrencySymbol)
            {
                return(BillingService.GetLocalizedPriceString(itemData.Key));
            }

            var symbol = BillingService.GetISOCurrencySymbol(itemData.Key);

            return(string.Format("{0} {1}", symbol, BillingService.GetPriceInLocalCurrency(itemData.Key)));
        }
예제 #11
0
 public string GetStoreKey(CocoStoreID id)
 {
     return(_itemDatas.ContainsKey(id) ? _itemDatas [id].Key : string.Empty);
 }
예제 #12
0
 public CocoStoreItemData GetItemData(CocoStoreID itemId)
 {
     return(_itemDatas.ContainsKey(itemId) ? _itemDatas [itemId] : null);
 }
예제 #13
0
 public void Buy(CocoStoreID id, Action <BuyItemResult> doneAction = null)
 {
     Purchase(id, doneAction);
 }
예제 #14
0
 private bool IsLegacyNoAdsPurchased(CocoStoreID id)
 {
     return(id == CocoStoreID.NoAds && IsNoAds);
 }
예제 #15
0
 public bool IsPurchased(CocoStoreID id)
 {
     return(IsPurchased(id, true));
 }