Ejemplo n.º 1
0
        public void MovePiece(StaticData.MoveType mv)
        {
            // copy the current merge board to the previous merge board.
            // so later in the diff board we will get the correct data, which block we need to update?
            this.CopyMergeToPrevMerge();

            // check which tetromino will be performed, and move the piece
            switch (this.CurrentTetromino)
            {
            case 1:
                this.TetrominoI.Move(mv, this.x, this.y, this.CurrentBoard, this.MergeBoard);
                break;

            case 2:
                this.TetrominoJ.Move(mv, this.x, this.y, this.CurrentBoard, this.MergeBoard);
                break;

            case 3:
                this.TetrominoL.Move(mv, this.x, this.y, this.CurrentBoard, this.MergeBoard);
                break;

            case 4:
                this.TetrominoO.Move(mv, this.x, this.y, this.CurrentBoard, this.MergeBoard);
                break;

            case 5:
                this.TetrominoS.Move(mv, this.x, this.y, this.CurrentBoard, this.MergeBoard);
                break;

            case 6:
                this.TetrominoT.Move(mv, this.x, this.y, this.CurrentBoard, this.MergeBoard);
                break;

            case 7:
                this.TetrominoZ.Move(mv, this.x, this.y, this.CurrentBoard, this.MergeBoard);
                break;
            }
        }
Ejemplo n.º 2
0
        public bool Move(StaticData.MoveType mv, int BoardX, int BoardY, int[,] CurrentBoard, int[,] MergeBoard)
        {
            // first let's copy the CurrentBoard into MergeBoard
            this.CopyBoard(BoardX, BoardY, CurrentBoard, MergeBoard);

            // check for the movement requested by user
            switch (mv)
            {
            case StaticData.MoveType.MoveDown:
                // call the MoveDown function
                return(this.MoveDown(BoardX, BoardY, CurrentBoard, MergeBoard));

            case StaticData.MoveType.MoveLeft:
                // call the MoveLeft function
                return(this.MoveLeft(BoardX, BoardY, CurrentBoard, MergeBoard));

            case StaticData.MoveType.MoveRight:
                // call the MoveRight function
                return(this.MoveRight(BoardX, BoardY, CurrentBoard, MergeBoard));

            default:
                throw new Exception("Invalid move request to the move function on Tetromino Class.");
            }
        }