Exemple #1
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();
     }
 }
Exemple #2
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);
        }