コード例 #1
0
        void TakeInput(out Vector3 stickInput)
        {
            stickInput = Vector3.zero;

            if (m_mainPlayer)
            {
                Rewired.Player player = ReInput.players.GetPlayer(m_mainPlayer.m_nplayerIndex - 1);
                stickInput = new Vector3(player.GetAxisRaw("Look Vertical"), -player.GetAxisRaw("Look Horizontal"), 0);

                if (player.GetButtonDown("Change Camera"))
                {
                    switch (m_currentViewStyle)
                    {
                    case viewStyles_e.bonnet:
                        SwitchViewStyle(viewStyles_e.driving);
                        break;

                    case viewStyles_e.driving:
                        SwitchViewStyle(viewStyles_e.thirdPerson);
                        break;

                    case viewStyles_e.thirdPerson:
                        SwitchViewStyle(viewStyles_e.bonnet);
                        break;
                    }
                }
            }
        }
コード例 #2
0
    public virtual void UpdateInputSnapshot()
    {
        snapshot.xAxis = player.GetAxisRaw("Move Horizontal");
        snapshot.yAxis = player.GetAxisRaw("Move Vertical");

        snapshot.xAxisThrow = player.GetAxisRaw("Throw Stick Horizontal");
        snapshot.yAxisThrow = player.GetAxisRaw("Throw Stick Vertical");

        //snapshot.xAxis = ConstrainAxisTo16Angles (snapshot.xAxis);
        //snapshot.yAxis = ConstrainAxisTo16Angles (snapshot.yAxis);

        //snapshot.xAxis *= 2f;
        //snapshot.xAxis = ConstrainAxisTo16Angles (snapshot.xAxis);
        //snapshot.xAxis /= 2f;

        //snapshot.yAxis *= 2f;
        //snapshot.yAxis = ConstrainAxisTo16Angles (snapshot.yAxis);
        //snapshot.yAxis /= 2f;

        if (player.GetButtonDown("Jump"))
        {
            JumpButtonDown();
        }

        if (player.GetButtonUp("Jump"))
        {
            JumpButtonUp();
        }

        if (player.GetButtonDown("Throw"))
        {
            ThrowButtonDown();
        }

        if (player.GetButtonUp("Throw"))
        {
            ThrowButtonUp();
        }

        if (player.GetButtonDown("Start"))
        {
            StartButtonDown();
        }

        if (player.GetButtonUp("Start"))
        {
            StartButtonUp();
        }

//		if (Input.GetButtonDown (selectButton)) {
//			snapshot.selectButton.down = true;
//			snapshot.selectButton.pressed = true;
//		}
//
//		if (Input.GetButtonUp (selectButton)) {
//			snapshot.selectButton.up = true;
//			snapshot.selectButton.pressed = false;
//		}
    }
コード例 #3
0
ファイル: CarScript.cs プロジェクト: n8-webb/RedShirtsKojima
        void AirControl()
        {
            //Vector3 controlVelocity = new Vector3(-Input.GetAxisRaw("Vertical" + m_strplayerInputTag), Input.GetAxisRaw("Horizontal" + m_strplayerInputTag), 0);
            //Rewired
            Vector3 controlVelocity = new Vector3(-m_rewiredPlayer.GetAxisRaw("Move Vertical"), m_rewiredPlayer.GetAxisRaw("Move Horizontal"), 0);

            controlVelocity = transform.TransformDirection(controlVelocity);
            m_rb.AddTorque(controlVelocity * 5, ForceMode.Acceleration);
        }
