public static bool SpecialNavigationSystem(
        this UFEScreen screen,
        int player,
        MoveCursorCallback moveCursorCallback = null,
        ActionCallback confirmCallback        = null,
        ActionCallback cancelCallback         = null
        )
    {
        //-------------------------------------------------------------------------------------------------------------
        // Retrieve the controller assigned to specified player
        //-------------------------------------------------------------------------------------------------------------
        AbstractInputController inputController = UFE.GetController(player);

        if (inputController != null && UFE.eventSystem != null && UFE.eventSystem.isActiveAndEnabled)
        {
            return(UFEScreenExtensions.SpecialNavigationSystem(
                       inputController,
                       inputController.GetAxisRaw(inputController.horizontalAxis),
                       inputController.GetAxisRaw(inputController.verticalAxis),
                       inputController.GetButtonDown(inputController.horizontalAxis),
                       inputController.GetButtonDown(inputController.verticalAxis),
                       inputController.GetButtonDown(UFE.config.inputOptions.confirmButton),
                       inputController.GetButtonDown(UFE.config.inputOptions.cancelButton),
                       moveCursorCallback,
                       confirmCallback,
                       cancelCallback
                       ));
        }

        return(false);
    }
Exemple #2
0
 protected virtual void MoveCursor(AbstractInputController controller)
 {
     if (!UFE.isConnected)
     {
         // If it's a local game, update the corresponding character immediately...
         if (UFE.config.player1Character == null)
         {
             this.MoveCursor(controller, 1);
         }
         else if (UFE.config.player2Character == null && UFE.gameMode != GameMode.StoryMode)
         {
             this.MoveCursor(controller, 2);
         }
     }
     else
     {
         // If it's an online game, find out if the local player is Player1 or Player2...
         // And only update the selection for the local player...
         int localPlayer = UFE.GetLocalPlayer();
         if (localPlayer == 1 && UFE.config.player1Character == null)
         {
             this.MoveCursor(controller, 1);
         }
         else if (localPlayer == 2 && UFE.config.player2Character == null)
         {
             this.MoveCursor(controller, 2);
         }
     }
 }
    public override void DoFixedUpdate()
    {
        base.DoFixedUpdate();

        AbstractInputController p1InputController = UFE.GetPlayer1Controller();
        AbstractInputController p2InputController = UFE.GetPlayer2Controller();

        // Retrieve the values of the horizontal and vertical axis
        float p1VerticalAxis = p1InputController.GetAxisRaw(p1InputController.horizontalAxis);
        bool  p1AxisDown     = p1InputController.GetButtonDown(p1InputController.horizontalAxis);

        float p2VerticalAxis = p2InputController.GetAxisRaw(p2InputController.horizontalAxis);
        bool  p2AxisDown     = p2InputController.GetButtonDown(p2InputController.horizontalAxis);


        if (p1AxisDown)
        {
            if (p1VerticalAxis > 0f)
            {
                this.PreviousStage();
            }
            else if (p1VerticalAxis < 0f)
            {
                this.NextStage();
            }
        }

        if (p1InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
        {
            this.TrySelectStage();
        }
        else if (p1InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
        {
            this.TryDeselectStage();
        }

        if (p2AxisDown)
        {
            if (p2VerticalAxis > 0f)
            {
                this.PreviousStage();
            }
            else if (p2VerticalAxis < 0f)
            {
                this.NextStage();
            }
        }

        if (p2InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
        {
            this.TrySelectStage();
        }
        else if (p2InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
        {
            this.TryDeselectStage();
        }
    }
    private static bool SpecialNavigationSystem(
        AbstractInputController inputController,
        float horizontalAxis,
        float verticalAxis,
        bool horizontalAxisDown,
        bool verticalAxisDown,
        bool confirmButtonDown,
        bool cancelButtonDown,
        MoveCursorCallback moveCursorCallback,
        ActionCallback confirmCallback,
        ActionCallback cancelCallback
        )
    {
        if (inputController != null)
        {
            if (moveCursorCallback != null && moveCursorCallback.Action != null)
            {
                moveCursorCallback.Action(
                    horizontalAxis,
                    verticalAxis,
                    horizontalAxisDown,
                    verticalAxisDown,
                    confirmButtonDown,
                    cancelButtonDown,
                    moveCursorCallback.Sound
                    );
            }

            if (confirmButtonDown)
            {
                if (confirmCallback != null && confirmCallback.Action != null)
                {
                    confirmCallback.Action(confirmCallback.Sound);
                }
                return(true);
            }
            else if (cancelButtonDown)
            {
                if (cancelCallback != null && cancelCallback.Action != null)
                {
                    cancelCallback.Action(cancelCallback.Sound);
                }
                return(true);
            }
        }
        return(false);
    }
        public override void Load()
        {
            Everest.Events.Level.OnLoadEntity += Level_OnLoadEntity;
            Everest.Events.CustomBirdTutorial.OnParseCommand += CustomBirdTutorial_OnParseCommand;

            RegisterOptionalDependencies();
            Everest.Events.Everest.OnRegisterModule += OnRegisterModule;

            DashStateRefill.Load();
            DreamTunnelDash.Load();
            SeekerDash.Load();

            DreamBlockDummy.Load();

            CustomDreamBlock.Load();
            // Individual Dream Blocks hooked in CustomDreamBlock.Load

            DreamDashCollider.Load();

            AbstractPanel.Load();
            // Panel-specific hooks loaded from AbstractPanel.Load

            ConnectedSwapBlockHooks.Hook();
            CustomCassetteBlock.Hook();

            AttachedWallBooster.Hook();
            MoveBlockRedirect.Load();
            MoveBlockRedirectable.Load();
            MoveSwapBlock.Load();

            AbstractInputController.Load();
            // Controller-specific hooks loaded from AbstractInputController.Load
            CassetteJumpFixController.Load();
            // TimedTriggerSpikes hooked in Initialize

            UnderwaterMusicController.Load();

            HeartGemShard.Load();
            CustomSummitGem.Load();

            CustomBooster.Load();

            DreamJellyfish.Load();
            DreamJellyfishRenderer.Load();

            ChainedKevin.Load();
        }
        public override void Unload()
        {
            Everest.Events.Level.OnLoadEntity -= Level_OnLoadEntity;
            Everest.Events.CustomBirdTutorial.OnParseCommand -= CustomBirdTutorial_OnParseCommand;

            Everest.Events.Everest.OnRegisterModule -= OnRegisterModule;

            DashStateRefill.Unload();
            DreamTunnelDash.Unload();
            SeekerDash.Unload();

            DreamBlockDummy.Unload();

            CustomDreamBlock.Unload();
            // Individual Dream Blocks unhooked in CustomDreamBlock.Unload

            AbstractPanel.Unload();
            DreamDashCollider.Unload();

            ConnectedSwapBlockHooks.Unhook();
            CustomCassetteBlock.Unhook();

            AttachedWallBooster.Unhook();
            MoveBlockRedirect.Unload();
            MoveBlockRedirectable.Unload();
            MoveSwapBlock.Unload();
            AbstractInputController.Unload();
            CassetteJumpFixController.Unload();
            TimedTriggerSpikes.Unload();

            UnderwaterMusicController.Unload();

            HeartGemShard.Unload();
            CustomSummitGem.Unload();

            CustomBooster.Unload();

            DreamJellyfish.Unload();
            DreamJellyfishRenderer.Unload();

            ChainedKevin.Unload();
        }
Exemple #7
0
    protected virtual void MoveCursor(AbstractInputController controller, int player)
    {
        float horizontalAxis = controller.GetAxisRaw(controller.horizontalAxis);
        float verticalAxis   = controller.GetAxisRaw(controller.verticalAxis);

        if (horizontalAxis > 0)
        {
            this.MoveCursorRight(player);
        }
        else if (horizontalAxis < 0)
        {
            this.MoveCursorLeft(player);
        }

        if (verticalAxis > 0)
        {
            this.MoveCursorUp(player);
        }
        else if (verticalAxis < 0)
        {
            this.MoveCursorDown(player);
        }
    }
    int StageSelect(int selectedIndex, AbstractInputController playerController)
    {
        if (!p1AxisHeld && playerController.GetAxisRaw(playerController.horizontalAxis) > 0){
            UFE.PlaySound(moveCursorSound);
            if (selectedIndex == UFE.config.stages.Length - 1){
                selectedIndex = 0;
            }else{
                selectedIndex += 1;
            }
        }else if (!p1AxisHeld && playerController.GetAxisRaw(playerController.horizontalAxis) < 0){
            UFE.PlaySound(moveCursorSound);
            if (selectedIndex == 0){
                selectedIndex = UFE.config.stages.Length - 1;
            }else{
                selectedIndex -= 1;
            }
        }

        return selectedIndex;
    }
Exemple #9
0
    protected virtual void MoveCursor(AbstractInputController controller, int player)
    {
        float horizontalAxis    = controller.GetAxisRaw(controller.horizontalAxis);
        float verticalAxis      = controller.GetAxisRaw(controller.verticalAxis);
        bool  characterSelected = true;
        int   currentIndex      = -1;

        if (player == 1)
        {
            currentIndex      = this.p1HoverIndex;
            characterSelected = UFE.config.player1Character != null;
        }
        else if (player == 2)
        {
            currentIndex      = this.p2HoverIndex;
            characterSelected = UFE.config.player2Character != null;
        }

        if (!characterSelected || currentIndex < 0)
        {
            Vector3 direction = Vector3.zero;
            if (horizontalAxis > 0)
            {
                direction = Vector3.right;
            }
            else if (horizontalAxis < 0)
            {
                direction = Vector3.left;
            }
            if (verticalAxis > 0)
            {
                direction = Vector3.up;
            }
            else if (verticalAxis < 0)
            {
                direction = Vector3.down;
            }

            GameObject currentGameObject = this.characters[currentIndex].gameObject;
            GameObject nextGameObject    = currentGameObject.FindSelectableGameObject(direction, this.wrapInput);

            if (nextGameObject == null)
            {
                nextGameObject = currentGameObject;
            }

            if (nextGameObject != null)
            {
                int index = -1;

                for (int i = 0; i < this.characters.Length; ++i)
                {
                    if (this.characters[i].gameObject == nextGameObject)
                    {
                        index = i;
                        break;
                    }
                }

                this.MoveCursor(player, index);
            }
        }
    }
Exemple #10
0
    public static void DefaultNavigationSystem(
        this UFEScreen screen,
        AudioClip selectSound     = null,
        AudioClip moveCursorSound = null,
        Action cancelAction       = null,
        AudioClip cancelSound     = null
        )
    {
        // Retrieve the controller assigned to each player
        AbstractInputController p1InputController = UFE.GetPlayer1Controller();
        AbstractInputController p2InputController = UFE.GetPlayer2Controller();

        // Retrieve the values of the horizontal and vertical axis
        float p1HorizontalAxis = p1InputController.GetAxisRaw(p1InputController.horizontalAxis);
        float p1VerticalAxis   = p1InputController.GetAxisRaw(p1InputController.verticalAxis);
        bool  p1AxisDown       =
            p1InputController.GetButtonDown(p1InputController.horizontalAxis) ||
            p1InputController.GetButtonDown(p1InputController.verticalAxis);

        float p2HorizontalAxis = p2InputController.GetAxisRaw(p2InputController.horizontalAxis);
        float p2VerticalAxis   = p2InputController.GetAxisRaw(p2InputController.verticalAxis);
        bool  p2AxisDown       =
            p2InputController.GetButtonDown(p2InputController.horizontalAxis) ||
            p2InputController.GetButtonDown(p2InputController.verticalAxis);

        // Check if we should change the selected option
        if (p1AxisDown)
        {
            screen.MoveCursor(new Vector3(p1HorizontalAxis, p1VerticalAxis), moveCursorSound);
        }

        if (p1InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
        {
            screen.SelectOption(selectSound);
        }
        else if (p1InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
        {
            if (cancelSound != null)
            {
                UFE.PlaySound(cancelSound);
            }
            if (cancelAction != null)
            {
                cancelAction();
            }
        }
        else
        {
            if (p2AxisDown)
            {
                screen.MoveCursor(new Vector3(p2HorizontalAxis, p2VerticalAxis), moveCursorSound);
            }

            if (p2InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
            {
                screen.SelectOption(selectSound);
            }
            else if (p2InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
            {
                if (cancelSound != null)
                {
                    UFE.PlaySound(cancelSound);
                }
                if (cancelAction != null)
                {
                    cancelAction();
                }
            }
        }
    }
Exemple #11
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);
                    }
                }
            }
        }
    }
Exemple #12
0
    public override void DoFixedUpdate()
    {
        base.DoFixedUpdate();

        // Retrieve the controller assigned to each player
        AbstractInputController p1InputController = UFE.GetPlayer1Controller();
        AbstractInputController p2InputController = UFE.GetPlayer2Controller();

        // Retrieve the values of the horizontal and vertical axis
        float p1HorizontalAxis     = p1InputController.GetAxisRaw(p1InputController.horizontalAxis);
        float p1VerticalAxis       = p1InputController.GetAxisRaw(p1InputController.verticalAxis);
        bool  p1HorizontalAxisDown = p1InputController.GetButtonDown(p1InputController.horizontalAxis);
        bool  p1VerticalAxisDown   = p1InputController.GetButtonDown(p1InputController.verticalAxis);

        float p2HorizontalAxis     = p2InputController.GetAxisRaw(p2InputController.horizontalAxis);
        float p2VerticalAxis       = p2InputController.GetAxisRaw(p2InputController.verticalAxis);
        bool  p2HorizontalAxisDown = p2InputController.GetButtonDown(p2InputController.horizontalAxis);
        bool  p2VerticalAxisDown   = p2InputController.GetButtonDown(p2InputController.verticalAxis);

        // Check if we should change the selected option
        if (p1HorizontalAxisDown)
        {
            GameObject currentGameObject = UFE.eventSystem.currentSelectedGameObject;
            Slider     slider            = null;

            if (currentGameObject != null)
            {
                slider = currentGameObject.GetComponent <Slider>();
            }

            if (slider != null)
            {
                if (slider.wholeNumbers)
                {
                    slider.value += Mathf.Sign(p1HorizontalAxis);
                }
                else
                {
                    slider.value += Mathf.Sign(p1HorizontalAxis) * this.sliderSpeed;
                }
            }
            else if (p1VerticalAxisDown)
            {
                this.MoveCursor(new Vector3(p1HorizontalAxis, p1VerticalAxis), this.moveCursorSound);
            }
            else
            {
                this.MoveCursor(new Vector3(p1HorizontalAxis, 0f), this.moveCursorSound);
            }
        }
        else if (p1VerticalAxisDown)
        {
            this.MoveCursor(new Vector3(0f, p1VerticalAxis), this.moveCursorSound);
        }

        if (p1InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
        {
            this.SelectOption(this.selectSound);
        }
        else if (p1InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
        {
            if (this.cancelSound != null)
            {
                UFE.PlaySound(cancelSound);
            }
            if (this.cancelButton != null && this.cancelButton.onClick != null)
            {
                this.cancelButton.onClick.Invoke();
            }
        }
        else
        {
            if (p2HorizontalAxisDown)
            {
                GameObject currentGameObject = UFE.eventSystem.currentSelectedGameObject;
                Slider     slider            = null;

                if (currentGameObject != null)
                {
                    slider = currentGameObject.GetComponent <Slider>();
                }

                if (slider != null)
                {
                    if (slider.wholeNumbers)
                    {
                        slider.value += Mathf.Sign(p2HorizontalAxis);
                    }
                    else
                    {
                        slider.value += Mathf.Sign(p2HorizontalAxis) * this.sliderSpeed;
                    }
                }
                else if (p2VerticalAxisDown)
                {
                    this.MoveCursor(new Vector3(p2HorizontalAxis, p2VerticalAxis), this.moveCursorSound);
                }
                else
                {
                    this.MoveCursor(new Vector3(p2HorizontalAxis, 0f), this.moveCursorSound);
                }
            }
            else if (p2VerticalAxisDown)
            {
                this.MoveCursor(new Vector3(0f, p2VerticalAxis), this.moveCursorSound);
            }

            if (p2InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
            {
                this.SelectOption(this.selectSound);
            }
            else if (p2InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
            {
                if (this.cancelSound != null)
                {
                    UFE.PlaySound(cancelSound);
                }
                if (this.cancelButton != null && this.cancelButton.onClick != null)
                {
                    this.cancelButton.onClick.Invoke();
                }
            }
        }
    }
    public static bool DefaultNavigationSystem(
        this UFEScreen screen,
        int player,
        AudioClip moveCursorSound = null,
        AudioClip confirmSound    = null,
        AudioClip cancelSound     = null,
        Action cancelAction       = null
        )
    {
        //-------------------------------------------------------------------------------------------------------------
        // Retrieve the controller assigned to specified player
        //-------------------------------------------------------------------------------------------------------------
        AbstractInputController inputController = UFE.GetController(player);

        if (inputController != null && UFE.eventSystem != null && UFE.eventSystem.isActiveAndEnabled)
        {
            //---------------------------------------------------------------------------------------------------------
            // First, check if the current Selectable Object is an Input Field, because it's a special case...
            //---------------------------------------------------------------------------------------------------------
            GameObject currentGameObject = UFE.eventSystem.currentSelectedGameObject;
            InputField inputField        = currentGameObject != null?currentGameObject.GetComponent <InputField>() : null;

            if (inputField != null)
            {
                //-----------------------------------------------------------------------------------------------------
                // If it's an Input Field, check if the user wants to write a text
                // or if he wants to move the caret or exit from the Input Field...
                //-----------------------------------------------------------------------------------------------------
                Vector3 direction =
                    (Input.GetKeyDown(KeyCode.UpArrow) ? Vector3.up : Vector3.zero) +
                    (Input.GetKeyDown(KeyCode.DownArrow) ? Vector3.down : Vector3.zero);

                if (
                    direction != Vector3.zero ||
                    Input.GetKeyDown(KeyCode.Tab) ||
                    Input.GetKeyDown(KeyCode.Return) ||
                    Input.GetKeyDown(KeyCode.KeypadEnter)
                    )
                {
                    Selectable previousSelectable = inputField;
                    Selectable nextSelectable     = null;

                    if (direction != Vector3.zero)
                    {
                        nextSelectable = currentGameObject.FindSelectable(direction, false);
                    }

                    if (nextSelectable == null || previousSelectable == nextSelectable)
                    {
                        nextSelectable = currentGameObject.FindSelectable(Vector3.right, false);

                        if (nextSelectable == null || previousSelectable == nextSelectable)
                        {
                            nextSelectable = currentGameObject.FindSelectable(Vector3.down, false);

                            if (nextSelectable == null || previousSelectable == nextSelectable)
                            {
                                nextSelectable = currentGameObject.FindSelectable(Vector3.left, false);

                                if (nextSelectable == null || previousSelectable == nextSelectable)
                                {
                                    nextSelectable = currentGameObject.FindSelectable(Vector3.up, false);
                                }
                            }
                        }
                    }

                    screen.HighlightOption(nextSelectable);
                }
                else
                {
                    inputField.OnUpdateSelected(new AxisEventData(UFE.eventSystem));
                }
                return(true);
            }
            else
            {
                //-----------------------------------------------------------------------------------------------------
                // Otherwise, invoke the "Special Navigation System" with the default functions
                //-----------------------------------------------------------------------------------------------------
                return(screen.SpecialNavigationSystem(
                           player,
                           new MoveCursorCallback(screen.DefaultMoveCursorAction, moveCursorSound),
                           new ActionCallback(UFE.eventSystem.currentSelectedGameObject.DefaultConfirmAction, confirmSound),
                           new ActionCallback(cancelAction.DefaultCancelAction, cancelSound)
                           ));
            }
        }
        return(false);
    }
    int CharacterMenuSelection(int selectedIndex, AbstractInputController controller, InputReferences horizontalAxis, InputReferences verticalAxis)
    {
        if (controller.GetAxisRaw(horizontalAxis) > 0){
            UFE.PlaySound(moveCursorSound);
            if (selectedIndex == UFE.config.characters.Length - 1){
                selectedIndex = 0;
            }else{
                selectedIndex += 1;
            }
        }else if (controller.GetAxisRaw(horizontalAxis) < 0){
            UFE.PlaySound(moveCursorSound);
            if (selectedIndex == 0){
                selectedIndex = UFE.config.characters.Length - 1;
            }else{
                selectedIndex -= 1;
            }
        }

        if (controller.GetAxisRaw(verticalAxis) < 0){
            UFE.PlaySound(moveCursorSound);
            if (selectedIndex <= 3 && UFE.config.characters.Length > 4){
                selectedIndex += 4;
            }
        }else if (controller.GetAxisRaw(verticalAxis) > 0){
            UFE.PlaySound(moveCursorSound);
            if (selectedIndex > 3){
                selectedIndex -= 4;
            }
        }

        return selectedIndex;
    }
Exemple #15
0
 private bool isAxisRested(AbstractInputController inputController)
 {
     if (currentState == PossibleStates.Down) return true;
     if (UFE.config.lockMovements) return true;
     foreach (InputReferences inputRef in inputController.inputReferences) {
         if (inputRef.inputType == InputType.Button) continue;
         if (inputController.GetAxisRaw(inputRef) != 0) return false;
     }
     return true;
 }
Exemple #16
0
    void Start()
    {
        if (gameObject.name == "Player1") {
            transform.position = new Vector3(UFE.config.roundOptions.p1XPosition, .009f, 0);
            opponent = GameObject.Find("Player2");
            if (UFE.config.player1Character == null)
                Debug.LogError("Player 1 character not found! Make sure you have set the characters correctly in the Global Editor");

            myInfo = (CharacterInfo) Instantiate(UFE.config.player1Character);
            UFE.config.player1Character = myInfo;

            debugger = UFE.debugger1;
            mirror = -1;
            playerNum = 1;

            inputController = UFE.GetPlayer1Controller();
            debugInfo = UFE.config.debugOptions.p1DebugInfo;
        }else{
            transform.position = new Vector3(UFE.config.roundOptions.p2XPosition, .009f, 0);
            opponent = GameObject.Find("Player1");
            if (UFE.config.player2Character == null)
                Debug.LogError("Player 2 character not found! Make sure you have set the characters correctly in the Global Editor");

            myInfo = (CharacterInfo) Instantiate(UFE.config.player2Character);
            UFE.config.player2Character = myInfo;

            debugger = UFE.debugger2;
            mirror = 1;
            playerNum = 2;

            inputController = UFE.GetPlayer2Controller();
            debugInfo = UFE.config.debugOptions.p2DebugInfo;
        }

        myInfo.currentLifePoints = (float)myInfo.lifePoints;

        if (myInfo.characterPrefab == null)
            Debug.LogError("Character prefab for "+ gameObject.name +" not found. Make sure you have selected a prefab character in the Character Editor");

        character = (GameObject) Instantiate(myInfo.characterPrefab);
        character.transform.parent = transform;
        character.AddComponent<MoveSetScript>();

        standardYRotation = character.transform.rotation.eulerAngles.y;

        myPhysicsScript = GetComponent<PhysicsScript>();
        myMoveSetScript = character.GetComponent<MoveSetScript>();
        myHitBoxesScript = character.GetComponent<HitBoxesScript>();
        cameraScript = transform.parent.GetComponent<CameraScript>();

        myHitBoxesScript.controlsScript = this;

        if (myInfo.headLook.enabled){
            character.AddComponent<HeadLookScript>();
            headLookScript = character.GetComponent<HeadLookScript>();
            headLookScript.segments = myInfo.headLook.segments;
            headLookScript.nonAffectedJoints = myInfo.headLook.nonAffectedJoints;
            headLookScript.effect = myInfo.headLook.effect;
            headLookScript.overrideAnimation = !myInfo.headLook.overrideAnimation;

            foreach(BendingSegment segment in headLookScript.segments) {
                segment.firstTransform = myHitBoxesScript.GetTransform(segment.bodyPart).parent.transform;
                segment.lastTransform = myHitBoxesScript.GetTransform(segment.bodyPart);
            }

            foreach(NonAffectedJoints nonAffectedJoint in headLookScript.nonAffectedJoints)
                nonAffectedJoint.joint = myHitBoxesScript.GetTransform(nonAffectedJoint.bodyPart);
        }

        if (gameObject.name == "Player2") {
            testCharacterRotation(100, true);
            UFE.FireGameBegins();
        }

        if (UFE.config.roundOptions.allowMovement) {
            UFE.config.lockMovements = false;
        }else{
            UFE.config.lockMovements = true;
        }
    }
 protected virtual void MoveCursor(AbstractInputController controller)
 {
     if (Network.peerType == NetworkPeerType.Disconnected){
         // If it's a local game, update the corresponding character immediately...
         if (UFE.config.player1Character == null){
             this.MoveCursor(controller, 1);
         }else if (UFE.config.player2Character == null && UFE.gameMode != GameMode.StoryMode){
             this.MoveCursor(controller, 2);
         }
     }else{
         // If it's an online game, find out if the local player is Player1 or Player2...
         // And only update the selection for the local player...
         int localPlayer = UFE.GetLocalPlayer();
         if (localPlayer == 1 && UFE.config.player1Character == null){
             this.MoveCursor(controller, 1);
         }else if (localPlayer == 2 && UFE.config.player2Character == null){
             this.MoveCursor(controller, 2);
         }
     }
 }
    public override void DoFixedUpdate()
    {
        base.DoFixedUpdate();

        if (this.isRunning)
        {
            AbstractInputController p1InputController = UFE.GetPlayer1Controller();
            AbstractInputController p2InputController = UFE.GetPlayer2Controller();
            float deltaTime = Time.fixedDeltaTime;

            // Animate the alert messages if they exist
            if (this.player1GUI != null && this.player1GUI.alert != null && this.player1GUI.alert.text != null)
            {
                this.player1GUI.alert.text.rectTransform.anchoredPosition = Vector3.Lerp(
                    this.player1GUI.alert.text.rectTransform.anchoredPosition,
                    this.player1GUI.alert.finalPosition,
                    this.player1GUI.alert.movementSpeed * deltaTime
                    );

                if (this.player1AlertTimer > 0f)
                {
                    this.player1AlertTimer -= deltaTime;
                }
                else if (!string.IsNullOrEmpty(this.player1GUI.alert.text.text))
                {
                    this.player1GUI.alert.text.text = string.Empty;
                }
            }

            if (this.player2GUI != null && this.player2GUI.alert != null && this.player2GUI.alert.text != null)
            {
                this.player2GUI.alert.text.rectTransform.anchoredPosition = Vector3.Lerp(
                    this.player2GUI.alert.text.rectTransform.anchoredPosition,
                    this.player2GUI.alert.finalPosition,
                    this.player2GUI.alert.movementSpeed * deltaTime
                    );

                if (this.player2AlertTimer > 0f)
                {
                    this.player2AlertTimer -= deltaTime;
                }
                else if (!string.IsNullOrEmpty(this.player2GUI.alert.text.text))
                {
                    this.player2GUI.alert.text.text = string.Empty;
                }
            }

            if (this.mainAlert != null && this.mainAlert.text != null)
            {
                if (this.mainAlertTimer > 0f)
                {
                    this.mainAlertTimer -= deltaTime;
                }
                else if (!string.IsNullOrEmpty(this.mainAlert.text.text))
                {
                    this.mainAlert.text.text = string.Empty;
                }
            }


            // Animate life points when it goes down (P1)
            if (this.player1.targetLife > UFE.config.player1Character.currentLifePoints)
            {
                this.player1.targetLife -= this.lifeDownSpeed * deltaTime;
                if (this.player1.targetLife < UFE.config.player1Character.currentLifePoints)
                {
                    this.player1.targetLife = UFE.config.player1Character.currentLifePoints;
                }
            }
            if (this.player1.targetLife < UFE.config.player1Character.currentLifePoints)
            {
                this.player1.targetLife += this.lifeUpSpeed * deltaTime;
                if (this.player1.targetLife > UFE.config.player1Character.currentLifePoints)
                {
                    this.player1.targetLife = UFE.config.player1Character.currentLifePoints;
                }
            }

            // Animate life points when it goes down (P2)
            if (this.player2.targetLife > UFE.config.player2Character.currentLifePoints)
            {
                this.player2.targetLife -= this.lifeDownSpeed * deltaTime;
                if (this.player2.targetLife < UFE.config.player2Character.currentLifePoints)
                {
                    this.player2.targetLife = UFE.config.player2Character.currentLifePoints;
                }
            }
            if (this.player2.targetLife < UFE.config.player2Character.currentLifePoints)
            {
                this.player2.targetLife += this.lifeUpSpeed * deltaTime;
                if (this.player2.targetLife > UFE.config.player2Character.currentLifePoints)
                {
                    this.player2.targetLife = UFE.config.player2Character.currentLifePoints;
                }
            }


            if (
                // Check if both players have their life points above zero...
                UFE.config.player1Character.currentLifePoints > 0 &&
                UFE.config.player2Character.currentLifePoints > 0 &&
                UFE.gameMode != GameMode.NetworkGame &&
                (
                    // and at least one of the players have pressed the Start button...
                    p1InputController != null && p1InputController.GetButtonDown(ButtonPress.Start) ||
                    p2InputController != null && p2InputController.GetButtonDown(ButtonPress.Start)
                )
                )
            {
                // In that case, we can process pause menu events
                UFE.PauseGame(!UFE.isPaused());
            }


            // Draw the Life Bars and Gauge Meters using the data stored in UFE.config.guiOptions
            if (this.player1GUI != null && this.player1GUI.lifeBar != null)
            {
                this.player1GUI.lifeBar.fillAmount = this.player1.targetLife / this.player1.totalLife;
            }

            if (this.player2GUI != null && this.player2GUI.lifeBar != null)
            {
                this.player2GUI.lifeBar.fillAmount = this.player2.targetLife / this.player2.totalLife;
            }

            if (UFE.config.gameGUI.hasGauge)
            {
                if (this.player1GUI != null && this.player1GUI.gaugeMeter != null)
                {
                    this.player1GUI.gaugeMeter.fillAmount = UFE.config.player1Character.currentGaugePoints / UFE.config.player1Character.maxGaugePoints;
                }

                if (this.player2GUI != null && this.player2GUI.gaugeMeter != null)
                {
                    this.player2GUI.gaugeMeter.fillAmount = UFE.config.player2Character.currentGaugePoints / UFE.config.player2Character.maxGaugePoints;
                }
            }

            if (this.pause != null)
            {
                this.pause.DoFixedUpdate();
            }


            /*
             * if (Debug.isDebugBuild){
             *      player1NameGO.guiText.text = string.Format(
             *              "{0}\t\t({1},\t{2},\t{3})",
             *              this.player1.characterName,
             *              UFE.GetPlayer1ControlsScript().transform.position.x,
             *              UFE.GetPlayer1ControlsScript().transform.position.y,
             *              UFE.GetPlayer1ControlsScript().transform.position.z
             *      );
             *
             *      player2NameGO.guiText.text = string.Format(
             *              "{0}\t\t({1},\t{2},\t{3})",
             *              this.player2.characterName,
             *              UFE.GetPlayer2ControlsScript().transform.position.x,
             *              UFE.GetPlayer2ControlsScript().transform.position.y,
             *              UFE.GetPlayer2ControlsScript().transform.position.z
             *      );
             * }
             */
        }
    }
    protected virtual void MoveCursor(AbstractInputController controller, int player)
    {
        float horizontalAxis = controller.GetAxisRaw(controller.horizontalAxis);
        float verticalAxis = controller.GetAxisRaw(controller.verticalAxis);

        if (horizontalAxis > 0)			this.MoveCursorRight(player);
        else if (horizontalAxis < 0)	this.MoveCursorLeft(player);

        if (verticalAxis > 0)			this.MoveCursorUp(player);
        else if (verticalAxis < 0)		this.MoveCursorDown(player);
    }
Exemple #20
0
    public void DoFixedUpdate()
    {
        if (isHit > 0)
        {
            isHit -= Time.fixedDeltaTime;
            return;
        }

        // Check if both controllers are ready
        AbstractInputController p1InputController = UFE.GetPlayer1Controller();
        AbstractInputController p2InputController = UFE.GetPlayer2Controller();

        if (p1InputController == null || !p1InputController.isReady || p2InputController == null || !p2InputController.isReady)
        {
            return;
        }

        if (UFE.freeCamera)
        {
            return;
        }

        transform.position += (movement * Time.fixedDeltaTime);

        hurtBox.position = gameObject.transform.position;
        if (projectileRenderer != null && (hurtBox.followXBounds || hurtBox.followYBounds))
        {
            hurtBox.rendererBounds = GetBounds();
            hitBox.rendererBounds  = GetBounds();
        }

        blockableArea.position = transform.position;
        if (!opControlsScript.isBlocking &&
            !opControlsScript.blockStunned &&
            opControlsScript.currentSubState != SubStates.Stunned &&
            opHitBoxesScript.TestCollision(blockableArea) != Vector3.zero)
        {
            opControlsScript.CheckBlocking(true);
        }

        if (data.projectileCollision)
        {
            if (opControlsScript.projectiles.Count > 0)
            {
                foreach (ProjectileMoveScript projectile in opControlsScript.projectiles)
                {
                    if (projectile == null)
                    {
                        continue;
                    }
                    if (projectile.hitBox == null)
                    {
                        continue;
                    }
                    if (projectile.hurtBox == null)
                    {
                        continue;
                    }

                    if (HitBoxesScript.TestCollision(new HitBox[] { projectile.hitBox }, new HurtBox[] { hurtBox }, HitConfirmType.Hit, mirror) != Vector3.zero)
                    {
                        if (data.impactPrefab != null)
                        {
                            GameObject hitEffect = (GameObject)Instantiate(data.impactPrefab, transform.position, Quaternion.Euler(0, 0, data.directionAngle));
                            UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(hitEffect); }catch {} }, data.impactDuration);
                        }
                        totalHits--;
                        if (totalHits <= 0)
                        {
                            destroyMe = true;
                        }
                        isHit = spaceBetweenHits;
                        transform.Translate(movement * -1 * Time.fixedDeltaTime);
                        break;
                    }
                }
            }
        }

        if (opHitBoxesScript.TestCollision(new HurtBox[] { hurtBox }, HitConfirmType.Hit) != Vector3.zero &&
            opControlsScript.ValidateHit(hit))
        {
            if (data.impactPrefab != null)
            {
                GameObject hitEffect = (GameObject)Instantiate(data.impactPrefab, transform.position, Quaternion.Euler(0, 0, data.directionAngle));
                UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(hitEffect); }catch {} }, data.impactDuration);
            }
            totalHits--;
            if (totalHits <= 0)
            {
                UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(gameObject); }catch {} }, (float)(2 / UFE.config.fps));
            }


            if (opControlsScript.currentSubState != SubStates.Stunned && opControlsScript.isBlocking && opControlsScript.TestBlockStances(hit.hitType))
            {
                myControlsScript.AddGauge(data.gaugeGainOnBlock);
                opControlsScript.AddGauge(data.opGaugeGainOnBlock);
                opControlsScript.GetHitBlocking(hit, 20, transform.position);

                if (data.moveLinkOnBlock != null)
                {
                    myControlsScript.CastMove(data.moveLinkOnBlock, true, data.forceGrounded);
                }
            }
            else if (opControlsScript.potentialParry > 0 && opControlsScript.TestParryStances(hit.hitType))
            {
                opControlsScript.AddGauge(data.opGaugeGainOnParry);
                opControlsScript.GetHitParry(hit, 20, transform.position);

                if (data.moveLinkOnParry != null)
                {
                    myControlsScript.CastMove(data.moveLinkOnParry, true, data.forceGrounded);
                }
            }
            else
            {
                myControlsScript.AddGauge(data.gaugeGainOnHit);
                opControlsScript.AddGauge(data.opGaugeGainOnHit);
                opControlsScript.GetHit(hit, 30, Vector3.zero);

                if (data.moveLinkOnStrike != null)
                {
                    myControlsScript.CastMove(data.moveLinkOnStrike, true, data.forceGrounded);
                }
            }

            isHit = opControlsScript.GetHitFreezingTime(data.hitStrength) * 1.2f;
            opControlsScript.CheckBlocking(false);
        }
    }
