コード例 #1
0
    public void Lerp(Object target, string field, float start, float end, float duration, LerpStyle style)
    {
        startValue  = start;
        targetValue = end;
        timeTotal   = duration;

        targetObject = target;
        fieldName    = field;
        this.style   = style;
    }
コード例 #2
0
ファイル: CoolAnimation.cs プロジェクト: Kritz7/Voices
    public void InitMoveAnimation(Vector3 startPos, Vector3 endPos, LerpStyle lerpStyle, float yOffset, float duration, bool animateRegardlessOfCameraDistance=true)
    {
        this.startPos = startPos;
        this.EndPos = endPos;
        this.YOffset = yOffset;
        this.animationType = AnimationType.MoveToPosition;
        this.lerpStyle = lerpStyle;
        this.Duration = duration;
        this.AnimateRegardlessOfCameraDistance = animateRegardlessOfCameraDistance;

        ResetT();
    }
コード例 #3
0
//	void Start(){
//
//	}

    public void Lerp(Object target, string field, Vector3 start, Vector3 end, float duration, LerpStyle style, bool loop = false)
    {
        startValue  = start;
        targetValue = end;
        timeTotal   = duration;

        targetObject    = target;
        fieldName       = field;
        this.style      = style;
        shouldLoop      = loop;
        shouldAutoStart = true;
    }
コード例 #4
0
ファイル: CoolAnimation.cs プロジェクト: Kritz7/Voices
    public void InitBounceAnimation(float moveSpeed, float rotationSpeed, Vector3 rotationAxis, float frequency, float yOffset, bool animateRegardlessOfCameraDistance=true)
    {
        startPos = transform.localPosition;

        this.animationType = AnimationType.Bobbing;
        this.lerpStyle = LerpStyle.Linear;
        this.MoveSpeed = moveSpeed;
        this.RotationSpeed = rotationSpeed;
        this.RotationAxis = rotationAxis;
        this.Frequency = frequency;
        this.YOffset = yOffset;
        this.AnimateRegardlessOfCameraDistance = animateRegardlessOfCameraDistance;

        ResetT();
    }
コード例 #5
0
ファイル: LerpAnimation.cs プロジェクト: Kritz7/CodeSnippets
    public static float GetCompletion(float percentage, LerpStyle style)
    {
        switch (style)
        {
        case LerpStyle.EaseIn:
            return(Mathf.Sin(percentage * Mathf.PI * 0.5f));

        case LerpStyle.EaseOut:
            return(1f - Mathf.Cos(percentage * Mathf.PI * 0.5f));

        case LerpStyle.Smooth:
            return(percentage * percentage * (3f - 2f * percentage));

        case LerpStyle.SuperSmooth:
            return(percentage * percentage * percentage * (percentage * (6f * percentage - 15f) + 10f));

        default:
            return(percentage);
        }
    }
コード例 #6
0
ファイル: CoolAnimation.cs プロジェクト: Kritz7/Awkies
    public void InitMoveAnimation(Vector3 endPos, LerpStyle lerpStyle, float yOffset, float duration, bool animateRegardlessOfCameraDistance=true, bool anchoredPos=false)
    {
        if(anchoredPos)
        {
            this.UseAnchoredPos = anchoredPos;
            myRect = GetComponent<RectTransform>();
            startPos = myRect.anchoredPosition3D;
            myRect.anchoredPosition3D = startPos;
        }
        else
        {
            startPos = transform.localPosition;
        }

        this.EndPos = endPos;
        this.YOffset = yOffset;
        this.animationType = AnimationType.MoveToPosition;
        this.lerpStyle = lerpStyle;
        this.Duration = duration;
        this.AnimateRegardlessOfCameraDistance = animateRegardlessOfCameraDistance;

        ResetT();
    }
コード例 #7
0
ファイル: CoolAnimation.cs プロジェクト: Kritz7/Awkies
    public void InitBounceAnimation(float moveSpeed, float rotationSpeed, Vector3 rotationAxis, float frequency, float yOffset, bool animateRegardlessOfCameraDistance=true)
    {
        if(UseAnchoredPos)
        {
            myRect = GetComponent<RectTransform>();
            startPos = myRect.anchoredPosition3D;
        }
        else
        {
            startPos = transform.localPosition;
        }

        this.animationType = AnimationType.Bobbing;
        this.lerpStyle = LerpStyle.Linear;
        this.MoveSpeed = moveSpeed;
        this.RotationSpeed = rotationSpeed;
        this.RotationAxis = rotationAxis;
        this.Frequency = frequency;
        this.YOffset = yOffset;
        this.AnimateRegardlessOfCameraDistance = animateRegardlessOfCameraDistance;

        ResetT();
    }
コード例 #8
0
ファイル: LerpAnimation.cs プロジェクト: Kritz7/CodeSnippets
 public static float GetCompletion(float t, float duration, LerpStyle style)
 {
     return(GetCompletion(t / duration, style));
 }
コード例 #9
0
    public static float ModifyTimeWithStyle(LerpStyle style, float t)
    {
        var   res = t;
        var   b = 0f;
        var   c = 1f;
        var   d = 1f;
        float ts, tc;



        switch (style)
        {
        case LerpStyle.None:
            break;

        case LerpStyle.EaseIn:
            break;

        case LerpStyle.EaseOut:
            break;

        case LerpStyle.InOutCubic:
            ts = (t /= d) * t;
            tc = ts * t;
            return(b + c * (-2 * tc + 3 * ts));

            break;

        case LerpStyle.InCubic:
            tc = (t /= d) * t * t;
            return(b + c * (tc));

        case LerpStyle.OutCubic:
            ts = (t /= d) * t;
            tc = ts * t;
            return(b + c * (tc + -3 * ts + 3 * t));

        case LerpStyle.OutQuartic:
            ts = (t /= d) * t;
            tc = ts * t;
            return(b + c * (-1.77635683940025e-15f * tc * ts + -1f * ts * ts + 4f * tc + -6f * ts + 4f * t));

        case LerpStyle.InQuintic:
            ts = (t /= d) * t;
            tc = ts * t;
            return(b + c * (tc * ts));

        case LerpStyle.OutQuintic:
            ts = (t /= d) * t;
            tc = ts * t;
            return(b + c * (tc * ts + -5 * ts * ts + 10 * tc + -10 * ts + 5 * t));

        case LerpStyle.Bounce1:
            ts = (t /= d) * t;
            tc = ts * t;
            return(b + c * (-20.4925f * tc * ts + 58.9325f * ts * ts + -63.585f * tc + 29.095f * ts + -2.95f * t));

        case LerpStyle.Bounce2:
            ts = (t /= d) * t;
            tc = ts * t;
            return(b + c * (-12.195f * tc * ts + 50.635f * ts * ts + -63.585f * tc + 29.095f * ts + -2.95f * t));

        case LerpStyle.Bounce3:
            ts = (t /= d) * t;
            tc = ts * t;
            return(b + c * (44.4925f * tc * ts + -122.08f * ts * ts + 120.88f * tc + -52.69f * ts + 10.3975f * t));
        }

        return(res);
    }