コード例 #4
0
    private void moveSelection()
    {
        //when move
        if (DpadPressing == false)
        {
            if (rewiredPlayer.GetAxisRaw("MoveVertical") >= 0.5f)
            {
                menuOrder--;
                DpadPressing = true;
            }
            if (rewiredPlayer.GetAxisRaw("MoveVertical") <= -0.5f)
            {
                menuOrder++;
                DpadPressing = true;
            }
        }
        else
        {
            if (rewiredPlayer.GetAxisRaw("MoveVertical") == 0)
            {
                DpadPressing = false;
            }
        }

        //when move pass limit
        if (menuOrder > 4)
        {
            menuOrder = 1;
        }
        if (menuOrder < 1)
        {
            menuOrder = 4;
        }

        //position of outline for selection
        if (menuOrder == 1)
        {
            outline.anchoredPosition =
                new Vector2(0, 70);
        }
        if (menuOrder == 2)
        {
            outline.anchoredPosition =
                new Vector2(0, -13);
        }
        if (menuOrder == 3)
        {
            outline.anchoredPosition =
                new Vector2(0, -96);
        }
        if (menuOrder == 4)
        {
            outline.anchoredPosition =
                new Vector2(0, -179);
        }
    }
コード例 #5
0
ファイル: Player.cs プロジェクト: eladrianovalle/TransVersus
    void Update()
    {
        isJumping      = player.GetButtonDown("Jump");
        isAttacking    = player.GetButtonDown("Attack");
        playerMovement = player.GetAxisRaw("Move Horizontal");

//		if (playerController != null)
//		{
//			playerController.ProcessInputFromPlayer (isJumping, playerMovement);
//		}

        if (isJumping)
        {
//			Debug.Log (this.name + " is Jumping!!!");
        }

        if (isAttacking)
        {
            Debug.Log(this.name + " is Attacking!!!");
            weapon.gameObject.SetActive(true);
        }
//		else
//		{
//			weapon.gameObject.SetActive (false);
//		}
    }
コード例 #6
0
    private void Update()
    {
        var moveInput = new Vector2(input.GetAxisRaw("MoveHorizontal"), input.GetAxisRaw("MoveVertical"));

        moveStep  = cameraTransform.forward * moveInput.y;
        moveStep += cameraTransform.right * moveInput.x;

        var applyOrientation = moveStep.sqrMagnitude > 0.1f;

        moveStep.y = 0f;
        UpdateOrientation(applyOrientation);

        AccelerationFactor += Time.deltaTime / (applyOrientation
            ? gP.PlayerAccelerationTime
            : -gP.PlayerDecelerationTime);

        AccelerationFactor = Mathf.Clamp01(AccelerationFactor);

        moveStep.Normalize();
    }
コード例 #7
0
        public override bool ShouldActivateModule()
        {
            if (!base.ShouldActivateModule())
            {
                return(false);
            }

            bool shouldActivate = false;

            // Combine input for all players
            for (int i = 0; i < players.Length; i++)
            {
                Rewired.Player player = players[i];
                if (player == null)
                {
                    continue;
                }

                shouldActivate |= player.GetButtonDown(m_SubmitButton);
                shouldActivate |= player.GetButtonDown(m_CancelButton);
                if (moveOneElementPerAxisPress)  // axis press moves only to the next UI element with each press
                {
                    shouldActivate |= player.GetButtonDown(m_HorizontalAxis) || player.GetNegativeButtonDown(m_HorizontalAxis);
                    shouldActivate |= player.GetButtonDown(m_VerticalAxis) || player.GetNegativeButtonDown(m_VerticalAxis);
                }
                else     // default behavior - axis press scrolls quickly through UI elements
                {
                    shouldActivate |= !Mathf.Approximately(player.GetAxisRaw(m_HorizontalAxis), 0.0f);
                    shouldActivate |= !Mathf.Approximately(player.GetAxisRaw(m_VerticalAxis), 0.0f);
                }
            }

            shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f;
            shouldActivate |= mouse.GetButtonDown(0);

            return(shouldActivate);
        }
