private void moveShape(String Direction) { var currentColumn = currentBlocks[0].cols; var currentRow = currentBlocks[0].rows; switch (Direction) { case "DOWN": currentRow = currentRow.ConvertAll(i => i + 1); break; case "LEFT": currentColumn = currentColumn.ConvertAll(x => x - 1); break; case "RIGHT": currentColumn = currentColumn.ConvertAll(y => y + 1); break; } currentBlocks.RemoveAt(0); //Type3 test2 = new Type3(); Block moveBlock = ShapeFactory.SetupType(CURRENT_TYPE); for (int i = 0; i < 4; i++) { /* * Rectangle newRect = new Rectangle() * { * Width = 20, * Height = 20, * RadiusX = 2, * RadiusY = 2, * Stroke = Brushes.Black, * Fill = Brushes.Gold, * StrokeThickness = 1, * * }; * newRect.Name = MOVING; */ Rectangle newRect = ShapeFactory.CreateRectangle(moveBlock.color); moveBlock.cols = currentColumn; moveBlock.rows = currentRow; tetrisGrid.Children.Add(newRect); Grid.SetColumn(newRect, currentColumn[i]); Grid.SetRow(newRect, currentRow[i]); } currentBlocks.Add(moveBlock); }
private void setNextShape() { //List<int> colValShape1 = new List<int>(); //List<int> rowValShape1 = new List<int>(); //colValShape1.Add(3); colValShape1.Add(3); colValShape1.Add(3); colValShape1.Add(3); //rowValShape1.Add(1); rowValShape1.Add(2); rowValShape1.Add(3); rowValShape1.Add(4); nextBlockGrid.Children.Clear(); Block currBlock = ShapeFactory.SetupType(NEXT_TYPE); var cols = currBlock.nextCols; var rows = currBlock.nextRows; for (int i = 0; i < 4; i++) { Rectangle testRect = ShapeFactory.CreateRectangle(currBlock.color); nextBlockGrid.Children.Add(testRect); Grid.SetColumn(testRect, cols[i]); Grid.SetRow(testRect, rows[i]); } }
public void rotatePiece() { var currentRow = currentBlocks[0].rows; var currentCol = currentBlocks[0].cols; if (currentBlocks[0].Blocktype.Equals("Type")) { return; } currentBlocks.RemoveAt(0); removeShape(); //Type3 Type3Rotate = new Type3(); Block RotateBlock = ShapeFactory.SetupType(CURRENT_TYPE); RotateBlock.RotateType(rotation, currentRow, currentCol); for (int i = 0; i < 4; i++) { /* * Rectangle newRect = new Rectangle() * { * Width = 20, * Height = 20, * RadiusX = 2, * RadiusY = 2, * Stroke = Brushes.Black, * Fill = Brushes.Gold, * StrokeThickness = 1, * * }; * newRect.Name = MOVING; */ Rectangle newRect = ShapeFactory.CreateRectangle(RotateBlock.color); tetrisGrid.Children.Add(newRect); Grid.SetColumn(newRect, RotateBlock.cols[i]); Grid.SetRow(newRect, RotateBlock.rows[i]); } currentBlocks.Add(RotateBlock); }
private void createShape() { //Type3 test1 = new Type3(); //Type3 test2 = new Type3(); //var cols = test2.cols; //var rows = test2.rows; Block newBlock = ShapeFactory.SetupType(CURRENT_TYPE); var cols = newBlock.cols; var rows = newBlock.rows; for (int i = 0; i < 4; i++) { /* * Rectangle newRect = new Rectangle() * { * Width = 20, * Height = 20, * RadiusX = 2, * RadiusY = 2, * Stroke = Brushes.Black, * Fill = Brushes.Gold, * StrokeThickness = 1, * * }; * newRect.Name = MOVING; */ Rectangle newRect = ShapeFactory.CreateRectangle(newBlock.color); tetrisGrid.Children.Add(newRect); Grid.SetColumn(newRect, cols[i]); Grid.SetRow(newRect, rows[i]); } currentBlocks.Add(newBlock); rotationEnabled = true; rotation = 0; }