Esempio n. 1
0
 private void Update()
 {
     if (!endGme)
     {
         if (score1 >= 27)
         {
             repuPanel.gameObject.SetActive(true);
             repuText.text = score1.ToString() + "/" + score2.ToString();
             EndGame();
         }
         else if (score2 >= 27)
         {
             demoPanel.gameObject.SetActive(false);
             demoText.text = score2.ToString() + "/" + score1.ToString();
             EndGame();
         }
     }
     if (endGme)
     {
         if (player.GetButtonDown("Action"))
         {
             SceneManager.LoadScene(SceneManager.GetActiveScene().name);
         }
         if (player.GetButtonDown("Hit"))
         {
             SceneManager.LoadScene("MainMenu");
         }
         if (player.GetButtonDown("Y"))
         {
             SceneManager.LoadScene("Selection screen");
         }
     }
 }
Esempio n. 2
0
 // the Update loop contains a very simple example of moving the character around and controlling the animation
 void Update()
 {
     if (this._grabbable.IsHeld)
     {
         this._myRigidbody.isKinematic = true;
         Rewired.Player p = Rewired.ReInput.players.GetPlayer(this._ratPlayer.PlayerID);
         if (p.GetButtonDoublePressDown("Jump") || p.GetButtonDoublePressDown("Interact"))
         {
             this.GetComponent <Projectile>()?.LastYeeter?.Drop();
             this._velocity                    = Vector3.zero;
             this._myRigidbody.velocity        = Vector3.zero;
             this._myRigidbody.angularVelocity = 0f;
             //depen with no fling after the fact.
             this._controller.Move(Vector3.zero);
             this._controller.ResetVelocity();
         }
         _animator.Play(Animator.StringToHash("Yote"));
     }
     else if (this.IsYote)
     {
         Rewired.Player p = Rewired.ReInput.players.GetPlayer(this._ratPlayer.PlayerID);
         if (p.GetButtonDown("Jump") || p.GetButtonDown("Interact") || this._myRigidbody.isKinematic)
         {
             LeaveYote();
         }
         _animator.Play(Animator.StringToHash("Yote"));
     }
     else
     {
         //we shouldn't need to set these values, but this is a quickfix for some weird edgecase I can't repro.
         this._myRigidbody.isKinematic = true;
         this._myRigidbody.simulated   = true;
         DoMove();
     }
 }
Esempio n. 3
0
        private void Update()
        {
            // Check if an item should be enable during display
            foreach (GameAction choice in choices)
            {
                SetButtonEnabled(choice.graphics, choice.IsEnabled);
            }


            if (inputManager == null)
            {
                return;
            }

            if (inputManager.GetButtonDown("MenuLeft"))
            {
                GoLeft();
            }
            else if (inputManager.GetButtonDown("MenuRight"))
            {
                GoRight();
            }
            else if (inputManager.GetButtonDown("Interact"))
            {
                Validate();
            }
            else if (inputManager.GetButtonDown("Cancel"))
            {
                Hide();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Process submit keys.
        /// </summary>
        private bool SendSubmitEventToSelectedObject()
        {
            if (eventSystem.currentSelectedGameObject == null)
            {
                return(false);
            }
            if (recompiling)
            {
                return(false);
            }

            var data = GetBaseEventData();

            for (int i = 0; i < playerIds.Length; i++)
            {
                Rewired.Player player = ReInput.players.GetPlayer(playerIds[i]);
                if (player == null)
                {
                    continue;
                }

                if (player.GetButtonDown(m_SubmitButton))
                {
                    ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler);
                    break;
                }

                if (player.GetButtonDown(m_CancelButton))
                {
                    ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler);
                    break;
                }
            }
            return(data.used);
        }
