Esempio n. 1
0
        public ShakeInstance StartShake(float magnitude, float roughness, float fadeInTime)
        {
            ShakeInstance shake = new ShakeInstance(magnitude, roughness);

            shake.PositionInfluence = m_DefaultPosInfluence;
            shake.RotationInfluence = m_DefaultRotInfluence;
            shake.StartFadeIn(fadeInTime);
            m_ShakeInstances.Add(shake);
            return(shake);
        }
Esempio n. 2
0
        public ShakeInstance ShakeOnce(float magnitude, float roughness, float fadeInTime, float fadeOutTime, Vector3 posInfluence, Vector3 rotInfluence)
        {
            ShakeInstance shake = new ShakeInstance(magnitude, roughness, fadeInTime, fadeOutTime);

            shake.PositionInfluence = posInfluence;
            shake.RotationInfluence = rotInfluence;
            m_ShakeInstances.Add(shake);

            return(shake);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        private ShakeInstance GetShakeInstance(float scale)
        {
            var shake = new ShakeInstance(m_Magnitude, m_Roughness, m_FadeInTime, m_FadeOutTime);

            shake.PositionInfluence = m_PositionInfluence;
            shake.RotationInfluence = m_RotationInfluence;
            shake.ScaleMagnitude   *= Mathf.Max(scale, m_MinMagnitudeScale);

            return(shake);
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        private ShakeInstance GetShakeInstance()
        {
            var shake = new ShakeInstance(m_Magnitude, m_Roughness, m_FadeInTime, m_FadeOutTime);

            shake.PositionInfluence = m_PositionInfluence;
            shake.RotationInfluence = m_RotationInfluence;
            shake.IsWeapon          = true;

            return(shake);
        }
Esempio n. 5
0
        private void LateUpdate()
        {
            m_PositionAddShake = Vector3.zero;
            m_RotationAddShake = Vector3.zero;

            for (int i = 0; i < m_ShakeInstances.Count; i++)
            {
                if (i >= m_ShakeInstances.Count)
                {
                    break;
                }

                ShakeInstance c = m_ShakeInstances[i];

                if (c.CurrentState == ShakeState.Inactive && c.DeleteOnInactive)
                {
                    m_ShakeInstances.RemoveAt(i);
                    i--;
                }
                else if (c.CurrentState != ShakeState.Inactive)
                {
                    m_PositionAddShake += Vector3.Scale(c.UpdateShake(), c.PositionInfluence);
                    m_RotationAddShake += Vector3.Scale(c.UpdateShake(), c.RotationInfluence);
                }
            }

            float movementSpeed = m_Player.Velocity.Get().magnitude;

            // Update the walk headbob.
            if (m_Player.Walk.Active)
            {
                m_PositionAddBob = m_WalkHeadbob.CalculateBob(movementSpeed, Time.deltaTime);
            }
            else
            {
                m_PositionAddBob = m_WalkHeadbob.Cooldown(Time.deltaTime);
            }

            // Update the run headbob.
            if (m_Player.Run.Active)
            {
                m_PositionAddBob += m_RunHeadbob.CalculateBob(movementSpeed, Time.deltaTime);
            }
            else
            {
                m_PositionAddBob += m_RunHeadbob.Cooldown(Time.deltaTime);
            }

            transform.localPosition    = m_PositionAddShake + m_PositionAddBob;
            transform.localEulerAngles = m_RotationAddShake;
        }
Esempio n. 6
0
 public ShakeInstance Shake(ShakeInstance shake)
 {
     m_ShakeInstances.Add(shake);
     return(shake);
 }