示例#1
0
        public void SetJumpFrom(Instruction ins)
        {
            if (JumpedFrom == null)
            {
                JumpedFrom = new List <Instruction>();
            }

            if (!JumpedFrom.Contains(ins))
            {
                JumpedFrom.Add(ins);
            }
        }
示例#2
0
        private bool TryStart_Jump()
        {
            bool canJump = m_EnableJumping &&
                           Player.Stamina.Get() > 5f &&
                           (Player.IsGrounded.Get() || Player.NearLadders.Count > 0) &&
                           (!Player.Crouch.Active || Player.Crouch.TryStop());

            if (canJump)
            {
                Vector3 jumpDirection = Vector3.up;
                //float surfaceAngle = Vector3.Angle(Vector3.up, m_LastSurfaceNormal);

                if (Player.NearLadders.Count > 0)
                {
                    jumpDirection = -Player.NearLadders.Peek().forward;
                }
                // Jump more perpendicular to the surface, on steep surfaces.
                //else if(surfaceAngle > 30f)
                //	jumpDirection = Vector3.Lerp(Vector3.up, m_LastSurfaceNormal, surfaceAngle / 60f).normalized;

                m_CurrentVelocity.y = 0f;

                if (Player.NearLadders.Count > 0)
                {
                    m_CurrentVelocity += jumpDirection * m_JumpSpeedFromLadder;
                    m_JumpedFrom       = JumpedFrom.Ladder;
                }
                else
                {
                    m_CurrentVelocity += jumpDirection * CalculateJumpSpeed(m_JumpHeight);
                    m_JumpedFrom       = JumpedFrom.Ground;
                }

                return(true);
            }

            return(false);
        }