Exemple #1
0
    public void ApplyForces(MoveInfo move)
    {
        //if (myControlsScript.debugger != null) myControlsScript.debugger.text = "";
        //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "IsGrounded = " + IsGrounded() + "\n";
        //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "verticalForce = " + verticalForce + "\n";
        //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "verticalTotalForce = " + verticalTotalForce + "\n";
        //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "normalizedJumpArc = " + myControlsScript.normalizedJumpArc + "\n";
        //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "isGroundBouncing = " + isGroundBouncing + "\n";
        //if (myControlsScript.debugger != null && myControlsScript.storedMove != null) myControlsScript.debugger.text += "myControlsScript.storedMove = " + myControlsScript.storedMove.name + "\n";
        //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "myControlsScript.currentHitAnimation = " + myControlsScript.currentHitAnimation + "\n";
        //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "isWallBouncing = " + isWallBouncing + "\n";
        //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "IsJumping = " + IsJumping() + "\n";
        //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "isTakingOff = " + isTakingOff + "\n";

        if (freeze)
        {
            return;
        }

        myControlsScript.normalizedJumpArc = 1 - ((verticalForce + verticalTotalForce) / (verticalTotalForce * 2));

        float appliedFriction = (moveDirection != 0 || myControlsScript.myInfo.physics.highMovingFriction) ?
                                UFE.config.selectedStage.groundFriction : myControlsScript.myInfo.physics.friction;


        if (move != null && move.ignoreFriction)
        {
            appliedFriction = 0;
        }

        if (myControlsScript.activePullIn != null)
        {
            transform.position = Vector3.Lerp(transform.position,
                                              myControlsScript.activePullIn.position,
                                              Time.fixedDeltaTime * myControlsScript.activePullIn.speed);

            if (myControlsScript.activePullIn.forceStand && !IsGrounded())
            {
                ForceGrounded();
            }

            if (Vector3.Distance(myControlsScript.activePullIn.position, transform.position) <= myControlsScript.activePullIn.targetDistance ||
                myControlsScript.currentSubState != SubStates.Stunned)
            {
                myControlsScript.activePullIn = null;
            }

            //if (transform.position.z != 0) transform.Translate(new Vector3(0, 0, -transform.position.z));
        }
        else
        {
            if (!IsGrounded())
            {
                appliedFriction = 0;
                if (verticalForce == 0)
                {
                    verticalForce = -.1f;
                }
            }

            if (horizontalForce != 0 && !isTakingOff)
            {
                if (horizontalForce > 0)
                {
                    horizontalForce -= appliedFriction * Time.fixedDeltaTime;
                    horizontalForce  = Mathf.Max(0, horizontalForce);
                }
                else if (horizontalForce < 0)
                {
                    horizontalForce += appliedFriction * Time.fixedDeltaTime;
                    horizontalForce  = Mathf.Min(0, horizontalForce);
                }

                Vector3 cameraLeftBounds  = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, -Camera.main.transform.position.z));
                Vector3 cameraRightBounds = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, -Camera.main.transform.position.z));
                cameraLeftBounds.x  = Camera.main.transform.position.x - (UFE.config.cameraOptions.maxDistance / 2);
                cameraRightBounds.x = Camera.main.transform.position.x + (UFE.config.cameraOptions.maxDistance / 2);

                bool bouncingOnCamera = false;
                if (myControlsScript.currentHit != null &&
                    myControlsScript.currentHit.bounceOnCameraEdge &&
                    (transform.position.x <= cameraLeftBounds.x ||
                     transform.position.x >= cameraRightBounds.x))
                {
                    bouncingOnCamera = true;
                }


                if (wallBounceTimes < UFE.config.wallBounceOptions.maximumBounces &&
                    myControlsScript.currentSubState == SubStates.Stunned &&
                    myControlsScript.currentState != PossibleStates.Down &&
                    UFE.config.wallBounceOptions.bounceForce != Sizes.None &&
                    Mathf.Abs(horizontalForce) >= UFE.config.wallBounceOptions.minimumBounceForce &&
                    (transform.position.x <= UFE.config.selectedStage.leftBoundary ||
                     transform.position.x >= UFE.config.selectedStage.rightBoundary || bouncingOnCamera) &&
                    myControlsScript.currentHit != null && myControlsScript.currentHit.wallBounce &&
                    !isWallBouncing)
                {
                    //if (!UFE.config.wallBounceOptions.bounceHitBoxes) myHitBoxesScript.HideHitBoxes(true);
                    if (myControlsScript.currentHit.overrideForcesOnWallBounce)
                    {
                        if (myControlsScript.currentHit.resetWallBounceHorizontalPush)
                        {
                            horizontalForce = 0;
                        }
                        if (myControlsScript.currentHit.resetWallBounceVerticalPush)
                        {
                            verticalForce = 0;
                        }

                        float addedH = -myControlsScript.currentHit.wallBouncePushForce.x;
                        float addedV = myControlsScript.currentHit.wallBouncePushForce.y;

                        AddForce(new Vector2(addedH, addedV), myControlsScript.mirror);
                    }
                    else
                    {
                        if (UFE.config.wallBounceOptions.bounceForce == Sizes.Small)
                        {
                            horizontalForce /= -1.4f;
                        }
                        else if (UFE.config.wallBounceOptions.bounceForce == Sizes.Medium)
                        {
                            horizontalForce /= -1.2f;
                        }
                        else if (UFE.config.wallBounceOptions.bounceForce == Sizes.High)
                        {
                            horizontalForce *= -1;
                        }
                    }

                    wallBounceTimes++;

                    if (verticalForce > 0 || !IsGrounded())
                    {
                        if (myMoveSetScript.basicMoves.airWallBounce.clip1 != null)
                        {
                            //myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.airWallBounce);
                            myControlsScript.currentHitAnimation = myMoveSetScript.basicMoves.airWallBounce.name;
                        }
                    }
                    else
                    {
                        if (myControlsScript.currentHit.knockOutOnWallBounce)
                        {
                            myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.standingWallBounceKnockdown);
                            myControlsScript.currentHitAnimation = myMoveSetScript.basicMoves.standingWallBounceKnockdown.name;
                        }
                        else
                        {
                            myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.standingWallBounce);
                            myControlsScript.currentHitAnimation = myMoveSetScript.basicMoves.standingWallBounce.name;
                        }
                    }

                    if (UFE.config.wallBounceOptions.bouncePrefab != null)
                    {
                        GameObject pTemp = (GameObject)Instantiate(UFE.config.wallBounceOptions.bouncePrefab);
                        pTemp.transform.parent        = transform;
                        pTemp.transform.localPosition = Vector3.zero;
                        Destroy(pTemp, UFE.config.wallBounceOptions.bounceKillTime);
                    }

                    if (UFE.config.wallBounceOptions.shakeCamOnBounce)
                    {
                        myControlsScript.shakeDensity = UFE.config.wallBounceOptions.shakeDensity;
                    }

                    UFE.PlaySound(UFE.config.wallBounceOptions.bounceSound);
                    isWallBouncing = true;
                }

                transform.Translate(horizontalForce * Time.fixedDeltaTime, 0, 0);
            }

            if (move == null || (move != null && !move.ignoreGravity))
            {
                if ((verticalForce < 0 && !IsGrounded()) || verticalForce > 0)
                {
                    verticalForce -= appliedGravity * Time.fixedDeltaTime;
                    transform.Translate(moveDirection * myControlsScript.myInfo.physics.jumpDistance * Time.fixedDeltaTime, verticalForce * Time.fixedDeltaTime, 0);
                }
                else if (verticalForce < 0 &&
                         IsGrounded() &&
                         myControlsScript.currentSubState != SubStates.Stunned)
                {
                    verticalForce = 0;
                }
            }
        }

        /*if (myControlsScript.debugger != null) {
         *      myControlsScript.debugger.text = "isBouncing = " + isBouncing + "\n";
         *      myControlsScript.debugger.text += "controlsScript.stunTime = " + controlsScript.stunTime + "\n";
         *      myControlsScript.debugger.text += "Animations:\n";
         *      foreach(AnimationState animState in character.animation){
         *              if (myMoveSetScript.IsAnimationPlaying(animState.name)){
         *                      myControlsScript.debugger.text += "<color=#003300>"+ animState.name +"</color>\n";
         *                      myControlsScript.debugger.text += "<color=#003300>"+ animState.speed +"</color>\n";
         *              }
         *      }
         * }*/

        /*if (UFE.normalizedCam) {
         *      Vector3 cameraLeftBounds = Camera.main.ViewportToWorldPoint(new Vector3(0,0,-Camera.main.transform.position.z));
         *      Vector3 cameraRightBounds = Camera.main.ViewportToWorldPoint(new Vector3(1,0,-Camera.main.transform.position.z));
         *
         *      transform.position = new Vector3(
         *              Mathf.Clamp(transform.position.x,cameraLeftBounds.x,cameraRightBounds.x),
         *              transform.position.y,
         *              transform.position.z);
         * }*/

        float minDist = myControlsScript.opponent.transform.position.x - UFE.config.cameraOptions.maxDistance;
        float maxDist = myControlsScript.opponent.transform.position.x + UFE.config.cameraOptions.maxDistance;

        transform.position = new Vector3(Mathf.Clamp(transform.position.x, minDist, maxDist), transform.position.y, transform.position.z);

        transform.position = new Vector3(
            Mathf.Clamp(transform.position.x,
                        UFE.config.selectedStage.leftBoundary,
                        UFE.config.selectedStage.rightBoundary),
            transform.position.y,
            transform.position.z);


        if (myControlsScript.currentState == PossibleStates.Down)
        {
            return;
        }

        if (IsGrounded() && myControlsScript.currentState != PossibleStates.Down)
        {
            if (verticalTotalForce != 0)
            {
                if (groundBounceTimes < UFE.config.groundBounceOptions.maximumBounces &&
                    myControlsScript.currentSubState == SubStates.Stunned &&
                    UFE.config.groundBounceOptions.bounceForce != Sizes.None &&
                    verticalForce <= -UFE.config.groundBounceOptions.minimumBounceForce &&
                    myControlsScript.currentHit.groundBounce)
                {
                    //if (!UFE.config.groundBounceOptions.bounceHitBoxes) myHitBoxesScript.HideHitBoxes(true);

                    if (myControlsScript.currentHit.overrideForcesOnGroundBounce)
                    {
                        if (myControlsScript.currentHit.resetGroundBounceHorizontalPush)
                        {
                            horizontalForce = 0;
                        }
                        if (myControlsScript.currentHit.resetGroundBounceVerticalPush)
                        {
                            verticalForce = 0;
                        }

                        float addedH = myControlsScript.currentHit.groundBouncePushForce.x;
                        float addedV = myControlsScript.currentHit.groundBouncePushForce.y;

                        AddForce(new Vector2(addedH, addedV), myControlsScript.mirror);
                    }
                    else
                    {
                        if (UFE.config.groundBounceOptions.bounceForce == Sizes.Small)
                        {
                            AddForce(new Vector2(0, -verticalForce / 2.4f), 1);
                        }
                        else if (UFE.config.groundBounceOptions.bounceForce == Sizes.Medium)
                        {
                            AddForce(new Vector2(0, -verticalForce / 1.8f), 1);
                        }
                        else if (UFE.config.groundBounceOptions.bounceForce == Sizes.High)
                        {
                            AddForce(new Vector2(0, -verticalForce / 1.2f), 1);
                        }
                    }

                    groundBounceTimes++;

                    if (!isGroundBouncing)
                    {
                        myControlsScript.stunTime += airTime + UFE.config.knockDownOptions.air.knockedOutTime;

                        if (myMoveSetScript.basicMoves.groundBounce.clip1 != null)
                        {
                            myControlsScript.currentHitAnimation = myMoveSetScript.basicMoves.groundBounce.name;
                            myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.groundBounce);
                        }
                        //Debug.LogError("Ground Bounce animation not found! Make sure you have it set on Character -> Basic Moves -> Ground Bounce");

                        //myHitBoxesScript.HideHitBoxes(UFE.config.groundBounceOptions.bounceHitBoxes);

                        if (UFE.config.groundBounceOptions.bouncePrefab != null)
                        {
                            GameObject pTemp = (GameObject)Instantiate(UFE.config.groundBounceOptions.bouncePrefab);
                            pTemp.transform.parent        = transform;
                            pTemp.transform.localPosition = Vector3.zero;
                            Destroy(pTemp, UFE.config.groundBounceOptions.bounceKillTime);
                        }
                        if (UFE.config.groundBounceOptions.shakeCamOnBounce)
                        {
                            myControlsScript.shakeDensity = UFE.config.groundBounceOptions.shakeDensity;
                        }
                        UFE.PlaySound(UFE.config.groundBounceOptions.bounceSound);
                        isGroundBouncing = true;
                    }
                    return;
                }
                verticalTotalForce            = 0;
                airTime                       = 0;
                myMoveSetScript.totalAirMoves = 0;
                currentAirJumps               = 0;

                BasicMoveInfo airAnimation  = null;
                string        downAnimation = "";

                isGroundBouncing  = false;
                groundBounceTimes = 0;

                float animationSpeed = 0;
                float delayTime      = 0;
                if (myControlsScript.currentMove != null && myControlsScript.currentMove.hitAnimationOverride)
                {
                    return;
                }
                if (myControlsScript.currentSubState == SubStates.Stunned)
                {
                    if (myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.airRecovery.name))
                    {
                        myControlsScript.stunTime     = 0;
                        myControlsScript.currentState = PossibleStates.Stand;
                    }
                    else
                    {
                        myControlsScript.stunTime = UFE.config.knockDownOptions.air.knockedOutTime + UFE.config.knockDownOptions.air.standUpTime;

                        // Hit Clips
                        if (myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.getHitKnockBack.name) &&
                            myMoveSetScript.basicMoves.getHitKnockBack.clip2 != null)
                        {
                            airAnimation  = myMoveSetScript.basicMoves.getHitKnockBack;
                            downAnimation = myMoveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else if (myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.getHitHighKnockdown.name) &&
                                 myMoveSetScript.basicMoves.getHitHighKnockdown.clip2 != null)
                        {
                            airAnimation              = myMoveSetScript.basicMoves.getHitHighKnockdown;
                            downAnimation             = myMoveSetScript.GetAnimationString(airAnimation, 2);
                            myControlsScript.stunTime = UFE.config.knockDownOptions.high.knockedOutTime + UFE.config.knockDownOptions.high.standUpTime;
                        }
                        else if (myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.getHitMidKnockdown.name) &&
                                 myMoveSetScript.basicMoves.getHitMidKnockdown.clip2 != null)
                        {
                            airAnimation              = myMoveSetScript.basicMoves.getHitMidKnockdown;
                            downAnimation             = myMoveSetScript.GetAnimationString(airAnimation, 2);
                            myControlsScript.stunTime = UFE.config.knockDownOptions.highLow.knockedOutTime + UFE.config.knockDownOptions.highLow.standUpTime;
                        }
                        else if (myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.getHitSweep.name) &&
                                 myMoveSetScript.basicMoves.getHitSweep.clip2 != null)
                        {
                            airAnimation              = myMoveSetScript.basicMoves.getHitSweep;
                            downAnimation             = myMoveSetScript.GetAnimationString(airAnimation, 2);
                            myControlsScript.stunTime = UFE.config.knockDownOptions.sweep.knockedOutTime + UFE.config.knockDownOptions.sweep.standUpTime;
                        }
                        else if (myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.getHitCrumple.name) &&
                                 myMoveSetScript.basicMoves.getHitCrumple.clip2 != null)
                        {
                            airAnimation  = myMoveSetScript.basicMoves.getHitCrumple;
                            downAnimation = myMoveSetScript.GetAnimationString(airAnimation, 2);
                            //myControlsScript.stunTime = UFE.config.knockDownOptions.crumple.knockedOutTime + UFE.config.knockDownOptions.crumple.standUpTime;

                            // Stage Clips
                        }
                        else if (myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.standingWallBounceKnockdown.name) &&
                                 myMoveSetScript.basicMoves.standingWallBounceKnockdown.clip2 != null)
                        {
                            airAnimation              = myMoveSetScript.basicMoves.standingWallBounceKnockdown;
                            downAnimation             = myMoveSetScript.GetAnimationString(airAnimation, 2);
                            myControlsScript.stunTime = UFE.config.knockDownOptions.wallbounce.knockedOutTime + UFE.config.knockDownOptions.wallbounce.standUpTime;
                        }
                        else if (myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.airWallBounce.name) &&
                                 myMoveSetScript.basicMoves.airWallBounce.clip2 != null)
                        {
                            airAnimation              = myMoveSetScript.basicMoves.airWallBounce;
                            downAnimation             = myMoveSetScript.GetAnimationString(airAnimation, 2);
                            myControlsScript.stunTime = UFE.config.knockDownOptions.wallbounce.knockedOutTime + UFE.config.knockDownOptions.wallbounce.standUpTime;

                            // Fall Clips
                        }
                        else if (myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.fallingFromAirHit.name) &&
                                 myMoveSetScript.basicMoves.fallingFromAirHit.clip2 != null)
                        {
                            airAnimation  = myMoveSetScript.basicMoves.fallingFromAirHit;
                            downAnimation = myMoveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else if (myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.fallingFromGroundBounce.name) &&
                                 myMoveSetScript.basicMoves.fallingFromGroundBounce.clip2 != null)
                        {
                            airAnimation  = myMoveSetScript.basicMoves.fallingFromGroundBounce;
                            downAnimation = myMoveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else
                        {
                            if (myMoveSetScript.basicMoves.fallDown.clip1 == null)
                            {
                                Debug.LogError("Fall Down From Air Hit animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Down From Air Hit");
                            }

                            airAnimation  = myMoveSetScript.basicMoves.fallDown;
                            downAnimation = myMoveSetScript.GetAnimationString(airAnimation, 1);
                        }

                        /*if (airAnimation.autoSpeed) {
                         *  animationSpeed = myMoveSetScript.GetAnimationLengh(airAnimation.name) / myControlsScript.stunTime;
                         * }*/

                        myControlsScript.currentState = PossibleStates.Down;
                        //if (!UFE.config.knockDownOptions.air.standUpHitBoxes) myHitBoxesScript.HideHitBoxes(true);
                    }
                }
                else if (myControlsScript.currentState != PossibleStates.Stand)
                {
                    if (myMoveSetScript.basicMoves.landing.clip1 != null &&
                        (myControlsScript.currentMove == null ||
                         (myControlsScript.currentMove != null && myControlsScript.currentMove.cancelMoveWheLanding)))
                    {
                        myControlsScript.isAirRecovering = false;
                        airAnimation  = myMoveSetScript.basicMoves.landing;
                        moveDirection = 0;
                        isLanding     = true;
                        myControlsScript.KillCurrentMove();
                        delayTime = (float)myControlsScript.myInfo.physics.landingDelay / UFE.config.fps;
                        UFE.DelaySynchronizedAction(ResetLanding, delayTime);

                        if (airAnimation.autoSpeed)
                        {
                            animationSpeed = myMoveSetScript.GetAnimationLength(airAnimation.name) / delayTime;
                        }
                    }

                    if (myControlsScript.currentState != PossibleStates.Crouch)
                    {
                        myControlsScript.currentState = PossibleStates.Stand;
                    }
                }

                if (airAnimation != null)
                {
                    if (downAnimation != "")
                    {
                        myMoveSetScript.PlayBasicMove(airAnimation, downAnimation);
                    }
                    else
                    {
                        myMoveSetScript.PlayBasicMove(airAnimation);
                    }

                    if (animationSpeed != 0)
                    {
                        myMoveSetScript.SetAnimationSpeed(airAnimation.name, animationSpeed);
                    }
                }
            }

            if (myControlsScript.currentSubState != SubStates.Stunned &&
                !myControlsScript.isBlocking && !myControlsScript.blockStunned &&
                move == null &&
                !isTakingOff &&
                !isLanding &&
                myControlsScript.currentState == PossibleStates.Stand)
            {
                if (moveDirection > 0 && myControlsScript.mirror == -1 ||
                    moveDirection < 0 && myControlsScript.mirror == 1)
                {
                    if (myMoveSetScript.basicMoves.moveForward.clip1 == null)
                    {
                        Debug.LogError("Move Forward animation not found! Make sure you have it set on Character -> Basic Moves -> Move Forward");
                    }
                    if (!myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.moveForward.name))
                    {
                        myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.moveForward);
                    }
                }
                else if (moveDirection > 0 && myControlsScript.mirror == 1 ||
                         moveDirection < 0 && myControlsScript.mirror == -1)
                {
                    if (myMoveSetScript.basicMoves.moveBack.clip1 == null)
                    {
                        Debug.LogError("Move Back animation not found! Make sure you have it set on Character -> Basic Moves -> Move Back");
                    }
                    if (!myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.moveBack.name))
                    {
                        myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.moveBack);
                    }
                }
            }
        }
        else if (verticalForce > 0 || !IsGrounded())
        {
            if (move != null && myControlsScript.currentState == PossibleStates.Stand)
            {
                myControlsScript.currentState = PossibleStates.StraightJump;
            }
            if (move == null && verticalForce / verticalTotalForce > 0 && verticalForce / verticalTotalForce <= 1)
            {
                if (isGroundBouncing)
                {
                    return;
                }

                if (moveDirection == 0)
                {
                    myControlsScript.currentState = PossibleStates.StraightJump;
                }
                else
                {
                    if (moveDirection > 0 && myControlsScript.mirror == -1 ||
                        moveDirection < 0 && myControlsScript.mirror == 1)
                    {
                        myControlsScript.currentState = PossibleStates.ForwardJump;
                    }

                    if (moveDirection > 0 && myControlsScript.mirror == 1 ||
                        moveDirection < 0 && myControlsScript.mirror == -1)
                    {
                        myControlsScript.currentState = PossibleStates.BackJump;
                    }
                }

                BasicMoveInfo airAnimation = myMoveSetScript.basicMoves.jumpStraight;
                if (myControlsScript.currentSubState == SubStates.Stunned)
                {
                    if (isWallBouncing && myMoveSetScript.basicMoves.airWallBounce.clip1 != null)
                    {
                        airAnimation = myMoveSetScript.basicMoves.airWallBounce;
                    }
                    else if (myMoveSetScript.basicMoves.getHitKnockBack.clip1 != null &&
                             Mathf.Abs(horizontalForce) > UFE.config.comboOptions.knockBackMinForce &&
                             UFE.config.comboOptions.knockBackMinForce > 0)
                    {
                        airAnimation = myMoveSetScript.basicMoves.getHitKnockBack;
                        airTime     *= 2;
                    }
                    else
                    {
                        if (myMoveSetScript.basicMoves.getHitAir.clip1 == null)
                        {
                            Debug.LogError("Get Hit Air animation not found! Make sure you have it set on Character -> Basic Moves -> Get Hit Air");
                        }

                        airAnimation = myMoveSetScript.basicMoves.getHitAir;
                    }
                    if (overrideStunAnimation != null)
                    {
                        airAnimation = overrideStunAnimation;
                    }
                }
                else if (myControlsScript.isAirRecovering &&
                         (myMoveSetScript.basicMoves.airRecovery.clip1 != null))
                {
                    airAnimation = myMoveSetScript.basicMoves.airRecovery;
                }
                else
                {
                    if (myMoveSetScript.basicMoves.jumpForward.clip1 != null && myControlsScript.currentState == PossibleStates.ForwardJump)
                    {
                        airAnimation = myMoveSetScript.basicMoves.jumpForward;
                    }
                    else if (myMoveSetScript.basicMoves.jumpBack.clip1 != null && myControlsScript.currentState == PossibleStates.BackJump)
                    {
                        airAnimation = myMoveSetScript.basicMoves.jumpBack;
                    }
                    else
                    {
                        if (myMoveSetScript.basicMoves.jumpStraight.clip1 == null)
                        {
                            Debug.LogError("Jump animation not found! Make sure you have it set on Character -> Basic Moves -> Jump Straight");
                        }

                        airAnimation = myMoveSetScript.basicMoves.jumpStraight;
                    }
                }

                if (!overrideAirAnimation && !myMoveSetScript.IsAnimationPlaying(airAnimation.name))
                {
                    myMoveSetScript.PlayBasicMove(airAnimation);
                    //if (airAnimation.invincible) myHitBoxesScript.HideHitBoxes(true);

                    if (airAnimation.autoSpeed)
                    {
                        myMoveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (myMoveSetScript.GetAnimationLength(airAnimation.name) / airTime));
                    }

                    //if (airAnimation.autoSpeed || myControlsScript.currentSubState == SubStates.Stunned) {
                    //myMoveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (myMoveSetScript.GetAnimationLengh(airAnimation.name) / airTime));
                }
            }
            else if (move == null && verticalForce / verticalTotalForce <= 0)
            {
                BasicMoveInfo airAnimation = myMoveSetScript.basicMoves.fallStraight;
                if (isGroundBouncing && myMoveSetScript.basicMoves.fallingFromGroundBounce.clip1 != null)
                {
                    airAnimation = myMoveSetScript.basicMoves.fallingFromGroundBounce;
                    //if (myMoveSetScript.basicMoves.fallingFromGroundBounce.invincible) myHitBoxesScript.HideHitBoxes(true);
                }
                else if (isWallBouncing && myMoveSetScript.basicMoves.airWallBounce.clip1 != null)
                {
                    airAnimation = myMoveSetScript.basicMoves.airWallBounce;
                    //if (myMoveSetScript.basicMoves.airWallBounce.invincible) myHitBoxesScript.HideHitBoxes(true);
                }
                else
                {
                    if (myControlsScript.currentSubState == SubStates.Stunned)
                    {
                        if (myMoveSetScript.basicMoves.getHitKnockBack.clip1 != null &&
                            Mathf.Abs(horizontalForce) > UFE.config.comboOptions.knockBackMinForce &&
                            UFE.config.comboOptions.knockBackMinForce > 0)
                        {
                            airAnimation = myMoveSetScript.basicMoves.getHitKnockBack;
                        }
                        else
                        {
                            airAnimation = myMoveSetScript.basicMoves.getHitAir;
                            if (myMoveSetScript.basicMoves.fallingFromAirHit.clip1 != null)
                            {
                                airAnimation = myMoveSetScript.basicMoves.fallingFromAirHit;
                            }
                            else if (myMoveSetScript.basicMoves.getHitAir.clip1 == null)
                            {
                                Debug.LogError("Air Juggle animation not found! Make sure you have it set on Character -> Basic Moves -> Air Juggle");
                            }
                        }
                        if (overrideStunAnimation != null)
                        {
                            airAnimation = overrideStunAnimation;
                        }
                    }
                    else if (myControlsScript.isAirRecovering &&
                             (myMoveSetScript.basicMoves.airRecovery.clip1 != null))
                    {
                        airAnimation = myMoveSetScript.basicMoves.airRecovery;
                    }
                    else
                    {
                        if (myMoveSetScript.basicMoves.fallForward.clip1 != null && myControlsScript.currentState == PossibleStates.ForwardJump)
                        {
                            airAnimation = myMoveSetScript.basicMoves.fallForward;
                        }
                        else if (myMoveSetScript.basicMoves.fallBack.clip1 != null && myControlsScript.currentState == PossibleStates.BackJump)
                        {
                            airAnimation = myMoveSetScript.basicMoves.fallBack;
                        }
                        else
                        {
                            if (myMoveSetScript.basicMoves.fallStraight.clip1 == null)
                            {
                                Debug.LogError("Fall animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Straight");
                            }

                            airAnimation = myMoveSetScript.basicMoves.fallStraight;
                        }
                    }
                }

                if (!overrideAirAnimation && !myMoveSetScript.IsAnimationPlaying(airAnimation.name))
                {
                    myMoveSetScript.PlayBasicMove(airAnimation);

                    if (airAnimation.autoSpeed)
                    {
                        //myMoveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (myMoveSetScript.GetAnimationLengh(airAnimation.name) / (airTime * 2)));
                        myMoveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (myMoveSetScript.GetAnimationLength(airAnimation.name) / airTime));
                    }
                }
            }
        }
        if (horizontalForce == 0 && verticalForce == 0)
        {
            moveDirection = 0;
        }
    }
