private void HighlightGrid(Grid grid, GridHighlight highlightType) { for (var i = 0; i < grid.Size.Width; i++) { for (var j = 0; j < grid.Size.Height; j++) { if (grid.Weight[i, j] > 0) { HighlightCell(i, j, highlightType); } } } }
private void HighlightCell(int x, int y, GridHighlight type) { if (x < 0 || x >= _grid.Size.Width || y < 0 || y >= _grid.Size.Height) { return; } if (_gridCells[x, y] == null) { return; } _gridCells[x, y].Highlight = type; }
void Start() { grid = GetComponent <RectTransform>(); hover = new GridHighlight(this); objects = new Dictionary <OccupiedSlot, Highlight>(); GRID_SIZE = (grid.rect.width - inventory.WIDTH - 1) / inventory.WIDTH; foreach (OccupiedSlot slot in inventory.items) { AddItem(slot); } inventory.OnItemAdded.AddListener(AddItem); inventory.OnItemRemoved.AddListener(RemoveItem); }
private void HighlightCell(int x, int y, GridHighlight type) { if (x < 0 || x >= _grid.Size.Width || y < 0 || y >= _grid.Size.Height) return; if (_gridCells[x, y] == null) return; _gridCells[x, y].Highlight = type; }