示例#1
0
            private void DoDash(FacingDir dir)
            {
                if (inDashCooldown)
                {
                    return;
                }

                if (wallStick != null && wallStick.Doing)
                {
                    return;
                }

                if (!physics.Grounded)
                {
                    if (!canAirDash || didAirDash)
                    {
                        return;
                    }
                    horizontalMovement.SetSpeed(dashSpeed);
                }

                StartCoroutine(DashCooldown());
                ChangeState(AbilityStates.Doing);
                curDashTime = 0.0f;
                dashDir     = dir;
            }
示例#2
0
            public virtual void OnJumpPress()
            {
                if (wasWallStickingLeft || wasWallStickingRight)
                {
                    StartCoroutine(HandleWallJumpAcceleration());
                    Vector2 vWallJump = wallJump;
                    if (dash != null && dash.HoldingDash)
                    {
                        vWallJump = dashWallJump;
                        if (horizontalMovement != null)
                        {
                            horizontalMovement.SetSpeed(dash.DashSpeed);
                        }
                    }
                    var dir = Mathf.Sign(physics.TargetVelocity.x);
                    if (faceable != null)
                    {
                        dir = faceable.CurFacingDir() == FacingDir.Right ? 1 : -1;
                    }
                    physics.SetVelocity(new Vector2(-(vWallJump.x * dir), vWallJump.y));
                    wasWallStickingLeft = wasWallStickingRight = false;
                    return;
                }

                var grounded = physics.Grounded;

                // Handle jumping from ground
                if (grounded || canCoyoteJump)
                {
                    physics.SetVelocityY(jumpForce);
                    return;
                }

                // Handle double jumping
                if (canDoubleJump && !grounded && !didDoubleJump)
                {
                    didDoubleJump = true;
                    physics.SetVelocityY(doubleJumpForce);
                }
            }