public void AddChip(int id, int num) { XItem item = GTDataManager.Instance.GetItemDataById(id); if (item == null) { int newPos = GetNewPos(EBagType.CHIP); if (newPos != 0) { this.MaxInstance++; item = new XItem(); item.Instance = this.MaxInstance; item.Pos = newPos; item.Id = id; item.Num = num; item.PosType = (int)EPosType.BagChip; DataDBSBagChip.Insert(newPos, item); } } else { item.Num += num; DataDBSBagChip.Update(item.Pos, item); } }
private void OnAck_SortBag(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); AckSortBag ack = Serializer.Deserialize <AckSortBag>(ms); EBagType bagType = (EBagType)ack.BagType; Dictionary <int, XItem> items = GTDataManager.Instance.GetBagDataByBagType(bagType); List <XItem> list = new List <XItem>(); list.AddRange(items.Values); items.Clear(); switch (bagType) { case EBagType.ITEM: { list.Sort(MLBag.Instance.CompareBagItem); DataDBSBagItem.Clear(false); for (int i = 0; i < list.Count; i++) { list[i].Pos = i + 1; DataDBSBagItem.Insert(list[i].Pos, list[i]); } } break; case EBagType.GEM: { list.Sort(MLBag.Instance.CompareBagGem); DataDBSBagGem.Clear(false); for (int i = 0; i < list.Count; i++) { list[i].Pos = i + 1; DataDBSBagGem.Insert(list[i].Pos, list[i]); } } break; case EBagType.CHIP: { list.Sort(MLBag.Instance.CompareBagChip); DataDBSBagChip.Clear(false); for (int i = 0; i < list.Count; i++) { list[i].Pos = i + 1; DataDBSBagChip.Insert(list[i].Pos, list[i]); } } break; case EBagType.FASHION: { list.Sort(MLBag.Instance.CompareBagFashion); DataDBSBagFashion.Clear(false); for (int i = 0; i < list.Count; i++) { list[i].Pos = i + 1; DataDBSBagFashion.Insert(list[i].Pos, list[i]); } } break; case EBagType.RUNE: { list.Sort(MLBag.Instance.CompareBagRune); DataDBSBagRune.Clear(false); for (int i = 0; i < list.Count; i++) { list[i].Pos = i + 1; DataDBSBagRune.Insert(list[i].Pos, list[i]); } } break; } GTEventCenter.FireEvent(GTEventID.TYPE_BAG_SORT_BAG); }