private void InitUI() { InitSkill(); List <StoreItemData> datas = new List <StoreItemData>(); for (int i = 0; i < itemList.Count; i++) { int sid = EB.Dot.Integer("id", itemList[i], 0); string id = EB.Dot.String("redeems.data", itemList[i], ""); string type = EB.Dot.String("redeems.type", itemList[i], ""); int buy_num = EB.Dot.Integer("redeems.quantity", itemList[i], 0); int have = GetScrollNum(id); string cost_id = EB.Dot.String("spends.data", itemList[i], ""); int cost_num = EB.Dot.Integer("spends.quantity", itemList[i], 0); int num = EB.Dot.Integer("num", itemList[i], 0); float mdiscount = EB.Dot.Single("discount", itemList[i], 1); bool sell_out = num > 0 || num == -1 ? false : true; int weight = 1; int buyId = EB.Dot.Integer("id", itemList[i], 0); if (!string.IsNullOrEmpty(id)) { StoreItemData itemdata = new StoreItemData(sid, id, type, buy_num, have, cost_id, cost_num, sell_out, weight, buyId, StoreType, mdiscount); datas.Add(itemdata); } } int left = datas.Count % Columns; if (left > 0) { left = Columns - left; for (int i = 0; i < left; i++) { StoreItemData itemdata = new StoreItemData(0, "", "", 1, 1, "", 1, true, 1, i, StoreType, 1); datas.Add(itemdata); } } Scroll.SetItemDatas(datas); }
/// <summary> /// 获取数据刷新 /// </summary> public virtual void RefreshData() { string title = EB.Localizer.GetString(m_StoreName); IDictionary data = null; if (DataLookupsCache.Instance.SearchDataByID <IDictionary>(m_DataID, out data) && data != null) { m_RefreshCost = EB.Dot.Integer("refreshCost.quantity", data, m_RefreshCost); m_RefreshCostId = EB.Dot.String("refreshCost.data", data, m_RefreshCostId); m_LastRefreshTime = EB.Dot.Integer("lastRefreshTime", data, m_LastRefreshTime); int time = EB.Dot.Integer("nextRefreshTime", data, m_NextRefreshTime); m_NextRefreshTime = time; ShowRefreshPrice(); int limit = EB.Dot.Integer("unlimited", data, 0); if (limit == 1) { if (m_RefreshTimeLabel != null) { m_RefreshTimeLabel.gameObject.CustomSetActive(false); } if (RefreshBtnRoot != null) { RefreshBtnRoot.gameObject.CustomSetActive(false); } } else { if (m_RefreshTimeLabel != null) { m_RefreshTimeLabel.gameObject.CustomSetActive(true); } if (RefreshBtnRoot != null) { RefreshBtnRoot.gameObject.CustomSetActive(true); RefreshBtnRoot.onClick.Clear(); RefreshBtnRoot.onClick.Add(new EventDelegate(RefreshBtnClick)); } } if (NewCurrencyCommonLabel != null && NewCurrencyCommonSprite != null) { if (m_CurStoreGold == "gold") { NewCurrencyCommonLabel.transform.parent.gameObject.SetActive(false); } else { NewCurrencyCommonLabel.transform.parent.gameObject.SetActive(true); } NewCurrencyCommonLabel.text = BalanceResourceUtil.NumFormat(BalanceResourceUtil.GetResValue(m_CurStoreGold).ToString()); NewCurrencyCommonSprite.spriteName = BalanceResourceUtil.GetResSpriteName(m_CurStoreGold); } if (act != null) { StopCoroutine(act); act = null; } act = RefreshTime(m_NextRefreshTime); StartCoroutine(act); List <StoreItemData> datas = new List <StoreItemData>(); ArrayList items = Hotfix_LT.EBCore.Dot.Array("itemList", data, null); float discount = 1; bool isGoldVIP = LTChargeManager.Instance.IsGoldVIP(); if (!m_StoreType.Equals("bosschallenge1") && !m_StoreType.Equals("bosschallenge2") && !m_StoreType.Equals("bosschallenge3")) { discount = VIPTemplateManager.Instance.GetVIPPercent(VIPPrivilegeKey.ShopDiscount); } if (items != null && items.Count > 0) { for (int i = 0; i < items.Count; i++) { int sid = EB.Dot.Integer("id", items[i], 0); string id = EB.Dot.String("redeems.data", items[i], ""); string type = EB.Dot.String("redeems.type", items[i], ""); int buy_num = EB.Dot.Integer("redeems.quantity", items[i], 0); int have = GameItemUtil.GetItemAlreadyHave(id, type); string cost_id = EB.Dot.String("spends.data", items[i], ""); int cost_num = EB.Dot.Integer("spends.quantity", items[i], 0); int num = EB.Dot.Integer("num", items[i], 0); float mdiscount = EB.Dot.Single("discount", items[i], 1); bool sell_out = num > 0 || num == -1 ? false : true; int weight = 1; float result = cost_num * discount + 0.05f; cost_num = (int)(result); if (!string.IsNullOrEmpty(id)) { StoreItemData itemdata = new StoreItemData(sid, id, type, buy_num, have, cost_id, cost_num, sell_out, weight, i, m_StoreType, mdiscount, num); datas.Add(itemdata); } } int left = datas.Count % m_Columns; if (left > 0) //补全 { left = m_Columns - left; for (int i = 0; i < left; i++) { StoreItemData itemdata = new StoreItemData(0, "", "", 1, 1, "", 1, true, 1, i, m_StoreType, 1); datas.Add(itemdata); } } m_Scroll.SetItemDatas(datas); } else { EB.Debug.LogWarning("{0}===no data items", m_DataID); } } else { EB.Debug.LogWarning("{0}===no data", m_DataID); } }