public static void Move(ItemInventory fromIn, ItemInventory toIn, ItemPosition ip, int countX, int countY, ISkillArgs args, FreeRuleEventArgs fr, IInventoryUI fromUI, IInventoryUI toUI) { if (fromIn != toIn) { fr.TempUse(PARA_ITEM, ip); bool canDrop = toIn.IsCanDrop(ip, args); // 如果toIn 不可以拖入物品 if (!canDrop) { fromUI.UpdateItem(args, fromIn, ip); if (toIn.GetDropAction() != null) { toIn.GetDropAction().Act(args); } //HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args); fr.Resume(PARA_ITEM); return; } fr.Resume(PARA_ITEM); } // 已有 ItemPosition[] olds = toIn.GetItem(countX, countY, ip.GetKey().GetGridWidth(), ip.GetKey().GetGridHeight()); ItemPosition old = null; if (olds.Length == 1) { old = olds[0]; if (old != ip) { fr.TempUse(PARA_ITEM, ip); if (old.GetKey().GetKey().Equals(ip.GetKey().GetKey())) { int delta = old.GetKey().GetItemStack() - old.GetCount(); if (delta > 0) { // 堆叠物品 ChangeItemStack(delta, fromIn, toIn, fromUI, toUI, ip, old, args); } else { // 交换物品位置 ExchangeItem(fromIn, toIn, fromUI, toUI, ip, old, args); } } else { if (!ip.DragTo(args, old)) { ExchangeItem(fromIn, toIn, fromUI, toUI, ip, old, args); } else { if (ip.GetInventory() != null) { fromUI.UpdateItem(args, fromIn, ip); } } } fr.Resume(PARA_ITEM); return; } } fr.TempUse(PARA_ITEM, ip); MoveItem(countX, countY, fromIn, toIn, fromUI, toUI, ip, old, args); fr.Resume(PARA_ITEM); }