Beispiel #1
0
 /// <summary>
 /// Moves the tetromino to down if it's possible and return the changed blocks after movement
 /// If it is not possible to move down, checks for game over and if game has not been over, fixes the tetromino in deck and checks for rows to vanish
 /// </summary>
 /// <returns></returns>
 public MoveDownResult MoveDown()
 {
     if (!CanMoveDown())
     {
         if (GameOver())
         {
             return(new MoveDownResult {
                 GameOver = true
             });
         }
         deck.FixBlocks(VisibleBlocks);
         var currentTetrominosRows = VisibleBlocks.Select(s => s.Y).Distinct().ToArray();
         var vanishRowResult       = deck.VanishRows(currentTetrominosRows);
         return(new MoveDownResult
         {
             VanishRowResult = vanishRowResult
         });
     }
     else
     {
         var inversedBlocks = InverseVisibleBlocks();
         foreach (var block in Blocks)
         {
             block.MoveDown();
         }
         var changedBlocks = AddVisibleBlocksToChangedBlocks(inversedBlocks);
         return(new MoveDownResult {
             ChangedBlocks = changedBlocks
         });
     }
 }