Ejemplo n.º 1
0
    public bool MinusId(int id, int count = 1)
    {
        inventoryitemgrid grid = null;

        foreach (inventoryitemgrid temp in itemGridList)
        {
            if (temp.id == id)
            {
                grid = temp; break;
            }
        }

        if (grid == null)
        {
            return(false);
        }
        else
        {
            bool isSucccess = grid.MinusNumber(count);
            return(isSucccess);
        }
    }
Ejemplo n.º 2
0
 protected override void OnDragDropRelease(GameObject surface)
 {
     base.OnDragDropRelease(surface);
     if (surface != null)
     {
         if (surface.tag == tags.inventot_item_Grid)
         {
             if (surface == this.transform.parent.gameObject)
             {
                 //resetPoisition();
             }
             else
             {
                 inventoryitemgrid oldParent = this.transform.parent.GetComponent <inventoryitemgrid>();
                 this.transform.parent = surface.transform;
                 //resetPoisition();
                 inventoryitemgrid newParent = surface.GetComponent <inventoryitemgrid>();
                 newParent.selid(oldParent.id, oldParent.num);
                 oldParent.clearInfo();
             }
         }
         else if (surface.tag == tags.inventot_item)
         {
             inventoryitemgrid grid1 = this.transform.parent.GetComponent <inventoryitemgrid>();
             inventoryitemgrid grid2 = surface.transform.parent.GetComponent <inventoryitemgrid>();
             int id = grid1.id; int num = grid1.num;
             grid1.selid(grid2.id, grid2.num);
             grid2.selid(id, num);
         }
         else if (surface.tag == tags.shortcut)
         {
             surface.GetComponent <shortcutgrid>().SetInventory(id);
         }
     }
     resetPoisition();
 }
Ejemplo n.º 3
0
    public void GetId(int id, int count = 1)
    {
        //第一步 查找所有物品中是否存在
        //第二步 如果存在,让物品加一
        //第三 如果不存在  查找空的方格
        inventoryitemgrid grid = null;

        foreach (inventoryitemgrid temp in itemGridList)
        {
            if (temp.id == id)
            {
                grid = temp; break;
            }
        }

        if (grid != null)
        {
            grid.plusNumber(count);
        }
        else
        {
            foreach (inventoryitemgrid temp in itemGridList)
            {
                if (temp.id == 0)
                {
                    grid = temp; break;
                }
            }
            if (grid != null)
            {
                GameObject itemGo = NGUITools.AddChild(grid.gameObject, inventoryItem);
                itemGo.transform.localPosition = Vector3.zero;
                grid.selid(id, count);
            }
        }
    }