void DumpRoleData() { DataDBSMoney.Clear(); DataDBSAction.Clear(); DataDBSSoul.Clear(); DataDBSBagItem.Clear(); DataDBSBagGem.Clear(); DataDBSBagChip.Clear(); DataDBSBagRune.Clear(); DataDBSBagFashion.Clear(); DataDBSDressEquip.Clear(); DataDBSDressFashion.Clear(); DataDBSDressGem.Clear(); DataDBSDressRune.Clear(); DataDBSEquip.Clear(); DataDBSGem.Clear(); DataDBSRune.Clear(); DataDBSMainChapter.Clear(); DataDBSCopy.Clear(); DataDBSRaid.Clear(); DataDBSRelics.Clear(); DataDBSMount.Clear(); DataDBSPartner.Clear(); DataDBSPet.Clear(); DataDBSGuide.Clear(); DataDBSThreadTask.Clear(); DataDBSBranchTask.Clear(); DataDBSDailyTask.Clear(); }
private void OnAck_UseItem(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); AckUseItem ack = Serializer.Deserialize <AckUseItem>(ms); int pos = ack.Pos; int num = ack.Num; int id = ack.ID; XItem item = DataDBSBagItem.GetDataById(pos); DItem itemDB = ReadCfgItem.GetDataById(item.Id); switch (itemDB.ItemType) { case EItemType.DRUG: GTDataManager.Instance.AddNewItem(itemDB.Data2, itemDB.Data1 * num); GTDataManager.Instance.UseItemById(itemDB.Id, num); break; case EItemType.BOX: break; } GTEventCenter.FireEvent(GTEventID.TYPE_BAG_USE_ITEM, id, num); }
void ReadRoleData() { DataDBSBagItem.Read(GetDataPath(GTDataKey.Data_BagItems), EDataKeyType.Pos); DataDBSEquip.Read(GetDataPath(GTDataKey.Data_Equips), EDataKeyType.Instance); DataDBSDressEquip.Read(GetDataPath(GTDataKey.Data_DressEquips), EDataKeyType.Pos); DataDBSMoney.Read(GetDataPath(GTDataKey.Data_Moneys), EDataKeyType.Id); DataDBSAction.Read(GetDataPath(GTDataKey.Data_Actions), EDataKeyType.Id); DataDBSSoul.Read(GetDataPath(GTDataKey.Data_Souls), EDataKeyType.Id); DataDBSBagGem.Read(GetDataPath(GTDataKey.Data_BagGems), EDataKeyType.Pos); DataDBSGem.Read(GetDataPath(GTDataKey.Data_Gems), EDataKeyType.Instance); DataDBSDressGem.Read(GetDataPath(GTDataKey.Data_DressGems), EDataKeyType.Pos); DataDBSBagChip.Read(GetDataPath(GTDataKey.Data_BagChips), EDataKeyType.Pos); DataDBSBagFashion.Read(GetDataPath(GTDataKey.Data_BagFashions), EDataKeyType.Pos); DataDBSBagRune.Read(GetDataPath(GTDataKey.Data_BagRunes), EDataKeyType.Pos); DataDBSDressRune.Read(GetDataPath(GTDataKey.Data_DressRunes), EDataKeyType.Pos); DataDBSDressFashion.Read(GetDataPath(GTDataKey.Data_DressFashions), EDataKeyType.Pos); DataDBSRune.Read(GetDataPath(GTDataKey.Data_Runes), EDataKeyType.Instance); DataDBSCopy.Read(GetDataPath(GTDataKey.Data_Copys), EDataKeyType.Id); DataDBSMainChapter.Read(GetDataPath(GTDataKey.Data_MainChapters), EDataKeyType.Id); DataDBSRaid.Read(GetDataPath(GTDataKey.Data_Raid), EDataKeyType.Id); DataDBSPartner.Read(GetDataPath(GTDataKey.Data_Partners), EDataKeyType.Id); DataDBSMount.Read(GetDataPath(GTDataKey.Data_Mounts), EDataKeyType.Id); DataDBSRelics.Read(GetDataPath(GTDataKey.Data_Relics), EDataKeyType.Id); DataDBSPet.Read(GetDataPath(GTDataKey.Data_Pets), EDataKeyType.Id); DataDBSGuide.Read(GetDataPath(GTDataKey.Data_Guides), EDataKeyType.Id); DataDBSThreadTask.Read(GetDataPath(GTDataKey.Data_MainTasks), EDataKeyType.Id); DataDBSBranchTask.Read(GetDataPath(GTDataKey.Data_BranchTasks), EDataKeyType.Id); DataDBSDailyTask.Read(GetDataPath(GTDataKey.Data_DailyTasks), EDataKeyType.Id); }
public void AddItem(int id, int num) { XItem item = Instance.GetItemDataById(id); if (item == null) { int newPos = GetNewPos(EBagType.ITEM); if (newPos != 0) { Instance.MaxInstance++; item = new XItem(); item.Instance = this.MaxInstance; item.Pos = newPos; item.Id = id; item.Num = num; item.PosType = (int)EPosType.BagItem; DataDBSBagItem.Insert(newPos, item); } } else { item.Num += num; DataDBSBagItem.Update(item.Pos, item); } }
public void ShowInfo(int pos) { XItem item = DataDBSBagItem.GetDataById(pos); GTItemHelper.ShowItemName(itemName, item.Id); GTItemHelper.ShowItemTexture(itemTexture, item.Id); GTItemHelper.ShowItemQuality(itemQuality, item.Id); mItemPos = pos; mMaxUseCount = GTDataManager.Instance.GetItemCountById(item.Id); SetCurrCount(1); }
public static void ShowItemUseDialogByPos(int pos) { if (!DataDBSBagItem.ContainsKey(pos)) { return; } GTWindowManager.Instance.OpenWindow(EWindowID.UIItemUse); UIItemUse window = (UIItemUse)GTWindowManager.Instance.GetWindow(EWindowID.UIItemUse); window.ShowView(pos); }
public bool DelBagEquip(int pos) { XItem item = DataDBSBagItem.GetDataById(pos); if (item == null) { return(false); } DataDBSBagItem.Delete(pos); DataDBSEquip.Delete(item.Instance); return(true); }
private void OnReq_DressEquip(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); ReqDressEquip req = Serializer.Deserialize <ReqDressEquip>(ms); AckDressEquip ack = new AckDressEquip(); XItem bagEquip = DataDBSBagItem.GetDataById(req.SrcPos); DEquip equipDB = ReadCfgEquip.GetDataById(bagEquip.Id); ack.SrcPos = req.SrcPos; ack.TarPos = equipDB.Pos; NetworkManager.Instance.Send(MessageID.MSG_ACK_DRESS_EQUIP, ack, 0, 0); }
public void ShowView(int pos) { mItemPos = pos; XItem item = DataDBSBagItem.GetDataById(pos); mMaxUseCount = GTDataManager.Instance.GetItemCountById(item.Id); GTItemHelper.ShowItemName(itemName, item.Id); GTItemHelper.ShowItemTexture(itemTexture, item.Id); GTItemHelper.ShowItemQuality(itemQuality, item.Id); SetCurrCount(1); itemNum.text = GTTools.Format("拥有数量:{0}", item.Num); }
public void ShowViewByPos(int pos, bool canUse) { this.pos = pos; XItem item = DataDBSBagItem.GetDataById(pos); int itemID = item.Id; DItem itemDB = ReadCfgItem.GetDataById(itemID); itemDesc.text = itemDB.Desc; itemNum.text = GTTools.Format("拥有数量:{0}", item.Num); GTItemHelper.ShowItemTexture(itemTexture, itemID); GTItemHelper.ShowItemName(itemName, itemID); GTItemHelper.ShowItemQuality(itemQuality, itemID); btnBatchUse.SetActive(canUse); btnUse.SetActive(canUse); btnSure.SetActive(!canUse); }
public void ShowInfoByPos(int pos, bool canUse) { this.mPos = pos; XItem item = DataDBSBagItem.GetDataById(pos); int itemID = item.Id; DItem itemDB = ReadCfgItem.GetDataById(itemID); itemDesc.text = itemDB.Desc; int hasNum = GTDataManager.Instance.GetItemCountById(itemID); itemNum.text = GTTools.Format("拥有数量:{0}", hasNum); GTItemHelper.ShowItemTexture(itemTexture, itemID); GTItemHelper.ShowItemName(itemName, itemID); GTItemHelper.ShowItemQuality(itemQuality, itemID); btnBatchUse.SetActive(canUse); btnUse.SetActive(canUse); }
private void OnAck_DressEquip(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); AckDressEquip ack = Serializer.Deserialize <AckDressEquip>(ms); int srcPos = ack.SrcPos; int tarPos = ack.TarPos; XItem bagEquip = DataDBSBagItem.GetDataById(srcPos); DEquip equipDB = ReadCfgEquip.GetDataById(bagEquip.Id); XItem dressEquip = DataDBSDressEquip.GetDataById(equipDB.Pos); if (dressEquip != null) { int bagInstance = bagEquip.Instance; int bagId = bagEquip.Id; bagEquip.Id = dressEquip.Id; bagEquip.Instance = dressEquip.Instance; bagEquip.PosType = (int)EPosType.BagItem; dressEquip.Instance = bagInstance; dressEquip.PosType = (int)EPosType.RoleEquip; dressEquip.Id = bagId; DataDBSDressEquip.Update(equipDB.Pos, dressEquip); DataDBSBagItem.Update(srcPos, bagEquip); } else { dressEquip = new XItem(); dressEquip.Instance = bagEquip.Instance; dressEquip.Pos = equipDB.Pos; dressEquip.PosType = (int)EPosType.RoleEquip; dressEquip.Id = bagEquip.Id; dressEquip.Num = 1; DataDBSDressEquip.Insert(equipDB.Pos, dressEquip); DataDBSBagItem.Delete(srcPos); } GTWorld.Instance.SyncMainPlayerData(ESyncDataType.TYPE_EQUIP); GTEventCenter.FireEvent(GTEventID.TYPE_BAG_DRESS_EQUIP, srcPos, tarPos); GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_FIGHTVALUE); }
public void AddNewEquip(int instance, int id) { int newPos = GetNewPos(EBagType.ITEM); if (newPos == 0) { return; } XItem item = new XItem(); item.Instance = instance; item.Pos = newPos; item.Id = id; item.Num = 1; item.PosType = (int)EPosType.BagItem; DataDBSBagItem.Insert(newPos, item); DataDBSEquip.Update(instance, GTDataFactory.CreateEquip(id, instance)); }
public void TryUseItemByPos(int pos, int num) { XItem item = DataDBSBagItem.GetDataById(pos); if (item.Num < num) { GTItemHelper.ShowTip("物品不足"); return; } DItem itemDB = ReadCfgItem.GetDataById(item.Id); if (itemDB.ItemType == EItemType.BOX) { if (itemDB.Data1 != 0) { if (GTDataManager.Instance.GetItemCountById(itemDB.Data1) < num) { GTItemHelper.ShowTip("需要足够的钥匙"); return; } } DAward awardDB = ReadCfgAward.GetDataById(itemDB.Data2); if (GTItemHelper.CheckBagFull(awardDB.MaxDropNum)) { return; } } ReqUseItem req = new ReqUseItem(); req.Pos = pos; req.Num = num; req.PosType = (int)EPosType.BagItem; req.ID = item.Id; NetworkManager.Instance.Send <ReqUseItem>(MessageID.MSG_REQ_USEITEM, req); }
private void OnAck_UnloadEquip(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); AckUnloadEquip ack = Serializer.Deserialize <AckUnloadEquip>(ms); int newPos = ack.NewPos; int tarPos = ack.TarPos; XItem dressEquip = DataDBSDressEquip.GetDataById(tarPos); XItem bagItem = new XItem(); bagItem.Instance = dressEquip.Instance; bagItem.Pos = newPos; bagItem.PosType = (int)EPosType.BagItem; bagItem.Id = dressEquip.Id; bagItem.Num = 1; DataDBSBagItem.Insert(newPos, bagItem); DataDBSDressEquip.Delete(tarPos); GTWorld.Instance.SyncMainPlayerData(ESyncDataType.TYPE_EQUIP); GTEventCenter.FireEvent(GTEventID.TYPE_BAG_UNLOAD_EQUIP, newPos, tarPos); GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_FIGHTVALUE); }
public bool UseBagItem(int id, int num) { XItem item = GetItemDataById(id); if (item == null) { return(false); } if (item.Num < num) { return(false); } item.Num -= num; if (item.Num < 1) { int pos = item.Pos; DataDBSBagItem.Delete(pos); } else { DataDBSBagItem.Update(item.Pos, item); } return(true); }
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); }