public void AddNewRune(int instance, int id) { int newPos = GetNewPos(EBagType.RUNE); if (newPos == 0) { return; } XItem item = new XItem(); item.Pos = newPos; item.Instance = instance; item.Pos = newPos; item.Id = id; item.Num = 1; item.PosType = (int)EPosType.BagRune; DataDBSBagRune.Insert(newPos, item); DataDBSRune.Insert(instance, GTDataFactory.CreateRune(id, instance)); }
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); }