Exemple #1
0
        /// <summary>
        /// 根据物品类型获取物品数据列表
        /// </summary>
        /// <param name="_nGoodsLabel">物品类型</param>
        /// <returns></returns>
        internal ObservableList <UWarGoodsStoreItem> GetWarGoodsStoreItem(List <int> _listGoodsLabelID, bool _bFilterGood = true)
        {
            char[] charSeparator = new char[] { MobaSchemesConfig.separator };
            //遍历所有物品数据
            return(WarGoodsStoreMobaGoodsDataSource.Where((item) =>
            {
                string[] itemLabels = item.SchemeGoodsInfo.GoodsLabel.Split(charSeparator);
                if (itemLabels.Length == 0)
                {
                    Trace.LogWarning("策划检查下物品ID:" + item.GoodsID + ",的标签子类型.");
                    return false;
                }

                if (_bFilterGood && EnableGoodsFilter) //如果需要过滤
                {
                    if (item.IsFiltered)
                    {
                        return false;
                    }
                }

                int confirmCount = 0;
                int tmpLabelID = -1;

                //遍历物品所有类型标签数据
                for (int i = 0; i < itemLabels.Length; ++i)
                {
                    if (string.IsNullOrEmpty(itemLabels[i]))
                    {
                        continue;
                    }

                    if (!int.TryParse(itemLabels[i], out tmpLabelID))
                    {
                        continue;
                    }
                    //判断类型是否在勾选列表里
                    if (_listGoodsLabelID.Contains(tmpLabelID))
                    {
                        confirmCount++;
                    }
                }

                return confirmCount == _listGoodsLabelID.Count;
            }).ToObservableList());
        }
Exemple #2
0
        /// <summary>
        /// 根据物品类型获取物品数据列表
        /// </summary>
        /// <param name="_nGoodsLabel">物品类型</param>
        /// <returns></returns>
        internal ObservableList <UWarGoodsStoreItem> GetWarGoodsStoreItem(string _strGoodsLabelID, bool _bFilterGood = true)
        {
            char[] charSeparator = new char[] { MobaSchemesConfig.separator };

            //选的是类型子类
            if (Convert.ToInt32(_strGoodsLabelID) > 1000)
            {
                return(WarGoodsStoreMobaGoodsDataSource.Where((item) =>
                {
                    if (_bFilterGood && EnableGoodsFilter) //如果需要过滤
                    {
                        if (item.IsFiltered)
                        {
                            return false;
                        }
                    }

                    foreach (string label in item.SchemeGoodsInfo.GoodsLabel.Split(charSeparator))
                    {
                        if (string.IsNullOrEmpty(label))
                        {
                            continue;
                        }
                        if (label == _strGoodsLabelID)
                        {
                            return true;
                        }
                    }
                    return false;
                }).ToObservableList());
            }
            else
            {
                int nGoodsLabelID = Convert.ToInt32(_strGoodsLabelID) * 1000;
                int nItemLabelID  = -1;
                return(WarGoodsStoreMobaGoodsDataSource.Where((item) =>
                {
                    if (_bFilterGood && EnableGoodsFilter) //如果需要过滤
                    {
                        if (item.IsFiltered)
                        {
                            return false;
                        }
                    }

                    foreach (string label in item.SchemeGoodsInfo.GoodsLabel.Split(charSeparator))
                    {
                        if (string.IsNullOrEmpty(label))
                        {
                            continue;
                        }
                        nItemLabelID = Convert.ToInt32(label);

                        if (nItemLabelID > nGoodsLabelID && nItemLabelID < nGoodsLabelID + 1000)
                        {
                            return true;
                        }
                    }
                    return false;
                }).ToObservableList());
            }
        }