示例#1
0
        public void MoveToStore(int fromSolt, int toSolt, int bagType, int maxCount)
        {
            IBag bag = _player.GetBag(bagType);

            if (bag == null)
            {
                return;
            }

            ItemInfo bagItem   = bag.GetItemAt(toSolt);
            ItemInfo storeItem = _player.StoreBag.GetItemAt(fromSolt);

            if (bagItem == null && storeItem == null)
            {
                return;
            }

            if (storeItem == null && (!IsSolt(fromSolt) || fromSolt >= maxCount))
            {
                fromSolt = FindFirstEmptySlot(0);
            }

            if (bagItem == null && !bag.IsSolt(toSolt))
            {
                if (bagType == 0)
                {
                    toSolt = bag.FindFirstEmptySlot(31);
                }
                else
                {
                    toSolt = bag.FindFirstEmptySlot(0);
                }
            }

            if (storeItem != null && storeItem.GetBagType() != bagType)
            {
                fromSolt = -1;
                toSolt   = -1;
            }

            //if (fromSolt >= maxCount)
            //    return;

            if (fromSolt == -1 || toSolt == -1 || fromSolt >= maxCount)
            {
                if (bagItem != null)
                {
                    _player.Out.SendUpdateInventorySlot(bagItem.Place, true, bagItem, bagItem.BagType);
                }

                if (storeItem != null)
                {
                    _player.Out.SendUpdateInventorySlot(storeItem.Place, true, storeItem, storeItem.BagType);
                }
            }
            else
            {
                if (storeItem != null)
                {
                    RemoveItem(storeItem);
                    bag.AddItemTo(storeItem, toSolt);
                }

                if (bagItem != null)
                {
                    bag.RemoveItem(bagItem);
                    AddItemTo(bagItem, fromSolt);
                }
            }
        }