コード例 #8
0
    public void VerticalInput(MenuState upperMenu, MenuState lowerMenu)
    {
        if (DpadPressing == false)
        {
            if (rewiredPlayer1.GetAxisRaw("MoveVertical") >= 0.5f || rewiredPlayer2.GetAxisRaw("MoveVertical") >= 0.5f)
            {
                currentMenuState = MenuState.Rotating;
                DpadPressing     = true;
                modeSelecter_Circle.circlingUp(upperMenu);
                menuWindow.changeMenu(upperMenu);
                modeSelector_screen.changeModeScreen(upperMenu);
                bubbleChange = true;
                AudioManager.Instance.PlayAudio(AudioManager.Instance.MenuMoveClips);
            }

            if (rewiredPlayer1.GetAxisRaw("MoveVertical") <= -0.5f || rewiredPlayer2.GetAxisRaw("MoveVertical") <= -0.5f)
            {
                currentMenuState = MenuState.Rotating;
                DpadPressing     = true;
                modeSelecter_Circle.circlingDown(lowerMenu);
                menuWindow.changeMenu(lowerMenu);
                modeSelector_screen.changeModeScreen(lowerMenu);
                bubbleChange = true;
                AudioManager.Instance.PlayAudio(AudioManager.Instance.MenuMoveClips);
            }
        }
        else
        {
            if (rewiredPlayer1.GetAxisRaw("MoveVertical") == 0 && rewiredPlayer2.GetAxisRaw("MoveVertical") == 0)
            {
                DpadPressing = false;
            }

            bubbleChange = false;
        }
    }
コード例 #9
0
    //Check for inputs during moveable states
    private void MoveCheck()
    {
        float axisRaw = rewiredPlayer.GetAxisRaw("MoveHorizontal");

        if (axisRaw != 0)
        {
            //switch to walking
            SendInput(InputState.Walk, axisRaw);
        }

        if (axisRaw == 0)
        {
            //stop walking and switch to idle
            SendInput(InputState.EndWalk, axisRaw);
        }
    }
