/// <summary> /// 返回合适的格子 /// </summary> /// <returns></returns> public UGUI.Package.Grid FindSuitableGrid(int weight) { foreach (GameObject g in grids) { UGUI.Package.Grid grid = g.GetComponent <UGUI.Package.Grid>(); if (!grid.Isfilled() && !grid.IsOverWeight(weight)) { return(grid); } } return(null); }
/// <summary> /// 将itemDatabase中相应id的物品按顺序添加到装备栏中 /// </summary> /// <param name="_id"></param> public bool AddItem(Item item) { if (item == null) { return(false); } UGUI.Package.Grid grid = FindSuitableGrid(item.Weight); if (grid == null) { Debug.LogWarning("没有空的物品槽"); return(false); } else { grid.AddItem(item); return(true); } }