示例#1
0
        /// <summary>Returns a routine that shakes the object using rotation</summary>
        private IEnumerator Rotate()
        {
            PingPongValue rotate = new PingPongValue(-rotation, rotation, int.MaxValue, rotateSpeed, 0.5f);

            while (rotate.Continue())
            {
                transform.eulerAngles = new Vector3(0, 0, rotate.value);
                yield return(null);
            }
        }
示例#2
0
        /// <summary>Returns a routine that shakes the object using scale</summary>
        private IEnumerator Scale()
        {
            PingPongValue scale = new PingPongValue(minScale, transform.localScale.x, int.MaxValue, scaleSpeed);

            while (scale.Continue())
            {
                Vector3 newScale = Vector3.one;
                ConformScaleScaleAxis(ref newScale, scale.value);
                transform.localScale = newScale;
                yield return(null);
            }
        }
示例#3
0
        /// <summary>
        /// Returns a routine that wiggles the character on the x axis
        /// </summary>
        /// <returns></returns>
        private IEnumerator WiggleRoutine()
        {
            while (true)
            {
                PingPongValue wiggle = new PingPongValue(-range, range, 1, speed, 0.5f);
                while (wiggle.Continue())
                {
                    Vector3 position = transform.position;
                    position.x         = anchor.x + wiggle.value;
                    transform.position = position;
                    yield return(null);
                }

                yield return(new WaitForSeconds(Random.Range(minInterval, maxInterval)));
            }
        }
        private IEnumerator ShakeWorld()
        {
            isShaking = true;
            PingPongValue shake     = new PingPongValue(-strength, strength, count, speed, 0.5f);
            Vector3       start     = transform.position;
            int           axisIndex = (int)axis;

            while (shake.Continue())
            {
                Vector3 position = transform.position;
                position[axisIndex] = start[axisIndex] + shake.value;
                transform.position  = position;
                yield return(updateInFixedFrames ? waitFixed : null);
            }

            transform.position = start;
            isShaking          = false;
        }