public void MoveToStore(PlayerInventory bag, int fromSolt, int toSolt, PlayerInventory tobag, int maxCount) { ItemInfo item = bag.GetItemAt(fromSolt); ItemInfo toItem = tobag.GetItemAt(toSolt); if (item == null && toItem == null) return; if (toItem == null && (toSolt < 0 || toSolt > 80) || (tobag.BagType == 11 && toSolt >= maxCount)) { if (tobag.BagType == 11 || tobag.BagType == 1) toSolt = tobag.FindFirstEmptySlot(0); //else if(bag.BagType==12&&tobag.BagType==0){ // toSolt=tobag.FindFirstEmptySlot(7); //} else toSolt = tobag.FindFirstEmptySlot(31); } if ((item.Template.CategoryID == 10 || item.Template.CategoryID == 11 || item.Template.CategoryID == 12) && tobag.BagType != 0 || ((item.Template.CategoryID != 10 && item.Template.CategoryID != 11 && item.Template.CategoryID != 12) && tobag.BagType != 1)) { if (toItem != null && item != null) { int place = item.Place; int bagtype = item.BagType; int place1 = toItem.Place; int bagtype1 = toItem.BagType; bag.RemoveItem(item); tobag.RemoveItem(toItem); item.IsExist = true; item.BagType = bagtype1; tobag.AddItemTo(item, place1); toItem.IsExist = true; toItem.BagType = bagtype; if (place == -1 && (eBageType)bag.BagType == eBageType.MainBag) { place = bag.FindFirstEmptySlot(31); } if (place < 31) place = bag.FindFirstEmptySlot(31); bag.AddItemTo(toItem, place); } else { if (toItem != null) { tobag.RemoveItem(item); bag.AddItemTo(item, toSolt); } if (item != null) { if (tobag.BagType == 11 && toSolt >= maxCount) { UpdateItem(item); return; } else { bag.RemoveItem(item); tobag.AddItemTo(item, toSolt); } } } } else { if (toItem != null) UpdateItem(toItem); if (item != null) UpdateItem(item); } }
public void SendUpdateCardData(PlayerInventory bag) { if (bag.BagType == (int)eBageType.Card) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.CARDS_DATA); pkg.WriteInt(m_gameClient.Player.PlayerCharacter.ID); var length = 17; pkg.WriteInt(17); for (int i = 0; i < length; i++) { pkg.WriteInt(i); if (bag.GetItemAt(i) != null) { pkg.WriteBoolean(true); var item = bag.GetItemAt(i); //cardId pkg.WriteInt(item.ItemID); pkg.WriteInt(m_gameClient.Player.PlayerCharacter.ID); pkg.WriteInt(item.Count); pkg.WriteInt(item.Place); pkg.WriteInt(item.Template.TemplateID); pkg.WriteInt(item.Attack); pkg.WriteInt(item.Defence); pkg.WriteInt(item.Agility); pkg.WriteInt(item.Luck); pkg.WriteInt(item.AttackCompose); pkg.WriteInt(99); pkg.WriteInt(item.StrengthenLevel); pkg.WriteInt(item.AgilityCompose); pkg.WriteBoolean(true); } else { pkg.WriteBoolean(false); } } SendTCP(pkg); return; } }
public void MoveToStore(PlayerInventory bag, int fromSolt, int toSolt, PlayerInventory tobag, int maxCount) { ItemInfo item = bag.GetItemAt(fromSolt); ItemInfo toItem = tobag.GetItemAt(toSolt); if (item == null && toItem == null) { return; } if (toItem == null && (toSolt < 0 || toSolt > 80) || (tobag.BagType == 11 && toSolt >= maxCount)) { //if (tobag.BagType == 11 || tobag.BagType == 1) if ((tobag.BagType == (int)eBageType.Bank) || (tobag.BagType == (int)eBageType.PropBag)) { toSolt = tobag.FindFirstEmptySlot(0); } else { toSolt = tobag.FindFirstEmptySlot(31); } } if ((item.Template.CategoryID == 10 || item.Template.CategoryID == 11 || item.Template.CategoryID == 12) && tobag.BagType != 0 || ((item.Template.CategoryID != 10 && item.Template.CategoryID != 11 && item.Template.CategoryID != 12) && tobag.BagType != 1)) { if (toItem != null && item != null) { int place = item.Place; int bagtype = item.BagType; int place1 = toItem.Place; int bagtype1 = toItem.BagType; bag.RemoveItem(item); tobag.RemoveItem(toItem); item.IsExist = true; item.BagType = bagtype1; tobag.AddItemTo(item, place1); toItem.IsExist = true; toItem.BagType = bagtype; if (place == -1 && (eBageType)bag.BagType == eBageType.MainBag) { place = bag.FindFirstEmptySlot(31); } if (place < 31) { place = bag.FindFirstEmptySlot(31); } bag.AddItemTo(toItem, place); } else { if (toItem != null) { tobag.RemoveItem(item); bag.AddItemTo(item, toSolt); } if (item != null) { if (tobag.BagType == (int)eBageType.Bank && toSolt >= maxCount) { //Console.WriteLine("+++++Stage 12!"); UpdateItem(item); return; } else { //Console.WriteLine("+++++Stage 13!"); bag.RemoveItem(item); tobag.AddItemTo(item, toSolt); } } } } else { if (toItem != null) { UpdateItem(toItem); } //Console.WriteLine("+++++UpdateItem(toItem);"); if (item != null) { UpdateItem(item); } //Console.WriteLine("+++++UpdateItem(item);"); } }
//public void SendUpdateInventorySlot(PlayerInventory bag, int[] updatedSlots) //{ // if (m_gameClient.Player == null) // return; // var numSend = updatedSlots.Length; // var j = 0; // do // { // GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GRID_GOODS, m_gameClient.Player.PlayerCharacter.ID); // pkg.WriteInt(bag.BagType); // var length = (numSend > 10) ? 10 : numSend; // pkg.WriteInt(length); // for (int i = 0; i < length; i++, j++) // { // pkg.WriteInt(updatedSlots[i]); // ItemInfo item = bag.GetItemAt(updatedSlots[i]); // if (item == null) // { // pkg.WriteBoolean(false); // } // else // { // pkg.WriteBoolean(true); // pkg.WriteInt(item.UserID); // pkg.WriteInt(item.ItemID); // pkg.WriteInt(item.Count); // pkg.WriteInt(item.Place); // pkg.WriteInt(item.TemplateID); // pkg.WriteInt(item.AttackCompose); // pkg.WriteInt(item.DefendCompose); // pkg.WriteInt(item.AgilityCompose); // pkg.WriteInt(item.LuckCompose); // pkg.WriteInt(item.StrengthenLevel); // pkg.WriteBoolean(item.IsBinds); // pkg.WriteBoolean(item.IsJudge); // pkg.WriteDateTime(item.BeginDate); // pkg.WriteInt(item.ValidDate); // pkg.WriteString(item.Color == null ? "" : item.Color); // pkg.WriteString(item.Skin == null ? "" : item.Skin); // pkg.WriteBoolean(item.IsUsed); // pkg.WriteInt(item.Hole1); // pkg.WriteInt(item.Hole2); // pkg.WriteInt(item.Hole3); // pkg.WriteInt(item.Hole4); // pkg.WriteInt(item.Hole5); // pkg.WriteInt(item.Hole6); // //DDTank // pkg.WriteString(item.Template.Pic); // pkg.WriteInt(5); // pkg.WriteDateTime(DateTime.Now.AddDays(5)); // pkg.WriteInt(5); // pkg.WriteByte(5); // pkg.WriteInt(5); // pkg.WriteByte(5); // pkg.WriteInt(5); // //item.RefineryLevel = pkg.readInt(); // //item.DiscolorValidDate = pkg.readDateString(); // //item.StrengthenTimes = pkg.readInt(); // //item.Hole5Level = pkg.readByte(); // //item.Hole5Exp = pkg.readInt(); // //item.Hole6Level = pkg.readByte(); // //item.Hole6Exp = pkg.readInt(); // } // } // numSend -= length; // SendTCP(pkg); // } while (j < updatedSlots.Length); //} public void SendUpdateInventorySlot(PlayerInventory bag, int[] updatedSlots) { if (m_gameClient.Player == null) return; if (bag.BagType == (int)eBageType.Card) { SendUpdateCardData(bag); return; } GSPacketIn pkg; pkg = new GSPacketIn((byte)ePackageType.GRID_GOODS, m_gameClient.Player.PlayerCharacter.ID, 10240); pkg.WriteInt(bag.BagType); pkg.WriteInt(updatedSlots.Length); foreach (int i in updatedSlots) { pkg.WriteInt(i); ItemInfo item = bag.GetItemAt(i); if (item == null) { pkg.WriteBoolean(false); } else { pkg.WriteBoolean(true); pkg.WriteInt(item.UserID); pkg.WriteInt(item.ItemID); pkg.WriteInt(item.Count); pkg.WriteInt(item.Place); pkg.WriteInt(item.TemplateID); pkg.WriteInt(item.AttackCompose); pkg.WriteInt(item.DefendCompose); pkg.WriteInt(item.AgilityCompose); pkg.WriteInt(item.LuckCompose); pkg.WriteInt(item.StrengthenLevel); pkg.WriteBoolean(item.IsBinds); pkg.WriteBoolean(item.IsJudge); pkg.WriteDateTime(item.BeginDate); pkg.WriteInt(item.ValidDate); pkg.WriteString(item.Color == null ? "" : item.Color); pkg.WriteString(item.Skin == null ? "" : item.Skin); pkg.WriteBoolean(item.IsUsed); pkg.WriteInt(item.Hole1); pkg.WriteInt(item.Hole2); pkg.WriteInt(item.Hole3); pkg.WriteInt(item.Hole4); pkg.WriteInt(item.Hole5); pkg.WriteInt(item.Hole6); //DDTank pkg.WriteString(item.Template.Pic); pkg.WriteInt(5); pkg.WriteDateTime(DateTime.Now.AddDays(5)); pkg.WriteInt(0); pkg.WriteByte(0); pkg.WriteInt(0); pkg.WriteByte(0); pkg.WriteInt(0); //item.RefineryLevel = pkg.readInt(); //item.DiscolorValidDate = pkg.readDateString(); //item.StrengthenTimes = pkg.readInt(); //item.Hole5Level = pkg.readByte(); //item.Hole5Exp = pkg.readInt(); //item.Hole6Level = pkg.readByte(); //item.Hole6Exp = pkg.readInt(); } } SendTCP(pkg); }
public void SendUpdateCardData(PlayerInventory bag, int[] updatedSlots) { if (bag.BagType == (int)eBageType.Card) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.CARDS_DATA); pkg.WriteInt(m_gameClient.Player.PlayerCharacter.ID); pkg.WriteInt(updatedSlots.Length); foreach (int i in updatedSlots) { pkg.WriteInt(i); if (bag.GetItemAt(i) != null) { pkg.WriteBoolean(true); var item = bag.GetItemAt(i); pkg.WriteInt(item.ItemID); pkg.WriteInt(m_gameClient.Player.PlayerCharacter.ID); pkg.WriteInt(item.Count); pkg.WriteInt(item.Place); pkg.WriteInt(item.Template.TemplateID); pkg.WriteInt(item.Attack); pkg.WriteInt(item.Defence); pkg.WriteInt(item.Agility); pkg.WriteInt(item.Luck); pkg.WriteInt(item.AttackCompose);// _loc_9.Damage = _loc_2.readInt(); pkg.WriteInt(item.DefendCompose); //_loc_9.Guard = _loc_2.readInt(); pkg.WriteInt(item.StrengthenLevel);//_loc_9.Level = _loc_2.readInt(); pkg.WriteInt(item.Hole5Exp);//_loc_9.CardGP = _loc_2.readInt(); pkg.WriteBoolean(item.IsGold); //_loc_2.readBoolean(); } else { pkg.WriteBoolean(false); } } SendTCP(pkg); } return; }