Esempio n. 5
0
    private void Update()
    {
        if (canRestart)
        {
            if (player1.GetButtonDown(RewiredConsts.Action.Pause) || player2.GetButtonDown(RewiredConsts.Action.Pause))
            {
                Restart();
            }
        }
#if UNITY_EDITOR || INTERNAL_BUILD
        if (Input.GetKeyDown(KeyCode.R))
        {
            Restart();
        }
#endif
        if ((Input.GetKeyDown(KeyCode.P) || player1.GetButtonDown(RewiredConsts.Action.Pause) || player2.GetButtonDown(RewiredConsts.Action.Pause)) && !canRestart && canPause)
        {
            if (PhotonNetwork.IsConnected)
            {
                photonView.RPC(nameof(Pause), RpcTarget.All);
            }
            else
            {
                Pause();
            }
        }
        if ((Input.GetKeyDown(KeyCode.Q) || (isPaused && (player1.GetButtonDown(RewiredConsts.Action.Back) || player2.GetButtonDown(RewiredConsts.Action.BackToMenu)))))
        {
            isPaused       = false;
            Time.timeScale = 1f;
            if (!PhotonNetwork.IsConnected)
            {
                SceneManager.LoadScene("scn_menu");
            }
            else
            {
                NetworkManager.Instance.ReturnToMenu();
            }
        }
#if UNITY_EDITOR || INTERNAL_BUILD
        autoGameOverWinner = Input.GetKeyDown(KeyCode.Alpha1) ? (byte)1 : Input.GetKeyDown(KeyCode.Alpha2) ? (byte)2 : (byte)0;
#endif
        if (autoGameOverWinner > 0)
        {
            if (autoGameOverWinner == 1)
            {
                StartCoroutine(HandleGameOver(backWalls[1].playerPosition));
            }
            if (autoGameOverWinner == 2)
            {
                StartCoroutine(HandleGameOver(backWalls[0].playerPosition));
            }
            autoGameOverWinner = 0;
        }
    }
    private void instructionsScroll()
    {
        if (gamePadController1.GetButtonDown("Menu Left") || gamePadController2.GetButtonDown("Menu Left"))
        {
            goLeft();
        }

        if (gamePadController1.GetButtonDown("Menu Right") || gamePadController2.GetButtonDown("Menu Right"))
        {
            goRight();
        }
    }
Esempio n. 7
0
        public override bool ShouldActivateModule()
        {
            if (!base.ShouldActivateModule())
            {
                return(false);
            }
            if (recompiling)
            {
                return(false);
            }
            if (!ReInput.isReady)
            {
                return(false);
            }

            bool shouldActivate = false;

            // Combine input for all players
            for (int i = 0; i < playerIds.Length; i++)
            {
                Rewired.Player player = ReInput.players.GetPlayer(playerIds[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);
                }
            }

            if (isMouseSupported)
            {
                shouldActivate |= (m_MousePosition - m_LastMousePosition).sqrMagnitude > 0.0f;
                shouldActivate |= ReInput.controllers.Mouse.GetButtonDown(0);
            }

            return(shouldActivate);
        }
Esempio n. 8
0

        
Esempio n. 9
0
 void UpdatePause()
 {
     if (GameManager.instance.isRunning && (Input.GetKeyDown(KeyCode.Escape) || pInput.GetButtonDown(Globals.BtnStart)))
     {
         Pause = !Pause;
     }
 }
Esempio n. 10
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));
            }
        }
Esempio n. 11
0
 // Extra Inputs
 public override void HandleExtraInput(Rewired.Player input)
 {
     if (input.GetButtonDown("ViewLevel"))
     {
         StartViewingLevel();
     }
 }
Esempio n. 12
0
    private bool GetButtonDown(string p_button)
    {
        if (m_listeningToAllInputs || m_handlingPlayer == null)
        {
            foreach (Rewired.Player player in Rewired.ReInput.players.Players)
            {
                if (player.GetButtonDown(p_button))
                {
                    if (m_handlingPlayer == null)
                    {
                        m_handlingPlayer = player;
                        Game.m_options.UpdateUIControls();
                    }

                    return(true);
                }
            }
        }
        else
        {
            return(m_handlingPlayer.GetButtonDown(p_button));
        }

        return(false);
    }
    // Update is called once per frame
    void Update()
    {
        if (!isReady)
        {
            //check1.SetActive(gamePadController1.GetButton("Jump")); // visual check for player 1
            //check2.SetActive(gamePadController2.GetButton("Jump")); // visual check for player 2
            toggleConfirmation(check1, gamePadController1); // visual check for player 1
            toggleConfirmation(check2, gamePadController2); // visual check for player 2
        }

        // Go To Game Scene
        if (gamePadController1.GetButton("Jump") && gamePadController2.GetButton("Jump") || Input.GetKeyDown(KeyCode.Return))
        {
            isReady = true;
            toggleConfirmation(check1, null, true); // visual check for player 1
            toggleConfirmation(check2, null, true); // visual check for player 2
            IEnumerator fadeSound = AudioFadeOut.FadeOut(sound, 2.0f);
            StartCoroutine(fadeSound);
            SceneChanger.setSceneIndexSelected(SceneChanger.GAME);
            FindObjectOfType <SceneChanger>().GetComponent <Animator>().SetTrigger("FadeOut");
        }

        // Go Back To Main Menu Scene
        if (gamePadController1.GetButtonDown("Camera Flip") || gamePadController2.GetButtonDown("Camera Flip"))
        {
            SceneChanger.setSceneIndexSelected(SceneChanger.MENU);
            FindObjectOfType <SceneChanger>().GetComponent <Animator>().SetTrigger("FadeOut");
        }
    }
