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
 private static void ExchangeItem(ItemInventory fromIn, ItemInventory toIn, IInventoryUI fromUI, IInventoryUI toUI, ItemPosition ip, ItemPosition old, ISkillArgs args)
 {
     if (fromIn.CanExchange(old, ip) && fromIn.IsCanDrop(old, args))
     {
         fromIn.ExchangeItemPosition(old, ip);
         HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args, true);
         HandleMoveAction(toIn, fromIn, toUI, fromUI, old, args, true);
         HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args, false);
         HandleMoveAction(toIn, fromIn, toUI, fromUI, old, args, false);
         if (fromIn == toIn)
         {
             fromUI.UpdateItem(args, fromIn, old);
             fromUI.UpdateItem(args, fromIn, ip);
         }
         else
         {
             fromUI.AddItem(args, fromIn, old);
             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.º 3
0
        private bool AddNewItem(ISkillArgs args, FreeItem item, bool useMove)
        {
            for (int i = 0; i <= row - item.GetGridHeight(); i++)
            {
                for (int j = 0; j <= column - item.GetGridWidth(); j++)
                {
                    bool filled = false;
                    for (int ii = i; ii < i + item.GetGridHeight(); ii++)
                    {
                        for (int jj = j; jj < j + item.GetGridWidth(); jj++)
                        {
                            if (ins[ii][jj])
                            {
                                filled = true;
                            }
                        }
                    }
                    if (!filled)
                    {
                        ItemPosition ip = new ItemPosition(item, j, i);
                        ip.inventory = this;
                        posList.Add(ip);
                        for (int ii_1 = i; ii_1 < i + item.GetGridHeight(); ii_1++)
                        {
                            for (int jj = j; jj < j + item.GetGridWidth(); jj++)
                            {
                                ins[ii_1][jj] = true;
                            }
                        }
                        if (inventoryUI != null && args != null)
                        {
                            inventoryUI.AddItem(args, this, ip);
                        }
                        //if ("default".Equals(name))
                        //{
                        args.TempUsePara(new StringPara("inventory", name));
                        item.Added(args);
                        if (inventoryUI != null && inventoryUI.MoveAction != null && useMove)
                        {
                            args.TempUsePara(new StringPara("to", this.name));
                            args.TempUse("item", ip);

                            inventoryUI.MoveAction.Act(args);

                            args.Resume("item");
                            args.ResumePara("to");
                        }
                        args.ResumePara("inventory");
                        //}
                        return(true);
                    }
                }
            }
            if (inventoryUI != null)
            {
                inventoryUI.Error(args, this, "物品栏已满");
            }
            return(false);
        }