Ejemplo n.º 1
0
        public void Update()
        {
            if (piece.Move(Direction.Down))
            {
                this.DeletedRowNum = 0;
                return;
            }

            int deletedRowNum;

            field.Update(out deletedRowNum);
            this.DeletedRowNum = deletedRowNum;

            if (piece.Y <= 0)
            {
                this.IsGameOver = true;
                return;
            }

            // Get the next piece
            var nextPiece = pieceQueue.Dequeue();

            nextField.RemovePiece(nextPiece);

            nextPiece.Field = this.field;
            nextPiece.X     = this.field.COLS / 2;
            nextPiece.Y     = 0;
            this.piece      = nextPiece;

            nextPiece = createPiece(nextField, nextField.COLS / 2, nextField.ROWS / 2);
            pieceQueue.Enqueue(nextPiece);
            nextField.Draw();
        }
Ejemplo n.º 2
0
        public bool Move(Direction direction)
        {
            Field.RemovePiece(this);
            bool moved = false;

            if (canMove(direction))
            {
                Mover.Move(ref pos, direction);
                moved = true;
            }

            Field.PutPiece(this);
            Field.Draw();
            return(moved);
        }
Ejemplo n.º 3
0
        public bool Rotate(RtDirection direction)
        {
            Field.RemovePiece(this);
            bool rotated = false;

            if (canRotate(direction))
            {
                Rotator.Rotate(Shape, direction);
                rotated = true;
            }

            Field.PutPiece(this);
            Field.Draw();
            return(rotated);
        }
Ejemplo n.º 4
0
        public Board(Field field, Field nextField)
        {
            this.IsGameOver = false;
            this.field = field;
            this.nextField = nextField;
            pieceQueue = new Queue<Piece>();

            this.rand = new Random();

            this.piece = createPiece(field, field.COLS / 2, 0);

            var nextPiece = createPiece(nextField, nextField.COLS / 2, nextField.ROWS / 2);
            pieceQueue.Enqueue(nextPiece);
            nextField.Draw();
        }
Ejemplo n.º 5
0
        public Board(Field field, Field nextField)
        {
            this.IsGameOver = false;
            this.field      = field;
            this.nextField  = nextField;
            pieceQueue      = new Queue <Piece>();

            this.rand = new Random();

            this.piece = createPiece(field, field.COLS / 2, 0);

            var nextPiece = createPiece(nextField, nextField.COLS / 2, nextField.ROWS / 2);

            pieceQueue.Enqueue(nextPiece);
            nextField.Draw();
        }