private void HandleJump() { if (ShouldPlayerJump()) { playerRigidBody.freezeRotation = true; _jumpReady = false; _isJumping = true; if (IsBackJump()) { _jumpKind = JumpKind.Backward; playerRigidBody.AddForce(Vector3.up * (jumpHeight * 0.75f), ForceMode2D.Impulse); } else if (IsNormalJump()) { _jumpKind = JumpKind.Normal; playerRigidBody.AddForce(Vector3.up * (jumpHeight * 0.95f), ForceMode2D.Impulse); } else if (IsBigJump()) { _jumpKind = JumpKind.Forward; playerRigidBody.AddForce(Vector3.up * (jumpHeight * 1.1f), ForceMode2D.Impulse); } } }
private void NormalizeSpeed() { if (transform.position.x < _playerInitialPosition - 0.4) { Accelerate(); _jumpKind = JumpKind.Normal; } else if (transform.position.x > _playerInitialPosition + 0.4) { SlowDown(); _jumpKind = JumpKind.Backward; } else { GameManager.Instance.SetNormalPlayerSpeed(); _jumpKind = JumpKind.Normal; } }
private void HandleMovement() { if (ShouldPlayerAccelerate()) { Accelerate(); _jumpKind = JumpKind.Forward; } else if (ShouldPlayerSlowDown()) { SlowDown(); _jumpKind = JumpKind.Backward; } else if (ShouldPlayerMaintainSpeed()) { } else { NormalizeSpeed(); } }
public Jump(JumpKind kind) { this.Kind = kind; }