Esempio n. 14
0
        private void GetInput()
        {
            upInput     = false;
            downInput   = false;
            acceptInput = false;

            if (player.GetAxis("Move Depth") == 0)
            {
                selectingUp   = false;
                selectingDown = false;
            }

            if (player.GetAxis("Move Depth") > 0 && !selectingUp)
            {
                upInput     = true;
                selectingUp = true;
            }

            if (player.GetAxis("Move Depth") < 0 && !selectingDown)
            {
                downInput     = true;
                selectingDown = true;
            }

            if (player.GetButtonDown("Action"))
            {
                acceptInput = true;
            }
        }
Esempio n. 15
0
    private void Update()
    {
        if (_player.GetButtonDown("UIPlay"))
        {
            Debug.Log("Play");
        }

        if (_player.GetButtonDown("UICancel"))
        {
            Debug.Log("Cancel");
        }

        if (_player.GetButtonDown("UISubmit"))
        {
            Debug.Log("Submit");
        }
    }
Esempio n. 16
0
	void Update ()
    {
        if (!GameManager.instance.isRunning)
        {
            return;
        }

        if (pInput.GetButtonDown(Globals.BtnAction4))
        {
            RestartCheckPoint();
        }

		if (Input.GetKeyDown(restartKeycode) || pInput.GetButtonDown(Globals.BtnBack))
        {
            RestartScene();
        }
	}
Esempio n. 17
0
 // Update is called once per frame
 void Update()
 {
     if (rewiredPlayer.GetButtonDown(RewiredConsts.Action.Jump))//Input.GetKeyDown(KeyCode.Space))
     {
         int index = Random.Range(0, listJump.Length);
         sfxClip          = listJump[index];
         audioSource.clip = sfxClip;
         audioSource.Play();
     }
     if (rewiredPlayer.GetButtonDown(RewiredConsts.Action.PerspectiveSwitch))//Input.GetMouseButtonDown(0))
     {
         int index = Random.Range(0, listWhoosh.Length);
         sfxClip          = listWhoosh[index];
         audioSource.clip = sfxClip;
         audioSource.Play();
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (canShake)
        {
            shakeLeft  = gamePadController.GetButtonDown("ShakeLeft");
            shakeRight = gamePadController.GetButtonDown("ShakeRight");

            if (shakeLeft)
            {
                camShakeLeft();
            }
            else if (shakeRight)
            {
                camShakeRight();
            }
        }
    }
    private void UpdateInteraction()
    {
        bool isInteractionPressed = _rewiredPlayer.GetButtonDown(RewiredConsts.Action.Interact);

        if (_astronaut != null && isInteractionPressed)
        {
            _astronaut.PressInteraction();
        }
    }
Esempio n. 20
0
 private void Update()
 {
     if ((player1.GetButtonDown("Start") || player2.GetButtonDown("Start")) &&
         canChangeScene)
     {
         StopAllCoroutines();
         SceneManager.LoadScene("scn_menu");
     }
 }
Esempio n. 21
0
        /// <summary>
        /// Check for inputs & updates rotation
        /// </summary>
        private void CheckForRotation()
        {
            if (_player1.GetButtonDown("RotateCamLeft"))
            {
                _wantedAngle.y += ROTATION_ANGLE * Mathf.Deg2Rad;
                ForwardVector   = Quaternion.AngleAxis(ROTATION_ANGLE, Vector3.up) * ForwardVector;
            }

            if (_player1.GetButtonDown("RotateCamRight"))
            {
                _wantedAngle.y -= ROTATION_ANGLE * Mathf.Deg2Rad;
                ForwardVector   = Quaternion.AngleAxis(-ROTATION_ANGLE, Vector3.up) * ForwardVector;
            }

            transform.rotation = Quaternion.Lerp(transform.rotation,
                                                 Quaternion.Euler(_wantedAngle * Mathf.Rad2Deg),
                                                 rotatingSpeed * Time.deltaTime);
        }
Esempio n. 22
0
        private bool CheckButtonOrKeyMovement(float time)
        {
            bool allow = false;

            for (int i = 0; i < playerIds.Length; i++)
            {
                Rewired.Player player = ReInput.players.GetPlayer(playerIds[i]);
                if (player == null)
                {
                    continue;
                }

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

            return(allow);
        }
Esempio n. 23
0
    public override bool GetButtonDown(int button)
    {
        if (!isEnabled)
        {
            return(false);
        }

        return(input.GetButtonDown(button));
    }
Esempio n. 24
0
        private void Update()
        {
            Vector2 moveInput = GetMoveInput();

            SetDesiredVelocity(moveInput);

            if (m_input.GetButtonDown(Action.Jump))
            {
                TryJump();
            }
        }
Esempio n. 25
0
 public AttackOutput GetAttackInput()
 {
     if (active)
     {
         if (player.GetButtonDown("Attack"))
         {
             return(new AttackOutput(true, new Vector2(player.GetAxis("Aim Horizontal"), player.GetAxis("Aim Vertical")).normalized));
         }
     }
     return(new AttackOutput(false, new Vector2(0, 0)));
 }
Esempio n. 26
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);
    }