コード例 #10
0
    private void Update()
    {
        if (rb.velocity != Vector3.zero)
        {
            isWalking = true;
        }
        else
        {
            isWalking = false;
        }

        PlayerIsBackwards();
        PlayerStrafeValue();

        //Management of speed
        if (playerScript.IsDown)
        {
            authorizedSpeed = 0;
            rb.constraints  = RigidbodyConstraints.FreezeAll;
        }
        else
        {
            if (rb.constraints == RigidbodyConstraints.FreezeAll)
            {
                rb.constraints = RigidbodyConstraints.FreezeRotation;
            }
            if (playerScript.isBackward || playerScript.LightSources < 0 || playerScript.objectCarrying != null)
            {
                authorizedSpeed = walkSpeed * speedInDarkMultiplier;
            }
            else if (RInput.GetButton("Sprint"))
            //else if (Input.GetAxis(sprintInput) > 0)
            {
                authorizedSpeed = walkSpeed * sprintSpeedMultiplier;
            }

            else
            {
                authorizedSpeed = walkSpeed;
            }

            inputValue = new Vector3(RInput.GetAxis("MoveH"), 0, RInput.GetAxis("MoveV"));
            //inputValue = new Vector3(Input.GetAxis(horizontalInputName), 0, Input.GetAxis(verticalInputName));

            Vector3 newVelocity;
            if (playerScript.isInteractGate == false && playerScript.IsDown == false)
            {
                rb.velocity += inputValue.normalized * Acceleration * Time.fixedDeltaTime;
            }
            else
            {
                rb.velocity = Vector3.zero;
            }

            //Stopper le déplacement sur un axe quand l'input est à zéro
            float xVelocity = rb.velocity.x;
            float zVelocity = rb.velocity.z;

            if (RInput.GetAxis("MoveH") == 0)
            {
                xVelocity = 0;
            }
            if (RInput.GetAxisRaw("MoveV") == 0)
            {
                zVelocity = 0;
            }

            /*if (Input.GetAxisRaw(horizontalInputName) == 0)
             *  xVelocity = 0;
             * if (Input.GetAxisRaw(verticalInputName) == 0)
             *  zVelocity = 0;*/

            newVelocity = new Vector3(xVelocity, rb.velocity.y, zVelocity);
            rb.velocity = newVelocity;


            if (rb.velocity.magnitude > authorizedSpeed)
            {
                float verticalVelocity = rb.velocity.y;
                rb.velocity = rb.velocity.normalized * authorizedSpeed;
                newVelocity = new Vector3(rb.velocity.x, verticalVelocity, rb.velocity.z);
                rb.velocity = newVelocity;
            }
        }
        BlockPlayerInScreen();

        //_animator.SetFloat("Speed", rb.velocity.magnitude / walkSpeed);

        #region Charles Animation

        /*
         *
         * float angle = Vector3.SignedAngle(inputValue, transform.forward,transform.up);
         * _animator.SetFloat("Speed", RInput.GetAxis("MoveV"));
         * _animator.SetBool("Walking", rb.velocity.magnitude > 0.1f);
         *
         * _animator.SetFloat("Strafing", RInput.GetAxis("MoveH"));
         * _animator.SetBool("Strafe", PlayerStrafeValue() != 0);
         *
         * _animator.SetBool("Down", playerScript.IsDown);
         */

        #endregion


        _animator.SetFloat("Speed", playerScript.isBackward ? -1 : 1);
        _animator.SetBool("Walking", rb.velocity.magnitude > 0.1f);

        _animator.SetFloat("Strafing", PlayerStrafeValue());
        _animator.SetBool("Strafe", PlayerStrafeValue() != 0);

        _animator.SetBool("Down", playerScript.IsDown);

        ///////Debug
        //sprintInputValue = Input.GetAxis(sprintInput);

        InputXValue    = RInput.GetAxis("MoveH");
        InputYValue    = RInput.GetAxis("MoveV");
        actualVelocity = rb.velocity;

        /*InputXValue = Input.GetAxis(horizontalInputName);
         * InputYValue = Input.GetAxis(verticalInputName);
         * actualVelocity = rb.velocity;*/

        ///////Debug
    }
