Exemple #1
0
    private void translateInputs(AbstractInputController inputController)
    {
        if (!introPlayed || !opControlsScript.introPlayed) return;
        if (UFE.config.lockInputs && !UFE.config.roundOptions.allowMovement) return;
        if (UFE.config.lockMovements) return;

        foreach (InputReferences inputRef in inputController.inputReferences) {
            if (((inputRef.engineRelatedButton == ButtonPress.Down && inputController.GetAxisRaw(inputRef) >= 0)
                 || (inputRef.engineRelatedButton == ButtonPress.Up && inputController.GetAxisRaw(inputRef) <= 0))
                && myPhysicsScript.IsGrounded()
                && !myHitBoxesScript.isHit
                && currentSubState != SubStates.Stunned){
                currentState = PossibleStates.Stand;
            }

            if (inputRef.inputType != InputType.Button && inputRef.heldDown > 0 && inputController.GetAxisRaw(inputRef) == 0) {
                if ((inputRef.engineRelatedButton == ButtonPress.Back && UFE.config.blockOptions.blockType == BlockType.HoldBack)){
                    potentialBlock = false;
                }

                storedMove = myMoveSetScript.GetMove(new ButtonPress[]{inputRef.engineRelatedButton}, inputRef.heldDown, currentMove, true);
                inputRef.heldDown = 0;
                if (storedMove != null){
                    storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                    return;
                }
            }

            if (inputRef.heldDown == 0 && inputRef.inputType != InputType.Button) {
                inputRef.activeIcon = inputController.GetAxisRaw(inputRef) > 0? inputRef.inputViewerIcon1 : inputRef.inputViewerIcon2;
            }

            /*if (inputController.GetButtonUp(inputRef)) {
                storedMove = myMoveSetScript.GetMove(new ButtonPress[]{inputRef.engineRelatedButton}, inputRef.heldDown, currentMove, true);
                inputRef.heldDown = 0;
                if (storedMove != null){
                    storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                    return;
                }
            }*/

            // Axis Press
            if (inputRef.inputType != InputType.Button && inputController.GetAxisRaw(inputRef) != 0) {
                if (inputRef.inputType == InputType.HorizontalAxis) {
                    // Horizontal Movements
                    if (inputController.GetAxisRaw(inputRef) > 0) {
                        inputRef.engineRelatedButton = mirror == 1? ButtonPress.Back : ButtonPress.Foward;
                        inputRef.heldDown += Time.fixedDeltaTime;
                        if (inputRef.heldDown == Time.fixedDeltaTime && testMoveExecution(inputRef.engineRelatedButton, false)) return;

                        if (currentState == PossibleStates.Stand
                            && !isBlocking
                            && !myPhysicsScript.isTakingOff
                            && !myPhysicsScript.isLanding
                            && currentSubState != SubStates.Stunned
                            && !blockStunned
                            && currentMove == null
                            && myMoveSetScript.basicMoves.moveEnabled) {
                            myPhysicsScript.Move(-mirror, inputController.GetAxisRaw(inputRef));
                        }
                    }

                    if (inputController.GetAxisRaw(inputRef) < 0) {
                        inputRef.engineRelatedButton = mirror == 1? ButtonPress.Foward : ButtonPress.Back;
                        inputRef.heldDown += Time.fixedDeltaTime;
                        if (inputRef.heldDown == Time.fixedDeltaTime && testMoveExecution(inputRef.engineRelatedButton, false)) return;

                        if (currentState == PossibleStates.Stand
                            && !isBlocking
                            && !myPhysicsScript.isTakingOff
                            && !myPhysicsScript.isLanding
                            && currentSubState != SubStates.Stunned
                            && !blockStunned
                            && currentMove == null
                            && myMoveSetScript.basicMoves.moveEnabled) {
                            myPhysicsScript.Move(mirror, inputController.GetAxisRaw(inputRef));
                        }
                    }

                    // Check for potential blocking
                    if (inputRef.engineRelatedButton == ButtonPress.Back
                        && UFE.config.blockOptions.blockType == BlockType.HoldBack
                        && !myPhysicsScript.isTakingOff
                        && myMoveSetScript.basicMoves.blockEnabled) {
                        potentialBlock = true;
                    }

                    // Check for potential parry
                    if (((inputRef.engineRelatedButton == ButtonPress.Back && UFE.config.blockOptions.parryType == ParryType.TapBack) ||
                         (inputRef.engineRelatedButton == ButtonPress.Foward && UFE.config.blockOptions.parryType == ParryType.TapForward))
                        && potentialParry == 0
                        && inputRef.heldDown == Time.fixedDeltaTime
                        && currentMove == null
                        && !isBlocking
                        && !myPhysicsScript.isTakingOff
                        && currentSubState != SubStates.Stunned
                        && !blockStunned
                        && myMoveSetScript.basicMoves.parryEnabled) {
                        potentialParry = UFE.config.blockOptions.parryTiming;
                    }

                }else{
                    // Vertical Movements
                    if (inputController.GetAxisRaw(inputRef) > 0) {
                        inputRef.engineRelatedButton = ButtonPress.Up;
                        if (!myPhysicsScript.isTakingOff && !myPhysicsScript.isLanding){
                            if (inputRef.heldDown == 0) {
                                if (!myPhysicsScript.IsGrounded() && myInfo.physics.canJump && myInfo.physics.multiJumps > 1){
                                    myPhysicsScript.Jump();
                                }
                                if (testMoveExecution(inputRef.engineRelatedButton, false)) return;
                            }
                            if (!myPhysicsScript.freeze
                                && !myPhysicsScript.IsJumping()
                                && storedMove == null
                                && currentMove == null
                                && currentState == PossibleStates.Stand
                                && currentSubState != SubStates.Stunned
                                && !isBlocking
                                && myInfo.physics.canJump
                                && !blockStunned
                                && myMoveSetScript.basicMoves.jumpEnabled) {

                                float delayTime = (float)myInfo.physics.jumpDelay/UFE.config.fps;
                                myPhysicsScript.isTakingOff = true;
                                potentialBlock = false;
                                potentialParry = 0;

                                UFE.DelaySynchronizedAction(myPhysicsScript.Jump, delayTime);

                                if (myMoveSetScript.AnimationExists(myMoveSetScript.basicMoves.takeOff.name)){
                                    myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.takeOff);

                                    if (myMoveSetScript.basicMoves.takeOff.autoSpeed) {
                                        myMoveSetScript.SetAnimationSpeed(
                                            myMoveSetScript.basicMoves.takeOff.name,
                                            myMoveSetScript.GetAnimationLengh(myMoveSetScript.basicMoves.takeOff.name) / delayTime);
                                    }

                                }
                            }
                        }
                        inputRef.heldDown += Time.fixedDeltaTime;

                    }else if (inputController.GetAxisRaw(inputRef) < 0) {
                        inputRef.engineRelatedButton = ButtonPress.Down;
                        if (inputRef.heldDown == 0 && testMoveExecution(inputRef.engineRelatedButton, false)) return;
                        inputRef.heldDown += Time.fixedDeltaTime;

                        if (!myPhysicsScript.freeze
                            && myPhysicsScript.IsGrounded()
                            && currentMove == null
                            && currentSubState != SubStates.Stunned
                            && !myPhysicsScript.isTakingOff
                            && !blockStunned
                            && myMoveSetScript.basicMoves.crouchEnabled) {
                            currentState = PossibleStates.Crouch;
                            if (!myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.crouching.name)) {
                                if (!isBlocking && !myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.crouching.name))
                                    myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.crouching);

                                if (isBlocking && !myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.blockingCrouchingPose.name))
                                    myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.blockingCrouchingPose);
                            }
                        }
                    }
                }

                foreach (InputReferences inputRef2 in inputController.inputReferences) {
                    if (inputRef2.inputType == InputType.Button && inputController.GetButtonDown(inputRef2)) {
                        storedMove = myMoveSetScript.GetMove(
                            new ButtonPress[]{inputRef.engineRelatedButton, inputRef2.engineRelatedButton}, 0, currentMove, false, true);

                        if (storedMove != null){
                            storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                            return;
                        }
                    }
                }
            }

            // Button Press
            if (inputRef.inputType == InputType.Button && !UFE.config.lockInputs){
                if (inputController.GetButton(inputRef)) {
                    if (myMoveSetScript.CompareBlockButtons(inputRef.engineRelatedButton)
                        && currentSubState != SubStates.Stunned
                        && !myPhysicsScript.isTakingOff
                        && !blockStunned
                        && myMoveSetScript.basicMoves.blockEnabled) {
                        potentialBlock = true;
                        CheckBlocking(true);
                    }

                    if (myMoveSetScript.CompareParryButtons(inputRef.engineRelatedButton)
                        && inputRef.heldDown == 0
                        && potentialParry == 0
                        && currentMove == null
                        && !isBlocking
                        && currentSubState != SubStates.Stunned
                        && !myPhysicsScript.isTakingOff
                        && !blockStunned
                        && myMoveSetScript.basicMoves.parryEnabled) {
                        potentialParry = UFE.config.blockOptions.parryTiming;
                    }

                    inputRef.heldDown += Time.fixedDeltaTime;
                    if (inputRef.heldDown <= ((float)UFE.config.plinkingDelay/(float)UFE.config.fps)) {
                        foreach (InputReferences inputRef2 in inputController.inputReferences) {
                            if (inputRef2 != inputRef
                                && inputRef2.inputType == InputType.Button
                                && inputController.GetButtonDown(inputRef2)) {
                                inputRef2.heldDown += Time.fixedDeltaTime;
                                storedMove = myMoveSetScript.GetMove(
                                    new ButtonPress[]{inputRef.engineRelatedButton, inputRef2.engineRelatedButton}, 0, currentMove, false, true);

                                if (storedMove != null && (currentMove == null || currentMove.currentFrame <= UFE.config.plinkingDelay)){
                                    KillCurrentMove();
                                    storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                                    return;
                                }
                            }
                        }
                    }
                }

                if (inputController.GetButtonDown(inputRef)) {
                    storedMove = myMoveSetScript.GetMove(new ButtonPress[]{inputRef.engineRelatedButton}, 0, currentMove, false);
                    if (storedMove != null){
                        storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                        return;
                    }
                }

                if (inputController.GetButtonUp(inputRef)) {
                    storedMove = myMoveSetScript.GetMove(new ButtonPress[]{inputRef.engineRelatedButton}, inputRef.heldDown, currentMove, true);
                    inputRef.heldDown = 0;
                    if (storedMove != null) {
                        storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                        return;
                    }
                    if (myMoveSetScript.CompareBlockButtons(inputRef.engineRelatedButton)
                        && !myPhysicsScript.isTakingOff) {
                        potentialBlock = false;
                        CheckBlocking(false);
                    }
                }
            }
        }
    }