Esempio n. 27
0
    // Update is called once per frame
    void Update()
    {
        thrust = maxThrust;
        thrust = Mathf.Clamp(thrust, 0, maxThrust);
        if (engines.Running)
        {
            Vector3 movementInput = new Vector3(0, 0, thrust);
            movementInput      = aimSpace.TransformVector(movementInput);
            controller.Pushing = movementInput.sqrMagnitude > 0.25f * 0.25f;
            controller.AddForceRelative(movementInput.normalized);
        }

        Vector3 rotationInput = new Vector3(
            player.GetAxis("Pitch"),
            player.GetAxis("Yaw"),
            player.GetAxis("Roll")
            );

        controller.Spinning = rotationInput.sqrMagnitude > 0.25f * 0.25f;
        controller.AddTorqueRelative(Vector3.Scale(rotationInput, controller.Drifting?driftingRotationFactors:rotationFactors));

        if (player.GetButtonDown("Slow Mo") && engines.Running)
        {
            engines.TurnOff();
        }
        if (player.GetButtonDown("Start Engine") && !engines.Running)
        {
            engines.TurnOn();
        }

        if (player.GetButton("Fire"))
        {
            Missile m = guns.Fire();
            if (m != null)
            {
                m.SetTarget(targetingSystem.GetLockedTarget());
            }
        }
    }
Esempio n. 28
0
    void Update()
    {
        if (!startPressed && pInput.GetButtonDown(Globals.BtnStart))
        {
            startPressed = true;
            pressStart.onClick.Invoke();
        }

        timeColor += speedColor * Time.deltaTime;
        timeColor %= 359f;

        cameraVHS.feedbackColor = Color.HSVToRGB(timeColor / 359f, 1f, 1f);
    }
        protected void OnScores()
        {
            if (input.GetButtonDown(PlayerInputActions.Scores))
            {
                if (UIManager.singleton.hasCurPanel(0))
                {
                    return;
                }

                var myPlayerTeamId = 0;

                var myPlayerSingleton = GetSingleton <MyPlayerSingleton>();
                if (myPlayerSingleton.playerEntity != default)
                {
                    myPlayerTeamId = EntityManager.GetComponentData <PlayerTeam>(myPlayerSingleton.playerEntity).value;
                }


                //
                Entities
                .WithAllReadOnly <Player, PlayerName, PlayerScore, PlayerTeam>()
                .WithNone <PlayerDestroyNetMessages>()
                .ForEach((ref PlayerName playerName, ref PlayerScore playerScore, ref PlayerTeam playerTeam) =>
                {
                    var scoreInfo = new ScoreInfo {
                        name = playerName.value.ToString(), score = playerScore.value
                    };
                    playerScores.Add(scoreInfo);

                    var playerTeamId = playerTeam.value;
                    if (playerTeamId != 0 && playerTeamId == myPlayerTeamId)    //my team
                    {
                        myTeamScores.Add(scoreInfo);
                    }
                });

                ScoresPanel.singleton.setScores(playerScores, myTeamScores);
                ScoresPanel.singleton.startIn();

                playerScores.Clear();
                myTeamScores.Clear();
            }

            if (input.GetButtonUp(PlayerInputActions.Scores))
            {
                if (ScoresPanel.singleton.visible)
                {
                    ScoresPanel.singleton.startOut();
                }
            }
        }
Esempio n. 30
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));
     }
 }