/// <summary> /// rotate figure by 90 degree /// </summary> /// <param name="gameField">game field</param> public void Rotate(TypeOfCell[,] gameField) { //check for square if (TypeOfCell == TypeOfCell.StaticO) { return; } //copy array var position = new Point[4]; Array.Copy(Position, position, Position.Length); //find new points for (int index = 1; index < 4; index++) { var point = FindNewShift(Position[0], Position[index]); Position[index] = point; } //if the final figure can't be entered in game filed then reset if (IsCorrect(gameField) == false) { Array.Copy(position, Position, Position.Length); } else { ChangeFigurePosition.Invoke(); } }
/// <summary> /// Move figure right /// </summary> /// <param name="gameField">game field</param> public void MoveRight(TypeOfCell[,] gameField) { for (var index = 0; index < Position.Length; index++) { Position[index].X++; } if (IsCorrect(gameField) == false) { for (var index = 0; index < Position.Length; index++) { Position[index].X--; } } else { ChangeFigurePosition.Invoke(); } }