Exemplo n.º 1
0
 public void PlayerJump()
 {
     if (PlayerUtility.CanJump(onGround, true))
     {
         PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, JUMPING_VELOCITY);
         body2D.AddForce((Vector2.right * RUNNING_VELOCITY) * THRUST);
     }
 }
Exemplo n.º 2
0
    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;
        }
    }
Exemplo n.º 3
0
 public void Player_Doesnt_Jump_When_Not_onGround()
 {
     Assert.AreNotEqual(true, PlayerUtility.CanJump(false, true));
 }
Exemplo n.º 4
0
 public void Player_Jumps_When_onGround_And_Space_Is_Pressed()
 {
     Assert.AreEqual(true, PlayerUtility.CanJump(true, true));
 }
Exemplo n.º 5
0
 public void Player_Doesnt_Jump_When_Space_Is_Not_Pressed()
 {
     Assert.AreNotEqual(true, PlayerUtility.CanJump(true, false));
 }