| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | public class SinglePack |
| | | { |
| | |
| | | public int unlockedGridCount { get; private set; } //已开启背包格子数 |
| | | private Dictionary<int, ItemModel> items = new Dictionary<int, ItemModel>(); //key 物品位置索引 |
| | | private Dictionary<int, List<int>> itemIDs = new Dictionary<int, List<int>>(); //key 物品ID:物品位置索引 |
| | | |
| | | public List<string> itemGuidList = new List<string>(); //前端界面GUID排序,各个背包根据实际情况使用 |
| | | |
| | | public SinglePack(PackType type) |
| | | { |
| | | this.type = type; |
| | |
| | | return list; |
| | | } |
| | | |
| | | public int GetCountById(int itemId, bool includeAuction = true) |
| | | public List<string> GetItemGUIDListById(int itemId) |
| | | { |
| | | var count = 0; |
| | | //foreach (var item in items.Values) |
| | | //{ |
| | | // if (!includeAuction && item.isAuction) |
| | | // { |
| | | // continue; |
| | | // } |
| | | var list = new List<string>(); |
| | | if (itemIDs.ContainsKey(itemId)) |
| | | { |
| | | foreach (var index in itemIDs[itemId]) |
| | | { |
| | | var item = items[index]; |
| | | list.Add(item.guid); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | // if (item.itemId == itemId) |
| | | // { |
| | | // count += item.count; |
| | | // } |
| | | //} |
| | | |
| | | |
| | | public long GetCountById(int itemId, bool includeAuction = true) |
| | | { |
| | | long count = 0; |
| | | |
| | | //部分货币和物品绑定 |
| | | if (GeneralDefine.itemMoneyCountDict.ContainsKey(itemId)) |
| | | { |
| | | //展示货币数量的物品 |
| | | count = UIHelper.GetMoneyCnt(GeneralDefine.itemMoneyCountDict[itemId]); |
| | | } |
| | | |
| | | if (itemIDs.ContainsKey(itemId)) |
| | | { |
| | |
| | | return count; |
| | | } |
| | | |
| | | public List<ItemModel> GetItems() |
| | | { |
| | | return items.Values.ToList(); |
| | | } |
| | | |
| | | public List<int> GetItemIndexs() |
| | | { |
| | | return items.Keys.ToList(); |
| | | } |
| | | |
| | | public List<ItemModel> GetItems(FilterParams filterParams) |
| | | { |
| | | var list = new List<ItemModel>(); |
| | |
| | | |
| | | var jobValid = filterParams.jobs == null || filterParams.jobs.Contains(item.config.JobLimit); |
| | | if (!jobValid) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | //var auctionValid = filterParams.isAuction == item.isAuction; |
| | | //if (!auctionValid) |
| | | //{ |
| | | // continue; |
| | | //} |
| | | |
| | | var realmValid = filterParams.realmLimit == 0 || filterParams.realmLimit == item.config.RealmLimit; |
| | | if (!realmValid) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | itemIDs.Clear(); |
| | | } |
| | | |
| | | public struct FilterParams |
| | | public class FilterParams |
| | | { |
| | | public List<int> levels; |
| | | public List<int> qualitys; |
| | | public List<int> itemTypes; |
| | | public List<int> equipTypes; |
| | | public int realmLimit; |
| | | public bool isAuction; |
| | | public List<int> jobs; |
| | | } |