public void PlayerJump() { if (PlayerUtility.CanJump(onGround, true)) { PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, JUMPING_VELOCITY); body2D.AddForce((Vector2.right * RUNNING_VELOCITY) * THRUST); } }
void Update() { if (onGround) { PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, NO_VELOCITY); PlayerUtility.ChangeAnimation(animator, RUNNING_ANIMATION); } if (PlayerUtility.CanJump(onGround, Input.GetKey(SPACE))) { PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, JUMPING_VELOCITY); body2D.AddForce((Vector2.right * RUNNING_VELOCITY) * THRUST); } if (player.transform.position.x >= FINISH_LOCATION_X_AXIS) { PlayerUtility.PlayerAction(body2D, NO_VELOCITY, NO_VELOCITY); PlayerUtility.ChangeAnimation(animator, IDLE_ANIMATION); txt.text = LEVEL_COMPLETE_MESSAGE; } }
public void Player_Doesnt_Jump_When_Not_onGround() { Assert.AreNotEqual(true, PlayerUtility.CanJump(false, true)); }
public void Player_Jumps_When_onGround_And_Space_Is_Pressed() { Assert.AreEqual(true, PlayerUtility.CanJump(true, true)); }
public void Player_Doesnt_Jump_When_Space_Is_Not_Pressed() { Assert.AreNotEqual(true, PlayerUtility.CanJump(true, false)); }