コード例 #1
0
ファイル: PurchaseMgr.cs プロジェクト: howelllucas/Project
 /// <summary>
 /// 根据id获取商品数据
 /// </summary>
 /// <param name="id"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public bool GetProductInfo(int id, out PurchaseProductData info)
 {
     return(productDataDic2.TryGetValue(id, out info));
 }
コード例 #2
0
ファイル: PurchaseMgr.cs プロジェクト: howelllucas/Project
        private void InitProductDatas()
        {
            productDataDic.Clear();
            productDataDic2.Clear();
            List <string> allProductIdArray = new List <string>();
            Dictionary <string, List <string> > subscriptionGroupDic = new Dictionary <string, List <string> >();
            List <string> nonConsumableIdArray = new List <string>();

            foreach (PurchaseProduct_TableItem item in TableMgr.singleton.PurchaseProductTable.getEnumerator())
            {
                //之后可能分平台赋值
                string productId         = item.productId;
                PurchaseProductData data = new PurchaseProductData();
                data.id        = item.id;
                data.productId = productId;
                data.type      = item.type;
#if !SERVER_CHECK
                int rewardNum = item.rewardNum;
                data.reward_list       = new int[rewardNum];
                data.reward_type_list  = new int[rewardNum];
                data.reward_count_list = new int[rewardNum];
                for (int i = 0; i < rewardNum; i++)
                {
                    data.reward_list[i]       = item.reward_list[i];
                    data.reward_type_list[i]  = item.reward_type_list[i];
                    data.reward_count_list[i] = item.reward_count_list[i];
                }
#endif
                productDataDic[productId] = data;
                productDataDic2[data.id]  = data;
                allProductIdArray.Add(productId);
                switch (item.type)
                {
                case 2:
                {
                    nonConsumableIdArray.Add(productId);
                }
                break;

                case 3:
                {
                    if (!subscriptionGroupDic.ContainsKey(item.subscriptionGroup))
                    {
                        subscriptionGroupDic.Add(item.subscriptionGroup, new List <string>());
                    }
                    subscriptionGroupDic[item.subscriptionGroup].Add(productId);
                }
                break;

                default:
                    break;
                }
            }

            AllProductIdJsonArray = JsonMapper.ToJson(allProductIdArray);

            List <List <string> >       NonConsumableProductStatusRequestArr = new List <List <string> >();
            Dictionary <string, object> RestoreRequestDic = new Dictionary <string, object>();
            if (nonConsumableIdArray.Count > 0)
            {
                NonConsumableProductStatusRequestArr.Add(nonConsumableIdArray);
                RestoreRequestDic["Non-Consumable"] = nonConsumableIdArray;
            }
            if (subscriptionGroupDic.Count > 0)
            {
                List <List <string> > subscriptionGroupItemArr = new List <List <string> >();
                foreach (var item in subscriptionGroupDic.Values)
                {
                    subscriptionGroupItemArr.Add(item);
                    NonConsumableProductStatusRequestArr.Add(item);
                }
                RestoreRequestDic["Auto-Renewable Subscriptions"] = subscriptionGroupItemArr;
            }
            if (NonConsumableProductStatusRequestArr.Count > 0)
            {
                NonConsumableProductStatusRequestJson = JsonMapper.ToJson(NonConsumableProductStatusRequestArr);
            }
            if (RestoreRequestDic.Count > 0)
            {
                RestoreRequestJson = JsonMapper.ToJson(RestoreRequestDic);
            }
        }
コード例 #3
0
ファイル: PurchaseMgr.cs プロジェクト: howelllucas/Project
 /// <summary>
 /// 根据productId获取商品数据
 /// </summary>
 /// <param name="productId"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public bool GetProductInfo(string productId, out PurchaseProductData info)
 {
     return(productDataDic.TryGetValue(productId, out info));
 }