Пример #1
0
        //
        protected void OnExit()
        {
            if (input.GetButtonUp(PlayerInputActions.Exit) &&
                UIManager.singleton.hasCurPanel(0) == false)
            {
                PlayerPanel.singleton.clientWorld = clientWorld;
                PausePanel.singleton.startIn();

                PausePanel.singleton.StartCoroutine(playerInputClientSystemEnabled());
            }
        }
Пример #2
0
        private void Poll(InputPlayer player, InputEventPollingType pollingType)
        {
            InputReceiver receiver = _receivers[player];

            if (receiver == null)
            {
                return;
            }

            Rewired.Player rePlayer = ReInput.players.GetPlayer((int)receiver.InputPlayer);
            foreach (var action in ReInput.mapping.Actions)
            {
                if (rePlayer.GetButtonDown(action.id))
                {
                    _receivers[player]?.ReceiveButtonEvent(new InputActionEvent(action.id, pollingType, InputEventType.Down));
                }
                if (rePlayer.GetButtonUp(action.id))
                {
                    _receivers[player]?.ReceiveButtonEvent(new InputActionEvent(action.id, pollingType, InputEventType.Up));
                }
                if (rePlayer.GetButton(action.id))
                {
                    _receivers[player]?.ReceiveButtonEvent(new InputActionEvent(action.id, pollingType, InputEventType.Hold));
                }

                _receivers[player]?.ReceiveAxisEvent(rePlayer.GetAxis(action.id), new InputAxisEvent(action.id, pollingType));
            }
        }
Пример #3
0
    public override bool GetButtonUp(int button)
    {
        if (!isEnabled)
        {
            return(false);
        }

        return(input.GetButtonUp(button));
    }
Пример #4
0
    private void Update()
    {
        if (!Rewired.ReInput.isReady)
        {
            return;
        }

        Rewired.Player player = Rewired.ReInput.players.GetPlayer(0);

        if (IsDragging)
        {
            // If current dragged thing was destroyed, cancel drag
            if (_currentDraggable == null)
            {
                StopDrag();
                return;
            }

            float   distanceScale  = Vector3.Distance(Camera.main.transform.position, _currentDraggable.position);
            float   horizontalAxis = player.GetAxis("CursorX") * Time.deltaTime * _handDragSensitivity;
            float   verticalAxis   = player.GetAxis("CursorY") * Time.deltaTime * _handDragSensitivity;
            Vector3 cameraMovement = Camera.main.transform.position - _dragStartCameraPos;
            _targetHandPos     += Camera.main.transform.right.WithY(0).normalized *horizontalAxis *distanceScale;
            _targetHandPos     += Camera.main.transform.forward.WithY(0).normalized *verticalAxis *distanceScale;
            _targetHandPos     += cameraMovement;
            _targetHandPos.y    = _handDragHeight;
            _dragStartCameraPos = Camera.main.transform.position;

            _isRotating = player.GetButton("Context");
        }
        else
        {
            Ray        mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;
            bool       hit = Physics.Raycast(mouseRay, out hitInfo, 100.0f, _raycastMask);
            if (hit)
            {
                _targetHandPos = hitInfo.point + hitInfo.normal * _handHoverDistance;

                if (player.GetButtonDown("Select"))
                {
                    StartDrag(hitInfo);
                }
            }
        }

        if (player.GetButtonUp("Select"))
        {
            StopDrag();
        }

        _handObject.transform.position = Mathfx.Damp(_handObject.transform.position, _targetHandPos, 0.5f, Time.deltaTime * _handAnimateSpeed);
    }
        protected override void OnUpdate()
        {
            if (input.GetButtonDown(PlayerInputActions.Shift))
            {
                begin();
            }
            else if (input.GetButtonUp(PlayerInputActions.Shift))
            {
                end();
            }

            if (input.GetButton(PlayerInputActions.Shift))
            {
                update();
            }
        }
Пример #6
0
    /*public void changeGroundState(bool newState)
     * {
     *  isGrounded = newState;
     * }*/

    private void Update()
    {
        if (rewiredPlayer.GetButton(RewiredConsts.Action.Jump))
        {
            timer += Time.deltaTime;
        }
        else if (rewiredPlayer.GetButtonUp(RewiredConsts.Action.Jump))
        {
            timer = 0;
        }
        if (isjumping)
        {
            if (timer > 0.3f)
            {
                ActivateFlying();
            }
        }
        if (canUseJetpack)
        {
            JetPack();
        }
    }
Пример #7
0
 public bool GetButtonUp(string button)
 {
     return(player.GetButtonUp(button));
 }
