Ejemplo n.º 1
0
    /*
     * [Gravity Suspension Dash]
     * Cancels all jumps and momentum, and then propels the player in the appointed direction.
     * With conventional WASD-like input, the dash is 8-directional, but does support any direction.
     */
    private void InitiateDash()
    {
        if (!dashAction.IsReady())
        {
            return;
        }
        if (dashAction.IsActive())
        {
            return;                             // Cannot spam dashes.
        }
        if (!canAirDash && _EC.state == EntityMotionState.AIR)
        {
            return;                                                          // If not allowed to air dash while in the air.
        }
        // Set some parameters immediately.
        isJumping            = false;
        allowPlayerInfluence = false;

        // Save the direction the player is holding input on when the dash initiates.
        dashDir = _EC.directionalInfluence;

        // If we do not have any direction inputted for our dash, default to dashing forward.
        if (dashDir == Vector2.zero)
        {
            dashDir = _EC.GetForwardVector();
        }

        // If we are on the ground and we press dash, perform a ground dash instead.
        if (_EC.directionalInfluence.y < 0 && _EC.state == EntityMotionState.GROUNDED)
        {
            dashDir = _EC.GetForwardVector();
        }

        dashAction.StartAction();
    }