internal void Initialize(UIInventory uiInventory, InventoryItem item)
        {
            UIInventory = uiInventory;
            Clear();

            item.OccupiedGridPositions_Matrix.GetConnectionMatrix(out bool[,] connectionMatrix, out GridPos offset);
            foreach (GridPos gp in item.OccupiedGridPositions_Matrix)
            {
                gp.GetConnection(connectionMatrix, offset, out GridPosR.OrientationFlag adjacentConnection, out GridPosR.OrientationFlag diagonalConnection);
                GridPos             localGP = gp - item.BoundingRect.position;
                UIInventoryItemGrid grid    = UIInventory.CreateUIInventoryItemGrid(UIInventoryItemGridContainer);
                grid.Initialize(localGP, new GridRect(localGP.x, -localGP.z, UIInventory.GridSize, UIInventory.GridSize), adjacentConnection, diagonalConnection);
                UIInventoryItemGrids.Add(grid);
            }
        }
示例#2
0
        public UIInventoryItemGrid CreateUIInventoryItemGrid(Transform transform)
        {
            if (InstantiateUIInventoryItemGridHandler != null)
            {
                MonoBehaviour mono = InstantiateUIInventoryItemGridHandler?.Invoke(transform);
                if (mono != null)
                {
                    try
                    {
                        UIInventoryItemGrid res = (UIInventoryItemGrid)mono;
                        return(res);
                    }
                    catch (Exception e)
                    {
                        LogError(e.ToString());
                    }
                }
            }

            return(null);
        }