コード例 #1
0
ファイル: Dash.cs プロジェクト: justawesomegames/dream-state
            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
ファイル: Jump.cs プロジェクト: justawesomegames/dream-state
            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);
                }
            }