Exemplo n.º 1
0
 public override void Execute(GameObject agent, MovementValues movementValues)
 {
     if (Input.GetKey(keycode))
     {
         agent.GetComponent <Rigidbody>().velocity += CalculateVelocityVector(agent, movementValues);
     }
 }
        private void JumpVelocityActivity()
        {
            if (JumpPushed &&                       // If the jump button was pushed
                CurrentMovement.JumpVelocity > 0 && // the current movement variable has a non-zero jump velocity
                (mIsOnGround || AfterDoubleJump == null || (AfterDoubleJump != null && mHasDoubleJumped == false))

                )
            {
                mTimeJumpPushed   = CurrentTime;
                this.YVelocity    = CurrentMovement.JumpVelocity;
                mValuesJumpedWith = CurrentMovement;

                if (mCurrentMovement == AirMovement)
                {
                    mHasDoubleJumped = true;
                }
            }

            double secondsSincePush = CurrentTime - mTimeJumpPushed;

            if (mValuesJumpedWith != null &&
                secondsSincePush < mValuesJumpedWith.JumpApplyLength &&
                (mValuesJumpedWith.JumpApplyByButtonHold == false || JumpDown)
                )
            {
                this.YVelocity = mValuesJumpedWith.JumpVelocity;
            }

            if (mValuesJumpedWith != null && mValuesJumpedWith.JumpApplyByButtonHold &&
                (!JumpDown || mHitHead)
                )
            {
                mValuesJumpedWith = null;
            }
        }
