Example #1
0
        public int[] GetNextEmptyPosition(FreeItem item)
        {
            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)
                    {
                        return(new int[] { j, i });
                    }
                }
            }

            return(new int[] { 0, 0 });
        }
Example #2
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);
        }
Example #3
0
 public virtual void Remove()
 {
     for (int i = x; i < x + key.GetGridWidth(); i++)
     {
         for (int j = y; j < y + key.GetGridHeight(); j++)
         {
             inventory.ins[j][i] = false;
         }
     }
     inventory = null;
 }