コード例 #11
0
ファイル: Player.cs プロジェクト: samyoed/Capstone
        void Update()
        {
//-----------------------------RUN BEFORE EVERY FRAME----------------------------------
            if (_gameManager.gameState == GameManagerNew.GameState.PAUSED ||
                _gameManager.gameState == GameManagerNew.GameState.COUNTING ||
                _gameManager.gameState == GameManagerNew.GameState.GAMEOVER)
            {
                canMove = false;
            }
            else
            {
                canMove = true;
            }


            if (input.x < -0.01)
            {
                isFacingRight = false;
            }
            else if (input.x > 0.01)
            {
                isFacingRight = true;
            }

            if (isFacingRight)
            {
                transform.localScale = new Vector3(currentScale.x, currentScale.y, currentScale.z);
            }
            if (!isFacingRight)
            {
                transform.localScale = new Vector3(-currentScale.x, currentScale.y, currentScale.z);
            }

            // if(hasSpecial)
            //    _PartSys.Play();

            if (currentDashCount == 0)
            {
                _Sr.color = Color.grey;
            }
            else
            {
                _Sr.color = Color.white;
            }

            //input
            if (canMove)
            {
                input = new Vector2(playInput.GetAxisRaw("Horizontal"), playInput.GetAxisRaw("Vertical"));
            }

//-----------------------------STATE MACHINE-------------------------------------------
            switch (phase)
            {   //----------------------------------ATTACKING---------------------------
            case state.ATTACK:

                attackTimer++;
                velocity = (new Vector3(lockedDashDirec.x, lockedDashDirec.y, 0)) * attackSpeed;

                gravity = 0;
                if (attackTimer > attackTimerMax)
                {
                    phase   = state.DEFAULT;
                    gravity = normGravTemp;
                    //currentDashCount--;
                    _PlayerCircColl.enabled    = true;
                    _PlayerCapsuleColl.enabled = false;
                    tempAttackInt = 0;

                    break;
                }
                break;

            //----------------------------------DASHING-----------------------------
            case state.DASH:

                dashTimer++;
                velocity = (new Vector3(lockedDashDirec.x, lockedDashDirec.y, 0)) * dashSpeed;

                gravity = 0;
                if (dashTimer > dashTimerMax)
                {
                    phase   = state.DEFAULT;
                    gravity = normGravTemp;
                    currentDashCount--;
                    break;
                }
                break;

            //-----------------------------------SPECIAL-----------------------------
            case state.SPECIAL:

                specialTimer++;
                _Special.activateSpecial();

                if (specialTimer > specialTimerMax)
                {
                    phase      = state.DEFAULT;
                    hasSpecial = false;
                    break;
                }
                break;

            //-----------------------------------DEFAULT-----------------------------
            case state.DEFAULT:
                //dashes when button is pressed and there are dashes available
                if (Input.GetButtonDown(actionInput) && currentDashCount > 0 && canMove)
                {
                    SoundManager.PlaySound("jump");
                    lockedDashDirec = input.normalized;
                    phase           = state.DASH;
                    dashTimer       = 0;
                }
                if (Input.GetButtonDown(attackInput) && canMove)
                {
                    SoundManager.PlaySound("hit");
                    lockedDashDirec = input.normalized;
                    phase           = state.ATTACK;
                    attackTimer     = 0;
                    Vector3 circCollRot = Vector3.zero;

                    _PlayerCapsuleColl.size = new Vector2(6f, 10f);

                    Vector2 roundedInput = new Vector2(Mathf.RoundToInt(input.x), Mathf.RoundToInt(input.y));

                    //for
                    if (roundedInput.x == 0 && roundedInput.y == 0 && isFacingRight)
                    {
                        circCollRot.z = -90f;           //if no direction inputted
                        tempAttackInt = 3;
                    }
                    else if (roundedInput.x == 0 && roundedInput.y == 0 && !isFacingRight)
                    {
                        circCollRot.z = 90f;
                        tempAttackInt = 3;
                    }
                    else if (roundedInput.x == 0 && roundedInput.y == 1)
                    {
                        circCollRot.z = 0f;              //if up input
                        tempAttackInt = 1;
                    }
                    else if (roundedInput.x == 1 && roundedInput.y == 1)
                    {
                        circCollRot.z = -45f;         //if up right input
                        tempAttackInt = 2;
                    }
                    else if (roundedInput.x == 1 && roundedInput.y == 0)
                    {
                        circCollRot.z = -90f;          //if right input
                        tempAttackInt = 3;
                    }
                    else if (roundedInput.x == 1 && roundedInput.y == -1)
                    {
                        circCollRot.z = -135f;       //if down right input
                        tempAttackInt = 4;
                    }
                    else if (roundedInput.x == 0 && roundedInput.y == -1)
                    {
                        circCollRot.z = -180f;            //if down input
                        tempAttackInt = 5;
                    }
                    else if (roundedInput.x == -1 && roundedInput.y == -1)
                    {
                        circCollRot.z = -225f;        //if down left input
                        tempAttackInt = 4;
                    }
                    else if (roundedInput.x == -1 && roundedInput.y == 0)
                    {
                        circCollRot.z = -270f;            //if left input
                        tempAttackInt = 3;
                    }
                    else if (roundedInput.x == -1 && roundedInput.y == 1)
                    {
                        circCollRot.z = -315f;          //if up left input
                        tempAttackInt = 2;
                    }
                    _PlayerCircColl.transform.eulerAngles = circCollRot;
                    _PlayerCapsuleColl.enabled            = true;
                    _PlayerCircColl.enabled = false;
                }
                if (Input.GetButtonDown(specialInput) && hasSpecial && canMove)
                {
                    phase        = state.SPECIAL;
                    specialTimer = 0;
                }

                //regain dashes once colliding with the ground
                if (_Controller.collisions.below)
                {
                    currentDashCount = dashNum;
                }

                //smooths x movement and overall x movement
                float targetVelocityX = Mathf.Round(input.x) * moveSpeed;
                velocity.x = Mathf.SmoothDamp(velocity.x, targetVelocityX,
                                              ref velocityXSmoothing,
                                              (_Controller.collisions.below)?accelerationTimeGrounded:accelerationTimeAirborne);

                velocity.y += gravity * (1 / 60f) * Time.timeScale;
                break;
            }


//-----------------------------RUN AFTER EVERY FRAME-------------------------------------

            if ((_Controller.collisions.above || _Controller.collisions.below))
            {
                velocity.y = 0;
            }


            _Controller.Move(velocity * (1 / 60f) * Time.timeScale);

//----------------------------ANIMATIONS-------------------------------------------------
            _animator.SetFloat("Speed", Mathf.Abs(input.x));
            _animator.SetFloat("Y Velocity", velocity.y);
            _animator.SetBool("OnGround", _Controller.collisions.below);
            _animator.SetInteger("AtkDirection", tempAttackInt);
        }
