| | |
| | | public event Action<PackType, string, bool> ChangeItemEvent; // 背包类型,GUID,是否创建 |
| | | |
| | | //删除物品,可能批量删除注意效率 |
| | | public event Action<PackType, string> DeleteItemEvent; // 背包类型,GUID |
| | | public event Action<PackType, string, int, int, int> DeleteItemEvent; // 背包类型,GUID, 物品ID,索引, 删除原因 |
| | | |
| | | // 单物品刷新 在得到新物品、物品数量的改变,清理该物品时均会触发 ; 但0725整个背包刷新不触发,如果有需要单独数量刷新事件另外处理 |
| | | // 触发比较频繁,界面使用时可以做个汇总后延迟刷新 |
| | |
| | | public event Action<int> refreshItemDayUseCountEvent; //刷新物品每日使用数量 |
| | | public event Action<int> refreshItemSumUseCountEvent; //刷新物品总使用数量 |
| | | public event Action<PackType, string, bool> RefreshItemLockEvent; //物品锁定刷新 背包类型,guid,锁定状态 |
| | | |
| | | public bool isPlayBetterEquipEffect { get; set; } //整理背包时是否播放特效 |
| | | |
| | | |
| | | private Dictionary<PackType, SinglePack> playerPackDict = new Dictionary<PackType, SinglePack>(); |
| | |
| | | itemSumUseCntDict.Clear(); |
| | | itemGUIDDict.Clear(); |
| | | PackGirdServerBuyCountDict.Clear(); |
| | | isPlayBetterEquipEffect = false; |
| | | } |
| | | |
| | | |
| | |
| | | playerPackDict.Add(packType, new SinglePack(packType)); |
| | | } |
| | | |
| | | if (isPlayBetterEquipEffect) |
| | | { |
| | | ItemLogicUtility.Instance.ClearSortedBetterEquip(); |
| | | } |
| | | |
| | | for (int i = 0; i < packInfo.ItemCount; i++) |
| | | { |
| | |
| | | var item = playerPackDict[packType].UpdateItem(itemInfo); |
| | | AddItemGUIDDict(item, true); |
| | | |
| | | if (isPlayBetterEquipEffect) |
| | | { |
| | | ItemLogicUtility.Instance.SetBagSortBetterEquipList(GetItemByGuid(itemInfo.guid)); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (refrechPackEvent != null) |
| | |
| | | |
| | | public void UpdateItem(H0704_tagRolePackRefresh serverItem) |
| | | { |
| | | isPlayBetterEquipEffect = false; |
| | | SetLookIndex(null); |
| | | PackType type = (PackType)serverItem.PackType; |
| | | if (!playerPackDict.ContainsKey(type)) |
| | |
| | | public void RefreshItemCount(H0707_tagItemCountRefresh refresh) |
| | | { |
| | | SetLookIndex(null); |
| | | isPlayBetterEquipEffect = false; |
| | | PackType type = (PackType)refresh.PackType; |
| | | SinglePack singlePack = null; |
| | | playerPackDict.TryGetValue(type, out singlePack); |
| | |
| | | |
| | | public void RemoveItem(H0709_tagClearItem clearItem) |
| | | { |
| | | isPlayBetterEquipEffect = false; |
| | | SetLookIndex(null); |
| | | PackType type = (PackType)clearItem.PackType; |
| | | |
| | |
| | | guid = itemModel.guid; |
| | | int itemId = itemModel.itemId; |
| | | |
| | | DeleteItemDictByGUID(type, itemModel.guid); |
| | | |
| | | singlePack.RemoveItem(clearItem.ItemIndex); |
| | | DeleteItemDictByGUID(type, itemModel.guid,itemId, clearItem.ItemIndex, clearItem.ClearType); |
| | | |
| | | if (RefreshItemEvent != null) |
| | | { |
| | | RefreshItemEvent(type, clearItem.ItemIndex, itemId); |
| | |
| | | |
| | | public void UseItemSuccess(H0706_tagUseItemSuccess success) |
| | | { |
| | | isPlayBetterEquipEffect = false; |
| | | SetLookIndex(null); |
| | | if (success.PlayerID != PlayerDatas.Instance.baseData.PlayerID) |
| | | { |
| | |
| | | ChangeItemEvent?.Invoke(itemModel.packType, itemModel.guid, showNewItem); |
| | | } |
| | | |
| | | void DeleteItemDictByGUID(PackType type, string guid) |
| | | void DeleteItemDictByGUID(PackType type, string guid, int itemID = 0, int index = 0, int clearType = -1) |
| | | { |
| | | if (itemGUIDDict.ContainsKey(guid)) |
| | | { |
| | | if (itemGUIDDict[guid].packType == type) |
| | | { |
| | | itemGUIDDict.Remove(guid); |
| | | DeleteItemEvent?.Invoke(type, guid); |
| | | DeleteItemEvent?.Invoke(type, guid, itemID, index, clearType); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public List<ItemModel> GetItems(PackType packType) |
| | | { |
| | | if (playerPackDict.ContainsKey(packType)) |
| | | { |
| | | return playerPackDict[packType].GetItems(); |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | //通过id找物品,注意检查是否指定背包 |
| | | public string GetItemGUIDByID(int itemId, bool includeAuction = true, PackType packType = PackType.Item) |
| | | { |