Exemplo n.º 3
0
 public Vector3 CalculateVelocityVector(GameObject agent, MovementValues movementValues)
 {
     if (movementValues.isSprinting)
     {
         return(movementValues.moveSpeed * movementValues.sprintMultiplier * agent.transform.right);
     }
     else
     {
         return(movementValues.moveSpeed * agent.transform.right);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Applies the jump input to control vertical velocity and state.
        /// </summary>
        private void ApplyJumpInput()
        {
            bool jumpPushed = JumpInput.WasJustPressed && InputEnabled;
            bool jumpDown   = JumpInput.IsDown && InputEnabled;


            if (jumpPushed &&
                CurrentMovement.JumpVelocity > 0 &&
                (IsOnGround || AfterDoubleJump == null ||
                 (AfterDoubleJump != null && mHasDoubleJumped == false) ||
                 (AfterDoubleJump != null && AfterDoubleJump.JumpVelocity > 0)

                )

                )
            {
                mTimeJumpPushed   = CurrentTime;
                this.YVelocity    = CurrentMovement.JumpVelocity;
                mValuesJumpedWith = CurrentMovement;

                if (JumpAction != null)
                {
                    JumpAction();
                }

                if (CurrentMovementType == MovementType.Air)
                {
                    mHasDoubleJumped = true;
                }
            }

            double secondsSincePush = CurrentTime - mTimeJumpPushed;

            if (mValuesJumpedWith != null &&
                secondsSincePush < mValuesJumpedWith.JumpApplyLength &&
                (mValuesJumpedWith.JumpApplyByButtonHold == false || JumpInput.IsDown)
                )
            {
                this.YVelocity = mValuesJumpedWith.JumpVelocity;
            }

            if (mValuesJumpedWith != null && mValuesJumpedWith.JumpApplyByButtonHold &&
                (!JumpInput.IsDown || mHitHead)
                )
            {
                mValuesJumpedWith = null;
            }

            this.YVelocity = Math.Max(-CurrentMovement.MaxFallSpeed, this.YVelocity);
        }
Exemplo n.º 5
0
    public override void Execute(GameObject agent, MovementValues movementValues)
    {
        if (movementValues.sprintingIsAToggle)
        {
            if (Input.GetKeyDown(keycode))
            {
                movementValues.isSprinting = !movementValues.isSprinting;
            }
        }
        else
        {
            if (Input.GetKeyDown(keycode))
            {
                movementValues.isSprinting = true;
            }

            if (Input.GetKeyUp(keycode))
            {
                movementValues.isSprinting = false;
            }
        }
    }
Exemplo n.º 6
0
        private void JumpVelocity()
        {
            if (JumpPushed &&
                CurrentMovement.JumpVelocity > 0 &&
                (mIsOnGround || AfterDoubleJump == null || (AfterDoubleJump != null && mHasDoubleJumped == false))

                )
            {
                mTimeJumpPushed   = CurrentTime;
                this.YVelocity    = CurrentMovement.JumpVelocity;
                mValuesJumpedWith = CurrentMovement;

                if (CurrentMovementType == MovementType.Air)
                {
                    mHasDoubleJumped = true;
                }
            }

            double secondsSincePush = CurrentTime - mTimeJumpPushed;

            if (mValuesJumpedWith != null &&
                secondsSincePush < mValuesJumpedWith.JumpApplyLength &&
                (mValuesJumpedWith.JumpApplyByButtonHold == false || JumpDown)
                )
            {
                this.YVelocity = mValuesJumpedWith.JumpVelocity;
            }

            if (mValuesJumpedWith != null && mValuesJumpedWith.JumpApplyByButtonHold &&
                (!JumpDown || mHitHead)
                )
            {
                mValuesJumpedWith = null;
            }

            this.YVelocity = Math.Max(-CurrentMovement.MaxFallSpeed, this.YVelocity);
        }
        public void DetermineMovementValues()
        {
            if (mIsOnGround)
            {
                mHasDoubleJumped = false;
                if (CurrentMovement == AirMovement ||
                    CurrentMovement == AfterDoubleJump)
                {
                    mCurrentMovement = GroundMovement;
                }
            }
            else
            {
                if (CurrentMovement == GroundMovement)
                {
                    mCurrentMovement = AirMovement;
                }
            }

            if (mCurrentMovement == AirMovement && mHasDoubleJumped)
            {
                mCurrentMovement = AfterDoubleJump;
            }
        }
Exemplo n.º 8
0
 public abstract void Execute(GameObject agent, MovementValues movementValues);
        private void JumpVelocity()
        {
			bool jumpPushed = JumpInput.WasJustPressed && InputEnabled;
			bool jumpDown = JumpInput.IsDown && InputEnabled;


            if (jumpPushed && 
                CurrentMovement.JumpVelocity > 0 &&
                (mIsOnGround || AfterDoubleJump == null || (AfterDoubleJump != null && mHasDoubleJumped == false))
                
                )
            {

                mTimeJumpPushed = CurrentTime;
                this.YVelocity = CurrentMovement.JumpVelocity;
                mValuesJumpedWith = CurrentMovement;

                if (CurrentMovementType == MovementType.Air)
                {
                    mHasDoubleJumped = true ;
                }
            }

            double secondsSincePush = CurrentTime - mTimeJumpPushed;

            if (mValuesJumpedWith != null && 
                secondsSincePush < mValuesJumpedWith.JumpApplyLength &&
				(mValuesJumpedWith.JumpApplyByButtonHold == false || JumpInput.IsDown)
                )
            {
                this.YVelocity = mValuesJumpedWith.JumpVelocity;

            }

            if (mValuesJumpedWith != null && mValuesJumpedWith.JumpApplyByButtonHold &&
				(!JumpInput.IsDown || mHitHead)
                )
            {
                mValuesJumpedWith = null;
            }

            this.YVelocity = Math.Max(-CurrentMovement.MaxFallSpeed, this.YVelocity);
        }
        private void CustomInitialize()
        {
            mCurrentMovement = GroundMovement;

            YAcceleration = this.CurrentMovement.Gravity;
        }
Exemplo n.º 11
0
 public void SetMovementValues(MovementValues receivedMovementValues)
 {
     movementValues = receivedMovementValues; //some jank to get this working
 }
Exemplo n.º 12
0
        public void DetermineMovementValues()
        {
            if (mIsOnGround)
            {
                mHasDoubleJumped = false;
                if (CurrentMovement == AirMovement ||
                    CurrentMovement == AfterDoubleJump)
                {
                    mCurrentMovement = GroundMovement;
                }
            }
            else
            {
                if (CurrentMovement == GroundMovement)
                {
                    mCurrentMovement = AirMovement;
                }

            }

            if (mCurrentMovement == AirMovement && mHasDoubleJumped)
            {
                mCurrentMovement = AfterDoubleJump;
            }
        


        }
Exemplo n.º 13
0
        private void JumpVelocityActivity()
        {

            if (JumpPushed && // If the jump button was pushed
                CurrentMovement.JumpVelocity > 0 && // the current movement variable has a non-zero jump velocity
                (mIsOnGround || AfterDoubleJump == null || (AfterDoubleJump != null && mHasDoubleJumped == false))
                
                )
            {

                mTimeJumpPushed = CurrentTime;
                this.YVelocity = CurrentMovement.JumpVelocity;
                mValuesJumpedWith = CurrentMovement;

                if (mCurrentMovement == AirMovement)
                {
                    mHasDoubleJumped = true ;
                }
            }

            double secondsSincePush = CurrentTime - mTimeJumpPushed;

            if (mValuesJumpedWith != null && 
                secondsSincePush < mValuesJumpedWith.JumpApplyLength &&
                (mValuesJumpedWith.JumpApplyByButtonHold == false || JumpDown)
                )
            {
                this.YVelocity = mValuesJumpedWith.JumpVelocity;

            }

            if (mValuesJumpedWith != null && mValuesJumpedWith.JumpApplyByButtonHold &&
                (!JumpDown || mHitHead)
                )
            {
                mValuesJumpedWith = null;
            }
        }
Exemplo n.º 14
0
        private void CustomInitialize()
		{
            mCurrentMovement = GroundMovement;

            YAcceleration = this.CurrentMovement.Gravity;

		}