Пример #1
0
        public void MoveTetromino(MovementDirection direction)
        {
            if (this.fallingTetromino != null && this.gameState == GameState.Running)
            {
                var movingContext = TetrominoMover.GetMoveContext(fallingTetromino, direction, movementSpeed);
                if (!CollisionDetector.CollisionDetected(this.fallingTetromino, this.playfieldInfo.FieldMatrix, movingContext.Positions))
                {
                    TetrominoMover.Move(this.fallingTetromino, this.playfieldInfo.FieldMatrix, movingContext);
                    this.renderer.RenderGameField();
                }
                else
                {
                    if (direction == MovementDirection.Down)
                    {
                        int clearedRowsCount = this.playfieldInfo.ClearFullRows();

                        this.ClearedLinesCount += clearedRowsCount;
                        if (this.clearedLinesCount >= ((this.currentLevel * 10) + 10))
                        {
                            this.CurrentLevel++;

                            int currentTimerInterval = this.frameRenderTimer.Interval.Milliseconds;
                            this.frameRenderTimer.Interval = TimeSpan.FromMilliseconds(currentTimerInterval - 50);
                        }


                        this.AddToScore(ScoringSystem.GetScore(this.currentLevel, clearedRowsCount));
                        this.renderer.RenderGameField();
                        this.DropNewTetromino();
                    }
                }
            }
        }
Пример #2
0
        private bool TryDropNewTetromino()
        {
            Tetromino tetromino = this.nextTetromino != null ? this.nextTetromino : TetrominoGenerator.GenerateRandomTetromino(new PositionInfo(3, 0));

            this.nextTetromino = TetrominoGenerator.GenerateRandomTetromino(new PositionInfo(3, 0));

            var movingContext = TetrominoMover.GetMoveContext(tetromino, MovementDirection.Down, movementSpeed);

            if (!CollisionDetector.CollisionDetected(tetromino, this.playfieldInfo.FieldMatrix, movingContext.Positions))
            {
                this.fallingTetromino = tetromino;
                return(true);
            }
            return(false);
        }
Пример #3
0
        public void Move(MovementDirection direction, int speed)
        {
            var moveContext = TetrominoMover.GetMoveContext(this, direction, speed);

            this.Move(moveContext);
        }