コード例 #1
0
    public float CalculateVolume(float interpolationTime)
    {
        switch (FadeType)
        {
        case FadeType.Linear:
            return(EasingFunctions.Linear(_fromValue, _toValue, interpolationTime));

        case FadeType.ExpoIn:
            return(EasingFunctions.ExponentialIn(_fromValue, _toValue, interpolationTime));

        case FadeType.ExpoOut:
            return(EasingFunctions.ExponentialOut(_fromValue, _toValue, interpolationTime));

        case FadeType.QuadraticIn:
            return(EasingFunctions.QuadraticIn(_fromValue, _toValue, interpolationTime));

        case FadeType.QuadraticOut:
            return(EasingFunctions.QuadraticOut(_fromValue, _toValue, interpolationTime));

        default:
            // If fade type is none or undefined, return fade factor of 1f
            Debug.LogWarning("Hey! Invalid fade type: " + FadeType.ToString());
            return(1f);
        }
    }
コード例 #2
0
    private void jumpUp()
    {
        var finalNewPos = posInMapToWorldPos(positionInMap + Isometric.vectorToIsoDirection(currentForwardDirection) + Isometric.vectorToIsoDirection(IsoDirection.Up));
        var tempNewPos  = posInMapToWorldPos(positionInMap + Isometric.vectorToIsoDirection(currentForwardDirection) * 2 / 3f + Isometric.vectorToIsoDirection(IsoDirection.Up) * 4 / 3f);

        inAction = true;
        moveTo(tempNewPos, (x) => EasingFunctions.Linear(x, 0, 1, forwardSpeed * 2 / 3f), () => {
            moveTo(finalNewPos, (x) => EasingFunctions.Linear(x, 0, 1, forwardSpeed * 1 / 3f), () => {
                positionInMap = positionInMap + Isometric.vectorToIsoDirection(currentForwardDirection) + Isometric.vectorToIsoDirection(IsoDirection.Up);
                inAction      = false;
            }, 0, forwardSpeed * 1 / 3f);
        }, 0, forwardSpeed * 2 / 3f);
    }
コード例 #3
0
        void Update()
        {
            if (!curve.Init())
            {
                return;
            }

            t += Time.deltaTime / duration;
            t %= 1;

            float easedT = EasingFunctions.Linear(t); // you can use any easing function here

            float        arcLength;
            CurveSegment curveSegment = curve.CurveSegmentAtArcLength(easedT * curve.ArcLength(curve.CurveCount()), out arcLength);
            float        curveT       = curveSegment.ComputeTAtArcLength(arcLength);

            transform.position = curveSegment.Evaluate(curveT);
            transform.forward  = curveSegment.EvaluateDv(curveT);
        }
コード例 #4
0
ファイル: Easing.cs プロジェクト: Syncinus/Rhythm_Game
    private IEnumerator _Run(Action <float> Execute)
    {
        Debug.Log("Run");
        float Timer = 0f;

        while (Timer < Duration)
        {
            float Progress = Mathf.Min(Timer / Duration, 1);
            float Value    = Progress;
            if (Type.ToLower() == "linear")
            {
                Value = EasingFunctions.Linear(Progress);
            }
            Execute(Value);
            Timer += Time.deltaTime;
            // Make sure we always execute with 1
            if (Progress < 1 && Timer > Duration)
            {
                Execute(1);
            }
            yield return(null);
        }
    }
コード例 #5
0
    public void moveToNextNode()
    {
        if (nodes.Length > 0 && nodes[nextNode] != null)
        {
            var   newPos   = nodes[nextNode].Position;
            float distance = (isoObj.Position - newPos).magnitude;

            moveTo(newPos, (x) => EasingFunctions.Linear(x, 0, 1, distance / speed), () => {
                if (nextNode < nodes.Length - 1)
                {
                    nextNode++;
                    moveToNextNode();
                }
                else
                {
                    if (loop)
                    {
                        nextNode = 0;
                        moveToNextNode();
                    }
                }
            }, 0, distance / speed);
        }
    }
コード例 #6
0
    public override void Update()
    {
        Vector2 new_pos = Vector2.zero;

        switch (movement_type)
        {
        case MovementType.MOVEMENT_LINEAR:
        {
            new_pos.x = EasingFunctions.Linear(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.Linear(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_EXPO_IN:
        {
            new_pos.x = EasingFunctions.ExpoIn(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.ExpoIn(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_EXPO_OUT:
        {
            new_pos.x = EasingFunctions.ExpoOut(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.ExpoOut(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_EXPO_IN_OUT:
        {
            new_pos.x = EasingFunctions.ExpoInOut(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.ExpoInOut(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_BOUNCE:
        {
            new_pos.x = EasingFunctions.Bounce(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.Bounce(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_QUAD_IN:
        {
            new_pos.x = EasingFunctions.QuadIn(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.QuadIn(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_QUAD_OUT:
        {
            new_pos.x = EasingFunctions.QuadOut(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.QuadOut(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_QUAD_IN_OUT:
        {
            new_pos.x = EasingFunctions.QuadInOut(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.QuadInOut(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }
        }

        affected_element.transform.position = new_pos;

        if (timer.ReadRealTime() >= duration)
        {
            affected_element.transform.position = final_pos;
            Finish();
        }
    }