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); }
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(); } }
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); } }
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(); } } } }
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); } } } } }
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; }
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; }
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); } } }
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); }
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(); } } } }
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; }