Exemplo n.º 1
0
    void PerformNextDownwardMove()
    {
        if (currentBlock == null)
        {
            return;
        }

        bool blockCanKeepMoving = false;
        bool shouldUpdateBoard  = true;

        blockCanKeepMoving = currentBlock.MoveDown(tetrisBoard);
        if (!blockCanKeepMoving)
        {
            if (currentBlock.IsBlockAbovePlayArea(boardSizeY))
            {
                LoseGame();
            }
            tetrisBoard = currentBlock.AddToBoard(tetrisBoard);
            soundEngine.PlaySoundWithName("BlockLand");
            currentBlock = null;
            if (CheckForCompleteLines() || CheckForCompleteColumns())
            {
                gameStepTimer    += lineCompleteHangDuration;
                shouldUpdateBoard = false;
            }
        }

        if (shouldUpdateBoard)
        {
            display.UpdateBoard(tetrisBoard, currentBlock);
        }
    }
Exemplo n.º 2
0
    public void SetNextBlock(TetrisBlock block)
    {
        // Draw the block
        var blockQueueDisplayText = new char[, ] {
            { ' ', ' ', ' ', ' ' },
            { ' ', ' ', ' ', ' ' },
            { ' ', ' ', ' ', ' ' }
        };

        blockQueueDisplayText = block.AddToBoard(blockQueueDisplayText, true);
        var blockQueueText = "";

        for (var x = 0; x < blockQueueDisplayText.GetLength(0); x++)
        {
            for (var y = 0; y < blockQueueDisplayText.GetLength(1); y++)
            {
                var nextText = blockQueueDisplayText[x, y];
                blockQueueText += nextText == ' ' ? ' ' : nextText;
            }
            blockQueueText += "\n";
        }
        if (!blockQueueDisplay)
        {
            Debug.LogWarning(gameObject.name + " blockQueueDisplay Missing");
        }
        else
        {
            blockQueueDisplay.text = blockQueueText;
        }

        //Debug.Log("Adding to board:" + blockQueueText);
    }
Exemplo n.º 3
0
    public void UpdateBoard(char[,] board, TetrisBlock currentBlock)
    {
        var displayBoard = board;

        if (currentBlock != null)
        {
            displayBoard = currentBlock.AddToBoard(board);
        }
        var debugTextStr = "";

        for (var y = displayBoard.GetLength(1) - 1; y >= 0; y--)
        {
            for (var x = 0; x < displayBoard.GetLength(0); x++)
            {
                debugTextStr += displayBoard[x, y];
            }
            debugTextStr += "\n";
        }

        debugText.text        = debugTextStr;
        commandText.text      = "";
        lineCompleteText.text = "";
    }