Ejemplo n.º 1
0
 public Piece(Board board, PreviewPiece previewPiece, Point position)
     : base(previewPiece.Color, previewPiece.Model, previewPiece.RotationIndex, Defaults.Board.BlockSize)
 {
     Board = board;
     Position = position;
     CreateGhostBlocks(Model[RotationIndex]);
     Rotate(0);
 }
Ejemplo n.º 2
0
        public PieceGenerator(Board board)
        {
            _board = board;
            _pieces = Defaults.Pieces;
            _randomBag = new RandomBag(_pieces.Length);

            //DeterminePiecesColors();

            _nextPiece = GetRandomPiece();
        }
Ejemplo n.º 3
0
 private Piece ConsumedPiece()
 {
     var resultPiece = _nextPiece;
     _nextPiece = GetRandomPiece();
     return new Piece(_board, resultPiece);
 }
Ejemplo n.º 4
0
 public void SetNextPiece(PreviewPiece piece)
 {
     _nextPiece = piece;
 }
Ejemplo n.º 5
0
 public void ExchangePiece()
 {
     if (TetrisGame.GetInstance().IsRunning && CanExchangePiece)
     {
         // Save Board.CurrentPiece in TemporaryPiece.
         var tempPiece = new PreviewPiece(this, CurrentPiece.Color, CurrentPiece.Model,
                                          CurrentPiece.RotationIndex, CurrentPiece.Position);
         // Save NextPiece to CurrentPiece.
         CurrentPiece = new Piece(this, PieceGenerator.PeekNextPiece(), CurrentPiece.Position);
         // Save TemporaryPiece to NextPiece.
         PieceGenerator.SetNextPiece(tempPiece);
         // Set Flag to Prevent Another Exchange.
         CanExchangePiece = false;
     }
 }