示例#1
0
        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]);
            }
        }
示例#2
0
        /// <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);
            }
        }