Example #1
0
        private TetrisPiece MakeRandomPiece()
        {
            int         pieceIndex     = _random.Next(_prototypePieces.Length);
            TetrisPiece prototypePiece = _prototypePieces[pieceIndex];
            TetrisPiece piece          = (TetrisPiece)prototypePiece.Clone();

            piece.Color = _colorFactory.MakeRandomColor();
            RotatePieceRandomly(piece);

            return(piece);
        }
Example #2
0
        public TetrisState GetState()
        {
            TetrisState state = new TetrisState(Rows, Columns);

            FixedBricksLogic.CopyFixedBricksInState(state);
            if (CurrentPiece != null)
            {
                state.CurrentPiece = (TetrisPieceWithPosition)CurrentPiece.Clone();
            }
            state.NextPiece = (TetrisPiece)NextPiece.Clone();
            return(state);
        }