private void SetCurrency(string shopType) { var shopTemplate = ShopTemplateManager.Instance.GetShopByShopType(shopType); if (shopTemplate == null) { EB.Debug.LogError("LTActivityBodyItem_BossChallenge.SetCurrency: shopTemplate is null"); return; } string[] strs = shopTemplate.shop_balance_type.Split(','); if (_currencyDisplay1 == null) { _currencyDisplay1 = mDMono.transform.GetMonoILRComponent <CurrencyDisplay>("Currency_1"); } if (_currencyDisplay1 != null && strs != null && strs.Length > 0) { var count = BalanceResourceUtil.NumFormat(BalanceResourceUtil.GetDataLookupValue(string.Format("res.{0}.v", strs[0])).ToString()); _currencyDisplay1.SetData(count, BalanceResourceUtil.GetResSpriteName(strs[0])); _currencyDisplay1.SetPopTip(LTShowItemType.TYPE_RES, strs[0]); } if (_currencyDisplay2 == null) { _currencyDisplay2 = mDMono.transform.GetMonoILRComponent <CurrencyDisplay>("Currency_2"); } if (_currencyDisplay2 != null && strs != null && strs.Length > 1) { var count = BalanceResourceUtil.NumFormat(BalanceResourceUtil.GetDataLookupValue(string.Format("res.{0}.v", strs[1])).ToString()); _currencyDisplay2.SetData(count, BalanceResourceUtil.GetResSpriteName(strs[1])); _currencyDisplay2.SetPopTip(LTShowItemType.TYPE_RES, strs[1]); } }
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); }