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 (this.gameObject.transform.position.x >= FINISH_LOCATION_X_AXIS) { // PlayerUtility.PlayerAction(body2D, NO_VELOCITY, NO_VELOCITY); // PlayerUtility.ChangeAnimation(animator, IDLE_ANIMATION); // } }
public IEnumerator PlayerAction_Run_No_Jump() { Rigidbody2D body = playerPrefab.GetComponent <Rigidbody2D>(); float yBeforePlayerJumps = playerPrefab.transform.position.x; yield return(null); PlayerUtility.PlayerAction(body, 9f, 0f); float yAfterPlayerJumps = playerPrefab.transform.position.x; if (yAfterPlayerJumps > yBeforePlayerJumps) { yield break; } Assert.Fail(); }
public IEnumerator PlayerAction_Jump() { Rigidbody2D body = playerPrefab.GetComponent <Rigidbody2D>(); float yBeforePlayerJumps = playerPrefab.transform.position.y; yield return(null); PlayerUtility.PlayerAction(body, 9f, 22f); float yAfterPlayerJumps = playerPrefab.transform.position.y; Debug.Log("before: " + yBeforePlayerJumps + " after: " + yAfterPlayerJumps); if (yAfterPlayerJumps > yBeforePlayerJumps) { yield break; } Assert.Fail(); }
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; } }