Пример #8
0
        public void UpdateKeyboard()
        {
            if (StopInput)
            {
                Direction = Vector2.zero;

                Jump   = false;
                Sprint = false;

                DodgeLeft  = false;
                DodgeRight = false;

                return;
            }

            // We get our horizontal/vertical inputs as integers so we don't have to deal with floating point value errors
            Direction.x = (int)(Sprint ? 0 : Inputs.GetAxis("Horizontal"));
            Direction.y = (int)(Sprint ? 1 : Inputs.GetAxis("Vertical"));

            Jump     = Inputs.GetButtonDown("Jump");
            HoldJump = Inputs.GetButton("Jump");

            if (Inputs.GetButtonDoublePressDown("Vertical"))
            {
                Sprint = true;
            }
            else if (Inputs.GetButtonUp("Vertical") || Jump || AnyAttack)
            {
                Sprint = false;
            }

            // Reset the dodge bools before we use it
            DodgeLeft  = false;
            DodgeRight = false;
            if (Settings.GameSettingsManager.Instance.ControlSettings.Save.ControlDoubleTapDodge != 0)
            {
                DodgeLeft  = Inputs.GetNegativeButtonDoublePressDown("Horizontal") && !DodgeRight;
                DodgeRight = Inputs.GetButtonDoublePressDown("Horizontal") && !DodgeLeft;
            }
            else
            {
                DodgeLeft  = Direction.x < 0 && Direction.y == 0 && Jump && !DodgeRight;
                DodgeRight = Direction.x > 0 && Direction.y == 0 && Jump && !DodgeLeft;
            }

            if (Inputs.GetButtonDown("Camera Side"))
            {
                CameraSide = !CameraSide;
            }

            // Select Weapon
            if (Inputs.GetButtonDown("Weapon 1"))
            {
                WeaponNumber = 0;
            }
            if (Inputs.GetButtonDown("Weapon 2"))
            {
                WeaponNumber = 1;
            }
            if (Inputs.GetButtonDown("Weapon 3"))
            {
                WeaponNumber = 2;
            }

            // Scroll Weapon
            if (Inputs.GetAxis("Scroll Weapon") * MouseScrollSpeed >= 1)
            {
                WeaponNumber--;
            }
            else if (Inputs.GetAxis("Scroll Weapon") * MouseScrollSpeed <= -1)
            {
                WeaponNumber++;
            }
            // Infinite scroll allows us to go to the first weapon if we attempt to scroll down on the last weapon
            if (Settings.GameSettingsManager.Instance.ControlSettings.Save.ControlWeaponSwitchInfiniteScroll != 0)
            {
                // Just reset the number
                WeaponNumber = WeaponNumber > 2 ? 0 : WeaponNumber < 0 ? 2 : WeaponNumber;
            }

            WeaponNumber = Mathf.Clamp(WeaponNumber, 0, 2);
        }
Пример #9
0
 // Update is called once per frame
 private void Update()
 {
     if (canMove && !GameManager.Instance.isPaused && (!PhotonNetwork.IsConnected || (PhotonNetwork.IsConnected && photonView.IsMine)))
     {
         input = ReadMovement();
         if (PhotonNetwork.IsConnected && player != null)
         {
             if (player.GetButtonDown(RewiredConsts.Action.Dash) && playerStatus == PlayerStatus.None)
             {
                 photonView.RPC(nameof(Dash), RpcTarget.All);
             }
             else if (player.GetButtonDown(RewiredConsts.Action.Charge) && playerStatus == PlayerStatus.None)
             {
                 AssignChargeCoroutine();
                 photonView.RPC(nameof(Move), RpcTarget.All);
             }
             else if ((player.GetButtonDown(RewiredConsts.Action.Swing) && playerStatus == PlayerStatus.None) || (chargeCoroutine != null && (player.GetButtonUp(RewiredConsts.Action.Charge) || !player.GetButton(RewiredConsts.Action.Charge))))
             {
                 StopChargeCoroutine();
                 photonView.RPC(nameof(Swing), RpcTarget.All, orientation, currentCharge);
                 //ReleaseCharge(Color.white);
             }
             else
             {
                 //Regular movement
                 photonView.RPC(nameof(Move), RpcTarget.All);
             }
         }
         else if (player != null)
         {
             if (player.GetButtonDown(RewiredConsts.Action.Dash) && playerStatus == PlayerStatus.None)
             {
                 Dash();
             }
             else if (player.GetButtonDown(RewiredConsts.Action.Charge) && playerStatus == PlayerStatus.None)
             {
                 AssignChargeCoroutine();
                 Move();
             }
             else if ((player.GetButtonDown(RewiredConsts.Action.Swing) && playerStatus == PlayerStatus.None) || (chargeCoroutine != null && (player.GetButtonUp(RewiredConsts.Action.Charge) || !player.GetButton(RewiredConsts.Action.Charge))))
             {
                 StopChargeCoroutine();
                 Swing(orientation, currentCharge);
                 //ReleaseCharge(Color.white);
             }
             else
             {
                 //Regular movement
                 Move();
             }
         }
     }
     else if (PhotonNetwork.IsConnected && !photonView.IsMine)
     {
         transform.position = Vector3.Lerp(transform.position, networkPosition, networkDistance * (1f / PhotonNetwork.SerializationRate));
     }
 }