private void RefreshPurchaseLimit() { if (_purchaseLimitLabel == null) { _purchaseLimitLabel = mDMono.transform.GetComponent <UILabel>("PurchaseLimit", false); } if (_purchaseLimitLabel != null && Data != null) { int maxBuyNum = 0; BossChallengeTemplate info = null; switch (Data.store_type) { case "bosschallenge1": info = ShopTemplateManager.Instance.GetBossChallenge1Template(Data.sid); break; case "bosschallenge2": info = ShopTemplateManager.Instance.GetBossChallenge2Template(Data.sid); break; case "bosschallenge3": info = ShopTemplateManager.Instance.GetBossChallenge3Template(Data.sid); break; } if (info != null) { maxBuyNum = info.buy_num; } _purchaseLimitLabel.text = EB.Localizer.GetString("ID_PURCHASE_LIMIT_ONLY") + string.Format("{0}/{1}", maxBuyNum - Data.remainBuyNum, maxBuyNum); _purchaseLimitLabel.gameObject.SetActive(Data.remainBuyNum > 0); } }
public static int GetCanBuyCount(string eventType) { var shopTemplate = ShopTemplateManager.Instance.GetShopByShopType(eventType); if (shopTemplate == null) { return(0); } string[] strs = shopTemplate.shop_balance_type.Split(','); if (strs == null) { return(0); } var list = new List <string>(strs); int canBuyCount = 0; ArrayList itemList; if (DataLookupsCache.Instance.SearchDataByID(string.Format("userShops.{0}.itemList", eventType), out itemList) && itemList != null) { for (int i = 0; i < itemList.Count; i++) { int id = EB.Dot.Integer("id", itemList[i], 0); int num = EB.Dot.Integer("num", itemList[i], 0); BossChallengeTemplate tpl = null; switch (_eventType) { case "bosschallenge1": tpl = ShopTemplateManager.Instance.GetBossChallenge1Template(id); break; case "bosschallenge2": tpl = ShopTemplateManager.Instance.GetBossChallenge2Template(id); break; case "bosschallenge3": tpl = ShopTemplateManager.Instance.GetBossChallenge3Template(id); break; } if (num > 0 && tpl != null && list.Contains(tpl.balance_name)) { var count = BalanceResourceUtil.GetDataLookupValue(string.Format("res.{0}.v", tpl.balance_name)); if (count >= tpl.balance_num) { canBuyCount += 1; } } } } else { Dictionary <int, BossChallengeTemplate> dict = null; switch (_eventType) { case "bosschallenge1": dict = ShopTemplateManager.Instance.GetAllBossChallenge1Template(); break; case "bosschallenge2": dict = ShopTemplateManager.Instance.GetAllBossChallenge2Template(); break; case "bosschallenge3": dict = ShopTemplateManager.Instance.GetAllBossChallenge3Template(); break; } if (dict != null) { foreach (var kvp in dict) { if (list.Contains(kvp.Value.balance_name)) { var count = BalanceResourceUtil.GetDataLookupValue(string.Format("res.{0}.v", kvp.Value.balance_name)); if (count >= kvp.Value.balance_num) { canBuyCount += 1; } } } } } return(canBuyCount); }