Exemple #21
0
    public override void DoFixedUpdate()
    {
        base.DoFixedUpdate();

        AbstractInputController p1InputController = UFE.GetPlayer1Controller();
        AbstractInputController p2InputController = UFE.GetPlayer2Controller();

        // Retrieve the values of the horizontal and vertical axis
        bool p1AxisDown =
            p1InputController.GetButtonDown(p1InputController.horizontalAxis) ||
            p1InputController.GetButtonDown(p1InputController.verticalAxis);

        bool p2AxisDown =
            p2InputController.GetButtonDown(p2InputController.horizontalAxis) ||
            p2InputController.GetButtonDown(p2InputController.verticalAxis);

        // Process the player input...
        if (UFE.gameMode != GameMode.StoryMode && !UFE.GetCPU(2))
        {
            // If we are in "Story Mode" or in "Player vs Player (versus mode)", the controller assigned to
            // the first player will be used always for selecting the character assigned to that player. If
            // that player has already selected a character, he can't move the cursor unless he deselects
            // the character first.
            if (p1AxisDown)
            {
                this.MoveCursor(p1InputController, 1);
            }

            if (p1InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
            {
                this.TrySelectCharacter(this.p1HoverIndex, 1);
            }
            else if (p1InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
            {
                this.TryDeselectCharacter(1);
            }

            // The controller assigned to the second player only can be used for selecting the character assigned to
            // the second player in "Player vs Player (versus mode)". In other game modes, the character assigned to
            // the second player will be chosen randomly (Story Mode) or will be selected by Player 1 (Player vs CPU).
            if (p2AxisDown)
            {
                this.MoveCursor(p2InputController, 2);
            }

            if (p2InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
            {
                this.TrySelectCharacter(this.p2HoverIndex, 2);
            }
            else if (p2InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
            {
                this.TryDeselectCharacter(2);
            }
        }
        else
        {
            // However, the character assigned to the second player will be chosen by the first player in other
            // game modes (for example: Player vs CPU).
            if (p1AxisDown)
            {
                this.MoveCursor(p1InputController);
            }

            if (p1InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
            {
                this.TrySelectCharacter();
            }
            else if (p1InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
            {
                this.TryDeselectCharacter();
            }
        }
    }