protected void InitHighlights() { PieceDimension.Row[] columns = PieceInfo.Columns; if (columns == null) { return; } float width = 1f; List <PieceHighlight> attachedHighlights = new List <PieceHighlight>(); for (int y = 0; y < columns.Length; y++) { bool[] rowItems = columns[y].RowBools; if (rowItems == null) { continue; } for (int x = 0; x < rowItems.Length; x++) { if (!rowItems[x]) { continue; } Vector2Int drawOffset = PieceInfo.GetRelativeIndex(x, y); Vector3 cubePosition = transform.localPosition; cubePosition += new Vector3(drawOffset.x * width, 0f, drawOffset.y); PieceHighlight thisHighlight = PieceHighlightHolder.InstantiateChild <PieceHighlight>(PieceHighlightPrefab.gameObject); thisHighlight.transform.localPosition = cubePosition; attachedHighlights.Add(thisHighlight); } } CurrentHighlights = attachedHighlights.ToArray(); UpdateHits(); }
public List <Vector2Int> GetRelativeLocationFromPoint(int x, int y, RotationDirection direction) { List <Vector2Int> relativeLocations = new List <Vector2Int>(); PieceDimension rotatedPieceLocations = GetRotatedPieceDimension(PieceInfo, direction); for (int i = 0; i < rotatedPieceLocations.PieceDimensions.GetLength(0); i++) { for (int k = 0; k < rotatedPieceLocations.PieceDimensions.GetLength(1); k++) { if (!rotatedPieceLocations.PieceDimensions[i, k]) { continue; } Vector2Int offsetLocation = rotatedPieceLocations.GetRelativeIndex(i, k); relativeLocations.Add(new Vector2Int(x + offsetLocation.x, y + offsetLocation.y)); } } return(relativeLocations); }