コード例 #12
0
    void Update()
    {
        if (!pauseMenu.isPaused)
        {
            directionalInput = new Vector2(rewiredPlayer.GetAxisRaw("Move Horizontal"), rewiredPlayer.GetAxisRaw("Move Vertical"));
            if (directionalInput.x > 0.05f)
            {
                directionalInput.x = 1;
            }
            else if (directionalInput.x < -0.05f)
            {
                directionalInput.x = -1;
            }
            else
            {
                directionalInput.x = 0;
            }

            //if (directionalInput.x != 0 || directionalInput.y != 0)
            //{
            //    EventManager.Instance.PostNotification(EVENT_TYPE.MOVE, this, directionalInput);
            //}
            movementController.SetDirectionalInput(directionalInput);

            if (rewiredPlayer.GetButtonDown("Jump"))
            {
                //Checking for these collision parameters here because we don't want to keep send the jump command in the air, as it resets preJump
                if (controller.collisions.below || controller.collisions.wallSliding)
                {
                    MessageKit.post(EventTypes.JUMP_INPUT_DOWN);
                }
            }

            if (rewiredPlayer.GetButtonUp("Jump"))
            {
                MessageKit.post(EventTypes.JUMP_INPUT_UP);
            }

            if (rewiredPlayer.GetButtonDown("Attack"))
            {
                if (teleportAttack != null &&
                    !animatorController.animationStates.isAttacking &&
                    !animatorController.animationStates.isWallSliding &&
                    !animatorController.animationStates.isHurt)
                {
                    if (!standardAttack.cooldown.active)
                    {
                        if (controller.collisions.below)
                        {
                            standardAttack.cooldown.StartCooldown();
                            MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.GroundedAttack1Animation, PlayerAnimationParameters.GroundedAttack1Parameter);
                        }
                        else
                        {
                            standardAttack.cooldown.StartCooldown();
                            MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.AirAttack1Animation, PlayerAnimationParameters.AirAttack1Parameter);
                        }
                    }
                    else
                    {
                        MessageKit <string> .post(EventTypes.UI_ELEMENT_SHAKE_1P, "Energy_Portrait");
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.R))
            {
                if (controller.collisions.below)
                {
                    MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.GroundedAttack2Animation, PlayerAnimationParameters.GroundedAttack2Parameter);
                }
                else
                {
                    MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.AirAttack2Animation, PlayerAnimationParameters.AirAttack2Parameter);
                }
            }

            if (Input.GetKeyDown(KeyCode.T))
            {
                if (controller.collisions.below)
                {
                    MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.GroundedAttack3Animation, PlayerAnimationParameters.GroundedAttack3Parameter);
                }
                else
                {
                    MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.AirAttack3Animation, PlayerAnimationParameters.AirAttack3Parameter);
                }
            }

            if (rewiredPlayer.GetButtonDown("Teleport Attack"))
            {
                if (teleportAttack != null &&
                    !animatorController.animationStates.isAttacking &&
                    !animatorController.animationStates.isWallSliding &&
                    !animatorController.animationStates.isHurt)
                {
                    if (!teleportAttack.cooldown.active)
                    {
                        teleportAttack.faceDirectionSnapshot = (animatorController.facingRight) ? 1 : -1;
                        if (controller.collisions.below)
                        {
                            teleportAttack.cooldown.StartCooldown();
                            MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.GroundedTeleportAttackAnimation, PlayerAnimationParameters.GroundedTeleportAttackParameter);
                        }
                        else
                        {
                            teleportAttack.cooldown.StartCooldown();
                            MessageKit <string, string> .post(EventTypes.ATTACK_INPUT_DOWN_2P, PlayerAnimationClips.AirTeleportAttackAnimation, PlayerAnimationParameters.AirTeleportAttackParameter);
                        }
                    }
                    else
                    {
                        MessageKit <string> .post(EventTypes.UI_ELEMENT_SHAKE_1P, "Teleport_Icon");
                    }
                }
            }
        }

        if (rewiredPlayer.GetButtonDown("Pause") || rewiredPlayer.GetButtonDown("UIPause"))
        {
            MessageKit.post(EventTypes.UI_PAUSE_MENU);
        }

        //if (Input.GetKeyDown(KeyCode.R))
        //{
        //    attackParameters[0] = "Player_Attack_Heavy";
        //    attackParameters[1] = "IsHeavyAttack";
        //    MessageKit<string[]>.post(EventTypes.ATTACK_INPUT_DOWN_1P, attackParameters);
        //}
    }
