public void CurrentTetrominoMovDown() { Point position = currentTetromino.GetCurrentPosition(); Point[] shape = currentTetromino.GetCurrentShape(); bool move = true; CurrentTetrominoErase(); foreach (Point S in shape) { if (((int)(S.Y + position.Y) + 2 + 1) >= rows) { move = false; } else if (blockControls[((int)(S.X + position.X) + ((cols / 2) - 1)), (int)(S.Y + position.Y) + 2 + 1].Background != noBrush) { move = false; } } if (move) { currentTetromino.MovDown(); CurrentTetroMinoDraw(); } else { CurrentTetroMinoDraw(); CheckRow(); currentTetromino = new TetroMino(); } }
public Board(Grid TetrisGrid) { rows = TetrisGrid.RowDefinitions.Count; cols = TetrisGrid.ColumnDefinitions.Count; score = 0; linesFilled = 0; blockControls = new Label[cols, rows]; for (int i = 0; i < cols; i++) { for (int j = 0; j < rows; j++) { blockControls[i, j] = new Label(); blockControls[i, j].Background = noBrush; blockControls[i, j].BorderBrush = silverBrush; blockControls[i, j].BorderThickness = new Thickness(1, 1, 1, 1); Grid.SetRow(blockControls[i, j], j); Grid.SetColumn(blockControls[i, j], i); TetrisGrid.Children.Add(blockControls[i, j]); } } currentTetromino = new TetroMino(); CurrentTetroMinoDraw(); }