public void Jump()
        {
            if (player.CheckState(StateLabels.IsKnockedBack))
            {
                return;
            }
            if (!player.HasTrait(PlayerTraits.Traits.CanJump))
            {
                return;
            }

            if (state == States.StompMode)
            {
                return;
            }

            player.SetState(StateLabels.IsJumping, true);
            player.SetState(StateLabels.IsStomping, false);
            state = States.JumpMode;
            player.AnimationHandler.Play(AnimationNames.Jump);
            jumpTimer = 0f;

            float velocity = JumpVelocity * player.GetPlayerState().GetFloat(StateLabels.TerrainBounciness);

            if (player.CheckState(StateLabels.IsInGravityField))
            {
                gravity.AddVelocityInField(new Vector2(body.velocity.x, velocity));
            }
            else
            {
                body.velocity = new Vector2(body.velocity.x, velocity);
                gravity.SetTargetVelocity(velocity * 0.5f);
            }
        }
Ejemplo n.º 2
0
        public void StartBoost()
        {
            if (!CanBoost)
            {
                return;
            }

            state         = States.Boosting;
            body.velocity = new Vector2(body.velocity.x, BoostPower * 0.7f);
            gravity.SetTargetVelocity(BoostPower);
            player.SetState(StateLabels.IsBoosting, true);
            player.GetEffect <BoostEffect>().Play();
            isRecharging = false;
        }