コード例 #13
0
        private Vector2 GetRawMoveVector()
        {
            Vector2 move        = Vector2.zero;
            bool    horizButton = false;
            bool    vertButton  = false;

            // Combine inputs of all Players
            for (int i = 0; i < players.Length; i++)
            {
                Rewired.Player player = players[i];
                if (player == null)
                {
                    continue;
                }

                if (moveOneElementPerAxisPress)  // axis press moves only to the next UI element with each press
                {
                    float x = 0.0f;
                    if (player.GetButtonDown(m_HorizontalAxis))
                    {
                        x = 1.0f;
                    }
                    else if (player.GetNegativeButtonDown(m_HorizontalAxis))
                    {
                        x = -1.0f;
                    }

                    float y = 0.0f;
                    if (player.GetButtonDown(m_VerticalAxis))
                    {
                        y = 1.0f;
                    }
                    else if (player.GetNegativeButtonDown(m_VerticalAxis))
                    {
                        y = -1.0f;
                    }

                    move.x += x;
                    move.y += y;
                }
                else     // default behavior - axis press scrolls quickly through UI elements
                {
                    move.x += player.GetAxisRaw(m_HorizontalAxis);
                    move.y += player.GetAxisRaw(m_VerticalAxis);
                }


                horizButton |= player.GetButtonDown(m_HorizontalAxis) || player.GetNegativeButtonDown(m_HorizontalAxis);
                vertButton  |= player.GetButtonDown(m_VerticalAxis) || player.GetNegativeButtonDown(m_VerticalAxis);
            }

            if (horizButton)
            {
                if (move.x < 0)
                {
                    move.x = -1f;
                }
                if (move.x > 0)
                {
                    move.x = 1f;
                }
            }
            if (vertButton)
            {
                if (move.y < 0)
                {
                    move.y = -1f;
                }
                if (move.y > 0)
                {
                    move.y = 1f;
                }
            }
            return(move);
        }