/// <summary> /// Moves the Blocks to the Right one Block /// </summary> /// <returns>True, if It moved. False, if it didn't</returns> internal bool MoveRight() { //Find the Most Right Cell const int RIGHT_SIDE = 10; const int MOVE_DISTANCE = 1; int mostRight = 0; Cells mostRightCell = null; foreach (var item in BlockCells) { if (item.CellLocationX >= mostRight) { mostRight = item.CellLocationX; mostRightCell = item; } } //See if I can move right else do nothing if (mostRightCell.CellLocationX + MOVE_DISTANCE < RIGHT_SIDE) { BlockCells.ForEach(x => x.CellLocationX++); return(true); } return(false); }
/// <summary> /// Moves the Blocks to the Left Block /// </summary> /// <returns>True, if It moved. False, if it didn't</returns> internal bool MoveLeft() { //Find the Most Left Cell const int LEFT_SIDE = -1; const int MOVE_DISTANCE = 1; int mostLeft = 9; Cells mostLeftCell = null; foreach (var item in BlockCells) { if (item.CellLocationX <= mostLeft) { mostLeft = item.CellLocationX; mostLeftCell = item; } } //See if I can move right else do nothing if (mostLeftCell.CellLocationX - MOVE_DISTANCE > LEFT_SIDE) { BlockCells.ForEach(x => x.CellLocationX--); return(true); } return(false); }