Ejemplo n.º 1
0
        void UpdateTween()
        {
            float _width = _fontComp.Font.MeasureString(_fontComp.Content).Width;

            float startX = _camera.ScreenToWorldCoords(new Vector2(_graphicsDevice.Viewport.Width, 0)).X;
            float midX   = _camera.ScreenToWorldCoords(new Vector2(_graphicsDevice.Viewport.Width / 2, 0)).X;
            float endX   = _camera.ScreenToWorldCoords(new Vector2(0, 0)).X;

            startX += _width / 2;
            endX   -= _width / 2;

            float masterAlpha = _elapsed / Constants.Animations.INTRO_READY_DURATION;

            if (masterAlpha < 0.5f)
            {
                float alpha = masterAlpha * 2;
                float beta  = Easings.CubicEaseOut(alpha);

                float valX = MathHelper.Lerp(startX, midX, beta);
                _transformComp.SetPosition(valX, 0);
            }
            else
            {
                float alpha = (masterAlpha - 0.5f) * 2;
                float beta  = Easings.CubicEaseIn(alpha);

                float valX = MathHelper.Lerp(midX, endX, beta);
                _transformComp.SetPosition(valX, 0);
            }
        }
Ejemplo n.º 2
0
        private void CurveLaserTowardTargets()
        {
            Quaternion minRotation   = Quaternion.identity;
            float      minDeltaAngle = float.MaxValue;

            foreach (Transform laserTarget in laserTargets_)
            {
                Vector3 delta = (laserTarget.position - this.transform.position).normalized;
                delta = delta.SetY(0.0f);
                if (delta.magnitude <= Mathf.Epsilon)
                {
                    continue;
                }

                Quaternion rotationToPlayer = Quaternion.LookRotation(delta.normalized);
                float      deltaAngle       = Quaternion.Angle(this.transform.rotation, rotationToPlayer);
                if (deltaAngle < minDeltaAngle)
                {
                    minDeltaAngle = deltaAngle;
                    minRotation   = rotationToPlayer;
                }
            }

            float rotationMultiplier = Mathf.Clamp(1.0f - Easings.CubicEaseIn(minDeltaAngle / kRotationMaxAngle), 0.0f, 1.0f);
            // in degrees
            float rotationSpeed          = kRotationSpeed * rotationMultiplier * Time.fixedDeltaTime;
            float rotationLerpPercentage = Mathf.Clamp(rotationSpeed / minDeltaAngle, 0.0f, 1.0f);

            rigidbody_.MoveRotation(Quaternion.Lerp(this.transform.rotation, minRotation, rotationLerpPercentage));
        }
Ejemplo n.º 3
0
    // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
    public static float Interpolate(float p, Easings.Functions function)
    {
        switch (function)
        {
        default:
            return(Easings.Linear(p));

        case Easings.Functions.QuadraticEaseIn:
            return(Easings.QuadraticEaseIn(p));

        case Easings.Functions.QuadraticEaseOut:
            return(Easings.QuadraticEaseOut(p));

        case Easings.Functions.QuadraticEaseInOut:
            return(Easings.QuadraticEaseInOut(p));

        case Easings.Functions.CubicEaseIn:
            return(Easings.CubicEaseIn(p));

        case Easings.Functions.CubicEaseOut:
            return(Easings.CubicEaseOut(p));

        case Easings.Functions.CubicEaseInOut:
            return(Easings.CubicEaseInOut(p));

        case Easings.Functions.QuarticEaseIn:
            return(Easings.QuarticEaseIn(p));

        case Easings.Functions.QuarticEaseOut:
            return(Easings.QuarticEaseOut(p));

        case Easings.Functions.QuarticEaseInOut:
            return(Easings.QuarticEaseInOut(p));

        case Easings.Functions.QuinticEaseIn:
            return(Easings.QuinticEaseIn(p));

        case Easings.Functions.QuinticEaseOut:
            return(Easings.QuinticEaseOut(p));

        case Easings.Functions.QuinticEaseInOut:
            return(Easings.QuinticEaseInOut(p));

        case Easings.Functions.SineEaseIn:
            return(Easings.SineEaseIn(p));

        case Easings.Functions.SineEaseOut:
            return(Easings.SineEaseOut(p));

        case Easings.Functions.SineEaseInOut:
            return(Easings.SineEaseInOut(p));

        case Easings.Functions.CircularEaseIn:
            return(Easings.CircularEaseIn(p));

        case Easings.Functions.CircularEaseOut:
            return(Easings.CircularEaseOut(p));

        case Easings.Functions.CircularEaseInOut:
            return(Easings.CircularEaseInOut(p));

        case Easings.Functions.ExponentialEaseIn:
            return(Easings.ExponentialEaseIn(p));

        case Easings.Functions.ExponentialEaseOut:
            return(Easings.ExponentialEaseOut(p));

        case Easings.Functions.ExponentialEaseInOut:
            return(Easings.ExponentialEaseInOut(p));

        case Easings.Functions.ElasticEaseIn:
            return(Easings.ElasticEaseIn(p));

        case Easings.Functions.ElasticEaseOut:
            return(Easings.ElasticEaseOut(p));

        case Easings.Functions.ElasticEaseInOut:
            return(Easings.ElasticEaseInOut(p));

        case Easings.Functions.BackEaseIn:
            return(Easings.BackEaseIn(p));

        case Easings.Functions.BackEaseOut:
            return(Easings.BackEaseOut(p));

        case Easings.Functions.BackEaseInOut:
            return(Easings.BackEaseInOut(p));

        case Easings.Functions.BounceEaseIn:
            return(Easings.BounceEaseIn(p));

        case Easings.Functions.BounceEaseOut:
            return(Easings.BounceEaseOut(p));

        case Easings.Functions.BounceEaseInOut:
            return(Easings.BounceEaseInOut(p));
        }
    }