示例#1
0
        public void Init(UIInventory uiInventory, UnityAction <UIInventoryItem> onHoverUIInventoryItem = null, UnityAction <UIInventoryItem> onHoverEndUIInventoryItem = null)
        {
            UIInventory               = uiInventory;
            OnHoverUIInventoryItem    = onHoverUIInventoryItem;
            OnHoverEndUIInventoryItem = onHoverEndUIInventoryItem;
            UIInventoryDragAreaIndicator.Init(uiInventory);
            UIInventory.UIInventoryPanel = this;

            UIInventoryTitle.text = uiInventory.InventoryName;
            UIInventoryDragMoveHandle.EnableScreenClamp          = uiInventory.EnableScreenClamp;
            ((RectTransform)UIInventoryTitleContainer).sizeDelta = new Vector2(uiInventory.GridSize * UIInventory.Columns, ((RectTransform)UIInventoryTitleContainer).sizeDelta.y);
            ((RectTransform)Container).sizeDelta = new Vector2(uiInventory.GridSize * UIInventory.Columns, uiInventory.GridSize * UIInventory.Rows);

            ItemContainerGridLayout.constraintCount = uiInventory.Columns;
            ItemContainerGridLayout.cellSize        = new Vector2(uiInventory.GridSize, uiInventory.GridSize);

            uiInventoryGridMatrix = new UIInventoryGrid[UIInventory.Columns, UIInventory.Rows];
            for (int row = 0; row < UIInventory.Rows; row++)
            {
                for (int col = 0; col < UIInventory.Columns; col++)
                {
                    UIInventoryGrid bg = UIInventory.CreateUIInventoryGrid(UIInventoryGridContainer);
                    bg.Init(UIInventory.InventoryGridMatrix[col, row], new GridPos(col, row));
                    uiInventoryGridMatrix[col, row] = bg;
                }
            }

            UIInventory.OnAddItemSucAction    = OnAddItemSuc;
            UIInventory.OnRemoveItemSucAction = OnRemoveItemSuc;
            uiInventory.RefreshInventoryGrids();
        }
示例#2
0
        public void Initialize(UIInventory uiInventory, InventoryItem inventoryItem, UnityAction onHoverAction, UnityAction onHoverEndAction)
        {
            UIInventory = uiInventory;
            SetInventoryItem(inventoryItem);
            OnHoverAction    = onHoverAction;
            OnHoverEndAction = onHoverEndAction;

            RefreshView();
        }
        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);
            }
        }
 public void AddInventory(UIInventory uiInventory)
 {
     UIInventoryDict.Add(uiInventory.InventoryName, uiInventory);
 }
 public void Init(UIInventory uiInventory)
 {
     UIInventory   = uiInventory;
     DragProcessor = DragManager.Instance.GetDragProcessor <UIInventoryItem>();
 }