示例#1
0
    // This stashes the current block and returns the next current block.
    TetrisBlock StashCurrentBlock()
    {
        // If there is no current block, then we can't do any stashing.
        if (currentBlock == null)
        {
            return(currentBlock);
        }

        // If there's a stashed block, switch it and the current block.
        if (stashedBlock != null)
        {
            var retBlock = stashedBlock;
            retBlock.SetPosition(currentBlock.GetPositionX(), currentBlock.GetPositionY());
            stashedBlock = currentBlock;
            stashBlockDisplay.SetNextBlock(stashedBlock);
            currentBlock = retBlock;
            return(currentBlock);
        }
        else
        {
            // Otherwise, put the current block in the stash and get the next block
            stashedBlock = currentBlock;
            stashBlockDisplay.SetNextBlock(stashedBlock);
            UpdateNextBlocks();
            return(currentBlock);
        }
    }