Exemplo n.º 1
0
 private static void MoveItem(int countX, int countY, ItemInventory fromIn, ItemInventory toIn, IInventoryUI fromUI, IInventoryUI toUI, ItemPosition ip, ItemPosition old, ISkillArgs args)
 {
     if (fromIn.CanMoveTo(ip, toIn, countX, countY))
     {
         fromIn.ChangePosition(ip, toIn, countX, countY);
         HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args);
         if (fromIn == toIn)
         {
             fromUI.UpdateItem(args, fromIn, ip);
         }
         else
         {
             fromUI.DeleteItem(args, fromIn, ip);
             toUI.AddItem(args, toIn, ip);
         }
     }
     else
     {
         fromIn.ChangePosition(ip, fromIn, ip.GetX(), ip.GetY());
         if (fromUI.CanNotMoveAction != null)
         {
             fromUI.CanNotMoveAction.Act(args);
         }
         fromUI.UpdateItem(args, fromIn, ip);
     }
 }
Exemplo n.º 2
0
        public virtual void UseItem(ISkillArgs args, ItemPosition ipos, int count)
        {
            ItemPosition remove = null;
            ItemPosition useIp  = null;

            foreach (ItemPosition ip in posList)
            {
                if (ip.GetX() == ipos.x && ip.GetY() == ipos.y)
                {
                    useIp = ip;
                    if (ip.GetKey().IsConsume())
                    {
                        ip.count = ip.count - count;
                    }
                    if (ip.count <= 0 && ipos.key.IsConsume())
                    {
                        remove = ip;
                    }
                }
            }
            if (remove != null)
            {
                RemoveItemPosition(remove);
            }
            if (inventoryUI != null && ipos.key.IsConsume())
            {
                if (remove != null)
                {
                    inventoryUI.DeleteItem(args, this, remove);
                }
                else
                {
                    if (useIp != null)
                    {
                        inventoryUI.UpdateItem(args, this, useIp);
                    }
                }
            }
            if (inventoryUI != null && useIp != null)
            {
                inventoryUI.UseItem(args, this, useIp);
            }
        }