private void MoveDown() { if (mBlockPattern == null) { return; } Debug.Log("MoveDown"); var pattern = mBlockPattern.PatternType; var blockGroup = mBlockPattern.BlockNodes; var newBlocks = new BlockNode[4]; //觸底或是下方有別的方塊 if (mTetrisGrid.IsGround(blockGroup) || mTetrisGrid.IsBlock(blockGroup, (int)MoveDirection.Down)) { SetBlocksType(blockGroup, BlockNode.BlockType.Stuck); mBlockPattern = null; Debug.LogWarning("Can't move down"); } else { var oldBlocks = mBlockPattern.BlockNodes; ClearBlockStatus(oldBlocks); for (int i = 0; i < blockGroup.Length; i++) { newBlocks[i] = mTetrisGrid.GetNode(blockGroup[i].X, blockGroup[i].Y + 1); } mBlockPattern.SetBlockNodes(newBlocks); SetView(mBlockPattern); } }
private void CreateNewPattern() { mBlockPattern = new BlockPattern(); var blockGroup = GetBlockGroup(mBlockPattern.PatternType); mBlockPattern.SetBlockNodes(blockGroup); SetView(mBlockPattern); }