public void Draw(Rect gameBoardRect) { UpdateBoardLayout(gameBoardRect); for (int row = GHOST_ROW_COUNT; row < gameBoardRows; ++row) { for (int col = 0; col < gameBoardCols; ++col) { // The board tile data should be starting after the ghost rows, // but the Rect should start at row = 0 so subtract back the ghost row count // for the Rect calculation only. Rect checkboxRect = new Rect( xLeftOffset + col * BLOCK_PIXEL_SIZE, yTopOffset + (row - GHOST_ROW_COUNT) * BLOCK_PIXEL_SIZE, BLOCK_PIXEL_SIZE, BLOCK_PIXEL_SIZE ); BoardTile tile = gameBoard[Index(col, row, gameBoardCols)]; bool currentPieceHit = null == currentPiece ? false : currentPiece.IsHit(col, row); if (tile.isFilled) { GUI.color = tile.color; } else if (currentPieceHit) { GUI.color = currentPiece.color; } //EditorGUI.LabelField(blockRect, "", EditorStyles.helpBox); //GUI.color = Color.white; bool tileState = tile.isFilled || currentPieceHit; bool newTileState = EditorGUI.Toggle(checkboxRect, tileState); if (newTileState != tileState) { SetInfoMessage("Cheater! >_<", new Color(1, 0.5f, 1, 1), 10); tile.isFilled = newTileState; tile.color = Color.magenta; ClearFullRows(); } GUI.color = Color.white; } } }
public ValidityResult IsValidPosition(EdtrisPiece piece) { for (int row = piece.row; row < piece.row + 4; ++row) { for (int col = piece.col; col < piece.col + 4; ++col) { if (piece.IsHit(col, row)) { if (col >= gameBoardCols || col < 0 || row >= gameBoardRows || row < 0) { return(ValidityResult.OutOfBounds); } if (gameBoard[Index(col, row, gameBoardCols)].isFilled) { return(ValidityResult.IntersectsBlock); } } } } return(ValidityResult.Valid); }