public override RobotState HandleInput(State2DRobotInput.RobotInput input) { if (!input.crouch) { return(new WalkState(_robot)); } input.move = (input.move * CROUCH_SPEED); base.HandleInput(input); return(this); }
private void FlipIfRequired(State2DRobotInput.RobotInput input) { if (input.move > 0 && !_facingRight) { Flip(); } else if (input.move < 0 && _facingRight) { Flip(); } }
public override RobotState HandleInput(State2DRobotInput.RobotInput input) { _robotAnimator.SetBool("Crouch", input.crouch); _robotAnimator.SetFloat("Speed", Mathf.Abs(input.move)); _robot.GetComponent <Rigidbody2D>().velocity = new Vector2(input.move * MAX_SPEED, _robot.GetComponent <Rigidbody2D>().velocity.y); FlipIfRequired(input); if (input.crouch) { return(new CrouchState(_robot)); } return(this); }
public abstract RobotState HandleInput(State2DRobotInput.RobotInput input);
public void UpdateState(State2DRobotInput.RobotInput input) { var newState = _robotState.HandleInput(input); _robotState = newState; }