//宝石替换 public void GemReplace(PlayerObject play, byte[] data) { GameBase.Network.PackIn inpack = new GameBase.Network.PackIn(data); inpack.ReadInt16(); inpack.ReadUInt32(); uint itemid = inpack.ReadUInt32(); RoleItemInfo src_item = play.GetItemSystem().FindItem(itemid); if (src_item == null) { play.MsgBox("替换失败,装备不存在。"); return; } int gem1_type = inpack.ReadInt32(); int gem2_type = inpack.ReadInt32(); int gem3_type = inpack.ReadInt32(); uint gem1_replace_id = inpack.ReadUInt32(); uint gem2_replace_id = inpack.ReadUInt32(); uint gem3_replace_id = inpack.ReadUInt32(); RoleItemInfo gem1_item_info = play.GetItemSystem().FindItem(gem1_replace_id); RoleItemInfo gem2_item_info = play.GetItemSystem().FindItem(gem2_replace_id); RoleItemInfo gem3_item_info = play.GetItemSystem().FindItem(gem3_replace_id); //第一个洞 if (gem1_item_info != null && gem1_item_info.IsGem()) { if (src_item.GetGemCount() > 0) { src_item.SetGemType(0, gem1_item_info.GetGemType()); play.GetItemSystem().DeleteItemByID(gem1_item_info.id); } } //第二个洞 if (gem2_item_info != null && gem2_item_info.IsGem()) { if (src_item.GetGemCount() > 1) { src_item.SetGemType(1, gem2_item_info.GetGemType()); play.GetItemSystem().DeleteItemByID(gem2_item_info.id); } } //第三个洞 if (gem3_item_info != null && gem3_item_info.IsGem()) { if (src_item.GetGemCount() > 2) { src_item.SetGemType(2, gem3_item_info.GetGemType()); play.GetItemSystem().DeleteItemByID(gem3_item_info.id); } } play.GetItemSystem().SendItemInfo(src_item); play.MsgBox("宝石替换成功"); // src_item.SetGemType() }