コード例 #1
0
        //constant spring force.
        void UpdateEarthQuake()
        {
            if (m_client == null || !m_client.UseEarthQuake || m_earthQuakeTimeTemp <= 0.0f || !EarthQuakeToggled || m_elapsedTime > m_client.EarthQuakeTime)
            {
                return;
            }
#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                Debug.LogWarning("earthquake shake can't be updated in editor mode.");
                this.enabled = false;
                return;
            }
#endif


            m_elapsedTime += Time.deltaTime;

            m_earthQuakeTimeTemp -= 0.0166f * (60 * Time.deltaTime);

            float magnitude = 0f;
            if (m_client.EarthQuakeMagTye == MAGTYPE.Fixed)
            {
                magnitude = m_client.EarthQuakeMagnitude;
            }
            else if (m_client.EarthQuakeMagTye == MAGTYPE.Curve_OBSOLETE)
            {
                magnitude = m_client.EarthQuakeMagCurve.Evaluate(m_elapsedTime);
            }
            else
            {
                magnitude = m_client.EarthQuakeMagCurveX.Evaluate(m_elapsedTime);
            }

            Vector3 horizMove = Vector3.Scale(XftSmoothRandom.GetVector3Centered(1), new Vector3(magnitude,
                                                                                                 0, magnitude)) * Mathf.Min(m_earthQuakeTimeTemp, 1.0f);

            float vertMove = 0;
            if (UnityEngine.Random.value < 0.3f)
            {
                vertMove = UnityEngine.Random.Range(0, (magnitude * 0.35f)) * Mathf.Min(m_earthQuakeTimeTemp, 1.0f);
                if (PositionSpring.State.y >= PositionSpring.RestState.y)
                {
                    vertMove = -vertMove;
                }
            }

            PositionSpring.AddForce(horizMove);



            RotationSpring.AddForce(new Vector3(0, 0, -horizMove.x * 2) * m_client.EarthQuakeCameraRollFactor);


            PositionSpring.AddForce(new Vector3(0, vertMove, 0));
        }
コード例 #2
0
        //constant spring force.
        void UpdateEarthQuake()
        {
            if (m_client == null || !m_client.UseEarthQuake || m_earthQuakeTimeTemp <= 0.0f ||
                !EarthQuakeToggled || m_client.ElapsedTime > m_client.EarthQuakeTime)
            {
                return;
            }

            m_earthQuakeTimeTemp -= 0.0166f * (60 * Time.deltaTime);

            float magnitude = 0f;

            if (m_client.EarthQuakeMagTye == MAGTYPE.Fixed)
            {
                magnitude = m_client.EarthQuakeMagnitude;
            }
            else if (m_client.EarthQuakeMagTye == MAGTYPE.Curve_OBSOLETE)
            {
                magnitude = m_client.EarthQuakeMagCurve.Evaluate(m_client.ElapsedTime);
            }
            else
            {
                magnitude = m_client.EarthQuakeMagCurveX.Evaluate(m_client.ElapsedTime);
            }

            Vector3 horizMove = Vector3.Scale(XftSmoothRandom.GetVector3Centered(1), new Vector3(magnitude,
                                                                                                 0, magnitude)) * Mathf.Min(m_earthQuakeTimeTemp, 1.0f);

            float vertMove = 0;

            if (UnityEngine.Random.value < 0.3f)
            {
                vertMove = UnityEngine.Random.Range(0, (magnitude * 0.35f)) * Mathf.Min(m_earthQuakeTimeTemp, 1.0f);
                if (PositionSpring.State.y >= PositionSpring.RestState.y)
                {
                    vertMove = -vertMove;
                }
            }

            PositionSpring.AddForce(horizMove);

            RotationSpring.AddForce(new Vector3(0, 0, -horizMove.x * 2) * m_client.EarthQuakeCameraRollFactor);
            PositionSpring.AddForce(new Vector3(0, vertMove, 0));
        }