public bool DelBagGem(int pos) { XItem item = DataDBSBagGem.GetDataById(pos); if (item == null) { return(false); } DataDBSBagGem.Delete(pos); DataDBSGem.Delete(item.Instance); return(true); }
private void OnReq_DressGem(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); ReqDressGem req = Serializer.Deserialize <ReqDressGem>(ms); XItem bagGem = DataDBSBagGem.GetDataById(req.SrcPos); DGem cfg = ReadCfgGem.GetDataById(bagGem.Id); AckDressGem ack = new AckDressGem(); ack.SrcPos = req.SrcPos; ack.Index = req.Index; ack.TarPos = cfg.Pos; NetworkManager.Instance.Send(MessageID.MSG_ACK_DRESS_GEM, ack, 0, 0); }
private void OnAck_DressGem(MessageRecv obj) { System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Data); AckDressGem ack = Serializer.Deserialize <AckDressGem>(ms); int srcPos = ack.SrcPos; int tarPos = ack.TarPos; int index = ack.Index; XItem sourceGem = DataDBSBagGem.GetDataById(srcPos); DGem gemDB = ReadCfgGem.GetDataById(sourceGem.Id); int pos = MLGem.Instance.GetDressGemPosByIndexAndTargetPos(index, gemDB.Pos); XItem dressGem = DataDBSDressGem.GetDataById(pos); if (dressGem != null) { int sourceInstanceID = sourceGem.Instance; int sourceId = sourceGem.Id; sourceGem.Instance = dressGem.Instance; sourceGem.Id = dressGem.Id; dressGem.Instance = sourceInstanceID; dressGem.Id = sourceId; DataDBSDressGem.Update(dressGem.Pos, dressGem); DataDBSBagGem.Update(sourceGem.Pos, sourceGem); } else { dressGem = new XItem(); dressGem.Instance = sourceGem.Instance; dressGem.Pos = pos; dressGem.PosType = (int)EPosType.RoleGem; dressGem.Id = sourceGem.Id; dressGem.Num = 1; DataDBSDressGem.Insert(pos, dressGem); DataDBSBagGem.Delete(sourceGem.Pos); } GTWorld.Instance.SyncMainPlayerData(ESyncDataType.TYPE_BASEATTR); GTEventCenter.FireEvent(GTEventID.TYPE_BAG_DRESS_GEM, srcPos, tarPos); GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_FIGHTVALUE); }