Exemple #2
0
    public void ApplyForces(MoveInfo move)
    {
        if (freeze)
        {
            return;
        }

        controlScript.normalizedJumpArc = (Fix64)1 - ((verticalForce + verticalTotalForce) / (verticalTotalForce * 2));


        Fix64 appliedFriction = (moveDirection != 0 || controlScript.myInfo.physics.highMovingFriction) ?
                                UFE.config.selectedStage._groundFriction : controlScript.myInfo.physics._friction;


        if (move != null && move.ignoreFriction)
        {
            appliedFriction = 0;
        }

        if (controlScript.activePullIn != null)
        {
            worldTransform.position = FPVector.Lerp(worldTransform.position,
                                                    controlScript.activePullIn.position,
                                                    UFE.fixedDeltaTime * controlScript.activePullIn.speed);

            if (controlScript.activePullIn.forceStand && !IsGrounded())
            {
                ForceGrounded();
            }

            if (FPVector.Distance(controlScript.activePullIn.position, worldTransform.position) <= controlScript.activePullIn._targetDistance ||
                controlScript.currentSubState != SubStates.Stunned)
            {
                controlScript.activePullIn = null;
            }
        }
        else
        {
            if (!IsGrounded())
            {
                appliedFriction = 0;
                if (verticalForce == 0)
                {
                    verticalForce = -.1;
                }
            }

            if (horizontalForce != 0 && !isTakingOff)
            {
                if (horizontalForce > 0)
                {
                    horizontalForce -= appliedFriction * UFE.fixedDeltaTime;
                    horizontalForce  = FPMath.Max(0, horizontalForce);
                }
                else if (horizontalForce < 0)
                {
                    horizontalForce += appliedFriction * UFE.fixedDeltaTime;
                    horizontalForce  = FPMath.Min(0, horizontalForce);
                }

                Fix64 leftCameraBounds  = opWorldTransform.position.x - (UFE.config.cameraOptions._maxDistance / 2);
                Fix64 rightCameraBounds = opWorldTransform.position.x + (UFE.config.cameraOptions._maxDistance / 2);

                bool bouncingOnCamera = false;
                if (controlScript.currentHit != null &&
                    controlScript.currentHit.bounceOnCameraEdge &&
                    (worldTransform.position.x <= leftCameraBounds ||
                     worldTransform.position.x >= rightCameraBounds))
                {
                    bouncingOnCamera = true;
                }


                if (wallBounceTimes < UFE.config.wallBounceOptions._maximumBounces &&
                    controlScript.currentSubState == SubStates.Stunned &&
                    controlScript.currentState != PossibleStates.Down &&
                    UFE.config.wallBounceOptions.bounceForce != Sizes.None &&
                    FPMath.Abs(horizontalForce) >= UFE.config.wallBounceOptions._minimumBounceForce &&
                    (worldTransform.position.x <= UFE.config.selectedStage._leftBoundary ||
                     worldTransform.position.x >= UFE.config.selectedStage._rightBoundary || bouncingOnCamera) &&
                    controlScript.currentHit != null && controlScript.currentHit.wallBounce &&
                    !isWallBouncing)
                {
                    if (controlScript.currentHit.overrideForcesOnWallBounce)
                    {
                        if (controlScript.currentHit.resetWallBounceHorizontalPush)
                        {
                            horizontalForce = 0;
                        }
                        if (controlScript.currentHit.resetWallBounceVerticalPush)
                        {
                            verticalForce = 0;
                        }

                        Fix64 addedH = -controlScript.currentHit._wallBouncePushForce.x;
                        Fix64 addedV = controlScript.currentHit._wallBouncePushForce.y;

                        AddForce(new FPVector(addedH, addedV, 0), controlScript.mirror);
                    }
                    else
                    {
                        if (UFE.config.wallBounceOptions.bounceForce == Sizes.Small)
                        {
                            horizontalForce /= -1.4;
                        }
                        else if (UFE.config.wallBounceOptions.bounceForce == Sizes.Medium)
                        {
                            horizontalForce /= -1.2;
                        }
                        else if (UFE.config.wallBounceOptions.bounceForce == Sizes.High)
                        {
                            horizontalForce *= -1;
                        }
                    }

                    wallBounceTimes++;

                    if (verticalForce > 0 || !IsGrounded())
                    {
                        if (moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null)
                        {
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.airWallBounce.name;
                        }
                    }
                    else
                    {
                        if (controlScript.currentHit.knockOutOnWallBounce)
                        {
                            moveSetScript.PlayBasicMove(moveSetScript.basicMoves.standingWallBounceKnockdown);
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.standingWallBounceKnockdown.name;
                        }
                        else
                        {
                            moveSetScript.PlayBasicMove(moveSetScript.basicMoves.standingWallBounce);
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.standingWallBounce.name;
                        }
                    }

                    if (UFE.config.wallBounceOptions.bouncePrefab != null)
                    {
                        GameObject pTemp = UFE.SpawnGameObject(UFE.config.wallBounceOptions.bouncePrefab, transform.position, Quaternion.identity, Mathf.RoundToInt(UFE.config.wallBounceOptions.bounceKillTime * UFE.config.fps));
                        pTemp.transform.rotation = UFE.config.wallBounceOptions.bouncePrefab.transform.rotation;
                        if (UFE.config.wallBounceOptions.sticky)
                        {
                            pTemp.transform.parent = transform;
                        }
                        //pTemp.transform.localPosition = Vector3.zero;
                    }

                    if (UFE.config.wallBounceOptions.shakeCamOnBounce)
                    {
                        controlScript.shakeCameraDensity = UFE.config.wallBounceOptions._shakeDensity;
                    }

                    UFE.PlaySound(UFE.config.wallBounceOptions.bounceSound);
                    isWallBouncing = true;
                }

                worldTransform.Translate((horizontalForce * UFE.fixedDeltaTime), 0, 0);
            }

            if (move == null || (move != null && !move.ignoreGravity))
            {
                if ((verticalForce < 0 && !IsGrounded()) || verticalForce > 0)
                {
                    verticalForce -= appliedGravity * UFE.fixedDeltaTime;
                    worldTransform.Translate((moveDirection * UFE.fixedDeltaTime) * controlScript.myInfo.physics._jumpDistance, (verticalForce * UFE.fixedDeltaTime), 0);
                }
                else if (verticalForce < 0 &&
                         IsGrounded() &&
                         controlScript.currentSubState != SubStates.Stunned)
                {
                    verticalForce = 0;
                }
            }
        }

        Fix64 minDist = opWorldTransform.position.x - UFE.config.cameraOptions._maxDistance;
        Fix64 maxDist = opWorldTransform.position.x + UFE.config.cameraOptions._maxDistance;

        worldTransform.position = new FPVector(FPMath.Clamp(worldTransform.position.x, minDist, maxDist), worldTransform.position.y, worldTransform.position.z);

        worldTransform.position = new FPVector(
            FPMath.Clamp(worldTransform.position.x,
                         UFE.config.selectedStage._leftBoundary,
                         UFE.config.selectedStage._rightBoundary),
            FPMath.Max(worldTransform.position.y, UFE.config.selectedStage._groundHeight),
            worldTransform.position.z);

        if (controlScript.currentState == PossibleStates.Down)
        {
            return;
        }

        if (IsGrounded() && controlScript.currentState != PossibleStates.Down)
        {
            if (verticalTotalForce != 0)
            {
                if (groundBounceTimes < UFE.config.groundBounceOptions._maximumBounces &&
                    controlScript.currentSubState == SubStates.Stunned &&
                    UFE.config.groundBounceOptions.bounceForce != Sizes.None &&
                    verticalForce <= -UFE.config.groundBounceOptions._minimumBounceForce &&
                    controlScript.currentHit.groundBounce)
                {
                    if (controlScript.currentHit.overrideForcesOnGroundBounce)
                    {
                        if (controlScript.currentHit.resetGroundBounceHorizontalPush)
                        {
                            horizontalForce = 0;
                        }
                        if (controlScript.currentHit.resetGroundBounceVerticalPush)
                        {
                            verticalForce = 0;
                        }

                        Fix64 addedH = controlScript.currentHit._groundBouncePushForce.x;
                        Fix64 addedV = controlScript.currentHit._groundBouncePushForce.y;

                        AddForce(new FPVector(addedH, addedV, 0), controlScript.mirror);
                    }
                    else
                    {
                        if (UFE.config.groundBounceOptions.bounceForce == Sizes.Small)
                        {
                            AddForce(new FPVector(0, (-verticalForce / 2.4), 0), 1);
                        }
                        else if (UFE.config.groundBounceOptions.bounceForce == Sizes.Medium)
                        {
                            AddForce(new FPVector(0, (-verticalForce / 1.8), 0), 1);
                        }
                        else if (UFE.config.groundBounceOptions.bounceForce == Sizes.High)
                        {
                            AddForce(new FPVector(0, (-verticalForce / 1.2), 0), 1);
                        }
                    }

                    groundBounceTimes++;

                    if (!isGroundBouncing)
                    {
                        controlScript.stunTime += airTime + UFE.config.knockDownOptions.air._knockedOutTime;

                        if (moveSetScript.basicMoves.groundBounce.animMap[0].clip != null)
                        {
                            controlScript.currentHitAnimation = moveSetScript.basicMoves.groundBounce.name;
                            moveSetScript.PlayBasicMove(moveSetScript.basicMoves.groundBounce);
                        }

                        if (UFE.config.groundBounceOptions.bouncePrefab != null)
                        {
                            GameObject pTemp = UFE.SpawnGameObject(UFE.config.groundBounceOptions.bouncePrefab, transform.position, Quaternion.identity, Mathf.RoundToInt(UFE.config.groundBounceOptions.bounceKillTime * UFE.config.fps));
                            pTemp.transform.rotation = UFE.config.groundBounceOptions.bouncePrefab.transform.rotation;
                            if (UFE.config.groundBounceOptions.sticky)
                            {
                                pTemp.transform.parent = transform;
                            }
                            //pTemp.transform.localPosition = Vector3.zero;
                        }
                        if (UFE.config.groundBounceOptions.shakeCamOnBounce)
                        {
                            controlScript.shakeCameraDensity = UFE.config.groundBounceOptions._shakeDensity;
                        }
                        UFE.PlaySound(UFE.config.groundBounceOptions.bounceSound);
                        isGroundBouncing = true;
                    }
                    return;
                }
                verticalTotalForce          = 0;
                airTime                     = 0;
                moveSetScript.totalAirMoves = 0;
                currentAirJumps             = 0;

                BasicMoveInfo airAnimation  = null;
                string        downAnimation = "";

                isGroundBouncing  = false;
                groundBounceTimes = 0;

                Fix64 animationSpeed = 0;
                Fix64 delayTime      = 0;
                if (controlScript.currentMove != null && controlScript.currentMove.hitAnimationOverride)
                {
                    return;
                }
                if (controlScript.currentSubState == SubStates.Stunned)
                {
                    if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.airRecovery.name))
                    {
                        controlScript.stunTime     = 0;
                        controlScript.currentState = PossibleStates.Stand;
                    }
                    else
                    {
                        controlScript.stunTime = UFE.config.knockDownOptions.air._knockedOutTime + UFE.config.knockDownOptions.air._standUpTime;

                        // Hit Clips
                        if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitKnockBack.name) &&
                            moveSetScript.basicMoves.getHitKnockBack.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.getHitKnockBack;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitHighKnockdown.name) &&
                                 moveSetScript.basicMoves.getHitHighKnockdown.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.getHitHighKnockdown;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.high._knockedOutTime + UFE.config.knockDownOptions.high._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitMidKnockdown.name) &&
                                 moveSetScript.basicMoves.getHitMidKnockdown.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.getHitMidKnockdown;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.highLow._knockedOutTime + UFE.config.knockDownOptions.highLow._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitSweep.name) &&
                                 moveSetScript.basicMoves.getHitSweep.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.getHitSweep;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.sweep._knockedOutTime + UFE.config.knockDownOptions.sweep._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitCrumple.name) &&
                                 moveSetScript.basicMoves.getHitCrumple.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.getHitCrumple;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);

                            // Stage Clips
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.standingWallBounceKnockdown.name) &&
                                 moveSetScript.basicMoves.standingWallBounceKnockdown.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.standingWallBounceKnockdown;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.wallbounce._knockedOutTime + UFE.config.knockDownOptions.wallbounce._standUpTime;
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.airWallBounce.name) &&
                                 moveSetScript.basicMoves.airWallBounce.animMap[1].clip != null)
                        {
                            airAnimation           = moveSetScript.basicMoves.airWallBounce;
                            downAnimation          = moveSetScript.GetAnimationString(airAnimation, 2);
                            controlScript.stunTime = UFE.config.knockDownOptions.wallbounce._knockedOutTime + UFE.config.knockDownOptions.wallbounce._standUpTime;

                            // Fall Clips
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.fallingFromAirHit.name) &&
                                 moveSetScript.basicMoves.fallingFromAirHit.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.fallingFromAirHit;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.fallingFromGroundBounce.name) &&
                                 moveSetScript.basicMoves.fallingFromGroundBounce.animMap[1].clip != null)
                        {
                            airAnimation  = moveSetScript.basicMoves.fallingFromGroundBounce;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 2);
                        }
                        else
                        {
                            if (moveSetScript.basicMoves.fallDown.animMap[0].clip == null)
                            {
                                Debug.LogError("Fall Down From Air Hit animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Down From Air Hit");
                            }

                            airAnimation  = moveSetScript.basicMoves.fallDown;
                            downAnimation = moveSetScript.GetAnimationString(airAnimation, 1);
                        }

                        controlScript.currentState = PossibleStates.Down;
                    }
                }
                else if (controlScript.currentState != PossibleStates.Stand)
                {
                    if (moveSetScript.basicMoves.landing.animMap[0].clip != null &&
                        (controlScript.currentMove == null ||
                         (controlScript.currentMove != null && controlScript.currentMove.cancelMoveWheLanding)))
                    {
                        controlScript.isAirRecovering = false;
                        airAnimation  = moveSetScript.basicMoves.landing;
                        moveDirection = 0;
                        isLanding     = true;
                        controlScript.KillCurrentMove();
                        delayTime = (Fix64)controlScript.myInfo.physics.landingDelay / (Fix64)UFE.config.fps;
                        UFE.DelaySynchronizedAction(ResetLanding, delayTime);

                        if (airAnimation.autoSpeed)
                        {
                            animationSpeed = moveSetScript.GetAnimationLength(airAnimation.name) / delayTime;
                        }
                    }

                    if (controlScript.currentState != PossibleStates.Crouch)
                    {
                        controlScript.currentState = PossibleStates.Stand;
                    }
                }

                if (airAnimation != null)
                {
                    if (downAnimation != "")
                    {
                        moveSetScript.PlayBasicMove(airAnimation, downAnimation);
                    }
                    else
                    {
                        moveSetScript.PlayBasicMove(airAnimation);
                    }

                    if (animationSpeed != 0)
                    {
                        moveSetScript.SetAnimationSpeed(airAnimation.name, animationSpeed);
                    }
                }
            }

            if (controlScript.currentSubState != SubStates.Stunned &&
                !controlScript.isBlocking && !controlScript.blockStunned &&
                move == null &&
                !isTakingOff &&
                !isLanding &&
                controlScript.currentState == PossibleStates.Stand)
            {
                if (moveDirection > 0 && controlScript.mirror == -1 ||
                    moveDirection < 0 && controlScript.mirror == 1)
                {
                    if (moveSetScript.basicMoves.moveForward.animMap[0].clip == null)
                    {
                        Debug.LogError("Move Forward animation not found! Make sure you have it set on Character -> Basic Moves -> Move Forward");
                    }
                    if (!moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.moveForward.name))
                    {
                        moveSetScript.PlayBasicMove(moveSetScript.basicMoves.moveForward);
                    }
                }
                else if (moveDirection > 0 && controlScript.mirror == 1 ||
                         moveDirection < 0 && controlScript.mirror == -1)
                {
                    if (moveSetScript.basicMoves.moveBack.animMap[0].clip == null)
                    {
                        Debug.LogError("Move Back animation not found! Make sure you have it set on Character -> Basic Moves -> Move Back");
                    }
                    if (!moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.moveBack.name))
                    {
                        moveSetScript.PlayBasicMove(moveSetScript.basicMoves.moveBack);
                    }
                }
            }
        }
        else if (verticalForce > 0 || !IsGrounded())
        {
            if (move != null && controlScript.currentState == PossibleStates.Stand)
            {
                controlScript.currentState = PossibleStates.NeutralJump;
            }
            if (move == null && verticalForce / verticalTotalForce > 0 && verticalForce / verticalTotalForce <= 1)
            {
                if (isGroundBouncing)
                {
                    return;
                }

                if (moveDirection == 0)
                {
                    controlScript.currentState = PossibleStates.NeutralJump;
                }
                else
                {
                    if (moveDirection > 0 && controlScript.mirror == -1 ||
                        moveDirection < 0 && controlScript.mirror == 1)
                    {
                        controlScript.currentState = PossibleStates.ForwardJump;
                    }

                    if (moveDirection > 0 && controlScript.mirror == 1 ||
                        moveDirection < 0 && controlScript.mirror == -1)
                    {
                        controlScript.currentState = PossibleStates.BackJump;
                    }
                }

                BasicMoveInfo airAnimation = moveSetScript.basicMoves.jumpStraight;
                if (controlScript.currentSubState == SubStates.Stunned)
                {
                    if (isWallBouncing && moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null)
                    {
                        airAnimation = moveSetScript.basicMoves.airWallBounce;
                    }
                    else if (moveSetScript.basicMoves.getHitKnockBack.animMap[0].clip != null &&
                             FPMath.Abs(horizontalForce) > UFE.config.comboOptions._knockBackMinForce &&
                             UFE.config.comboOptions._knockBackMinForce > 0)
                    {
                        airAnimation = moveSetScript.basicMoves.getHitKnockBack;
                        airTime     *= (Fix64)2;
                    }
                    else
                    {
                        if (moveSetScript.basicMoves.getHitAir.animMap[0].clip == null)
                        {
                            Debug.LogError("Get Hit Air animation not found! Make sure you have it set on Character -> Basic Moves -> Get Hit Air");
                        }

                        airAnimation = moveSetScript.basicMoves.getHitAir;
                    }
                    if (overrideStunAnimation != null)
                    {
                        airAnimation = overrideStunAnimation;
                    }
                }
                else if (controlScript.isAirRecovering &&
                         (moveSetScript.basicMoves.airRecovery.animMap[0].clip != null))
                {
                    airAnimation = moveSetScript.basicMoves.airRecovery;
                }
                else
                {
                    if (moveSetScript.basicMoves.jumpForward.animMap[0].clip != null && controlScript.currentState == PossibleStates.ForwardJump)
                    {
                        airAnimation = moveSetScript.basicMoves.jumpForward;
                    }
                    else if (moveSetScript.basicMoves.jumpBack.animMap[0].clip != null && controlScript.currentState == PossibleStates.BackJump)
                    {
                        airAnimation = moveSetScript.basicMoves.jumpBack;
                    }
                    else
                    {
                        if (moveSetScript.basicMoves.jumpStraight.animMap[0].clip == null)
                        {
                            Debug.LogError("Jump animation not found! Make sure you have it set on Character -> Basic Moves -> Jump Straight");
                        }

                        airAnimation = moveSetScript.basicMoves.jumpStraight;
                    }
                }

                if (!overrideAirAnimation && !moveSetScript.IsAnimationPlaying(airAnimation.name))
                {
                    moveSetScript.PlayBasicMove(airAnimation);

                    if (airAnimation.autoSpeed)
                    {
                        moveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (moveSetScript.GetAnimationLength(airAnimation.name) / airTime));
                    }
                }
            }
            else if (move == null && verticalForce / verticalTotalForce <= 0)
            {
                BasicMoveInfo airAnimation = moveSetScript.basicMoves.fallStraight;
                if (isGroundBouncing && moveSetScript.basicMoves.fallingFromGroundBounce.animMap[0].clip != null)
                {
                    airAnimation = moveSetScript.basicMoves.fallingFromGroundBounce;
                }
                else if (isWallBouncing && moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null)
                {
                    airAnimation = moveSetScript.basicMoves.airWallBounce;
                }
                else
                {
                    if (controlScript.currentSubState == SubStates.Stunned)
                    {
                        if (moveSetScript.basicMoves.getHitKnockBack.animMap[0].clip != null &&
                            FPMath.Abs(horizontalForce) > UFE.config.comboOptions._knockBackMinForce &&
                            UFE.config.comboOptions._knockBackMinForce > 0)
                        {
                            airAnimation = moveSetScript.basicMoves.getHitKnockBack;
                        }
                        else
                        {
                            airAnimation = moveSetScript.basicMoves.getHitAir;
                            if (moveSetScript.basicMoves.fallingFromAirHit.animMap[0].clip != null)
                            {
                                airAnimation = moveSetScript.basicMoves.fallingFromAirHit;
                            }
                            else if (moveSetScript.basicMoves.getHitAir.animMap[0].clip == null)
                            {
                                Debug.LogError("Air Juggle animation not found! Make sure you have it set on Character -> Basic Moves -> Air Juggle");
                            }
                        }
                        if (overrideStunAnimation != null)
                        {
                            airAnimation = overrideStunAnimation;
                        }
                    }
                    else if (controlScript.isAirRecovering &&
                             (moveSetScript.basicMoves.airRecovery.animMap[0].clip != null))
                    {
                        airAnimation = moveSetScript.basicMoves.airRecovery;
                    }
                    else
                    {
                        if (moveSetScript.basicMoves.fallForward.animMap[0].clip != null && controlScript.currentState == PossibleStates.ForwardJump)
                        {
                            airAnimation = moveSetScript.basicMoves.fallForward;
                        }
                        else if (moveSetScript.basicMoves.fallBack.animMap[0].clip != null && controlScript.currentState == PossibleStates.BackJump)
                        {
                            airAnimation = moveSetScript.basicMoves.fallBack;
                        }
                        else
                        {
                            if (moveSetScript.basicMoves.fallStraight.animMap[0].clip == null)
                            {
                                Debug.LogError("Fall animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Straight");
                            }

                            airAnimation = moveSetScript.basicMoves.fallStraight;
                        }
                    }
                }

                if (!overrideAirAnimation && !moveSetScript.IsAnimationPlaying(airAnimation.name))
                {
                    moveSetScript.PlayBasicMove(airAnimation);

                    if (airAnimation.autoSpeed)
                    {
                        moveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (moveSetScript.GetAnimationLength(airAnimation.name) / airTime));
                    }
                }
            }
        }
        if (horizontalForce == 0 && verticalForce == 0)
        {
            moveDirection = 0;
        }
    }