State UpdateCore(InputType inputType, MoveAmount moveAmount) { var currentTetrimino = data.CurrentTetrimino; switch (inputType) { case InputType.TurnLeft when fieldAnalyzer.CanTurnLeft(currentTetrimino): data.CurrentTetrimino.TurnLeft(); break; case InputType.TurnRight when fieldAnalyzer.CanTurnRight(currentTetrimino): data.CurrentTetrimino.TurnRight(); break; case InputType.Fall: { while (fieldAnalyzer.CanMove(currentTetrimino, 0, -1)) { currentTetrimino.Move(0, -1); } data.Field.SetTetrimino(currentTetrimino.X, currentTetrimino.Y, currentTetrimino.TetriminoColors); return(State.Ground); } case InputType.Move: { var canMove = fieldAnalyzer.CanMove(currentTetrimino, moveAmount.X, moveAmount.Y); if (moveAmount.Y < 0 && !canMove) { data.Field.SetTetrimino(currentTetrimino.X, currentTetrimino.Y, currentTetrimino.TetriminoColors); return(State.Ground); } if (canMove) { currentTetrimino.Move(moveAmount.X, moveAmount.Y); } break; } case InputType.None: break; default: break; } return(State.UserOperation); }
public void Set(InputType input, MoveAmount move) { InputType = input; MoveAmount = move; }