Пример #1
0
 //TetrisBlock constructor that receives a TetrisBord and block definition: block map and block color
 //Throws block definition exception if a block is defined with more than CELLS cells of block defined
 //out of tetrisBoard bounds
 public TetrisBlock(TetrisCell[,] board, int[,] block, SolidColorBrush color)
 {
     this.board      = board;
     this.block      = block;
     this.BlockColor = color;
     this.BlockID    = TetrisCell.GenerateID();
     CkeckBlockDef(block);
 }
Пример #2
0
        //Compares two Tetris cells by ID and color
        public override bool Equals(object obj)
        {
            if (null == obj || GetType() != obj.GetType())
            {
                return(false);
            }
            TetrisCell other = (TetrisCell)obj;

            return(ID == other.ID && Cell.Fill.Equals(other.Cell.Fill));
        }
Пример #3
0
        //Initializes the tetris cells of the game
        private void InitCells()
        {
            for (int row = 0; row < ROWS; row++)
            {
                for (int col = 0; col < COLUMNS; col++)
                {
                    boardCells[row, col] = new TetrisCell();
                    Grid.SetRow(boardCells[row, col].Cell, row);
                    Grid.SetColumn(boardCells[row, col].Cell, col);
                    boardGrids.Children.Add(boardCells[row, col].Cell);

                    if (row < TetrisBlock.CELLS && col < TetrisBlock.CELLS)
                    {
                        nextBlockCells[row, col] = new TetrisCell();
                        Grid.SetRow(nextBlockCells[row, col].Cell, row);
                        Grid.SetColumn(nextBlockCells[row, col].Cell, col);
                        nextBlockGrids.Children.Add(nextBlockCells[row, col].Cell);
                    }
                }
            }
        }