示例#1
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenTransform Begin(GameObject go, float duration, Transform from, Transform to)
    {
        TweenTransform comp = ThunderTweener.Begin <TweenTransform>(go, duration);

        comp.from = from;
        comp.to   = to;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
示例#2
0
文件: TweenScale.cs 项目: nqnq/pa22
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenScale Begin(GameObject go, float duration, Vector3 scale)
    {
        TweenScale comp = ThunderTweener.Begin <TweenScale>(go, duration);

        comp.from = comp.value;
        comp.to   = scale;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
示例#3
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenAlpha Begin(GameObject go, float duration, float targetVolume)
    {
        TweenAlpha comp = ThunderTweener.Begin <TweenAlpha>(go, duration);

        comp.from = comp.value;
        comp.to   = targetVolume;

        if (targetVolume > 0f)
        {
            var s = comp.image;
            s.enabled = true;
        }
        return(comp);
    }
示例#4
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenFOV Begin(GameObject go, float duration, float to)
    {
        TweenFOV comp = ThunderTweener.Begin <TweenFOV>(go, duration);

        comp.from = comp.value;
        comp.to   = to;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
示例#5
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenPosition Begin(GameObject go, float duration, Vector3 pos)
    {
        TweenPosition comp = ThunderTweener.Begin <TweenPosition>(go, duration);

        comp.from = comp.value;
        comp.to   = pos;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
示例#6
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenRotation Begin(GameObject go, float duration, Quaternion rot)
    {
        TweenRotation comp = ThunderTweener.Begin <TweenRotation>(go, duration);

        comp.from = comp.value.eulerAngles;
        comp.to   = rot.eulerAngles;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
示例#7
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenVolume Begin(GameObject go, float duration, float targetVolume)
    {
        TweenVolume comp = ThunderTweener.Begin <TweenVolume>(go, duration);

        comp.from = comp.value;
        comp.to   = targetVolume;

        if (targetVolume > 0f)
        {
            var s = comp.audioSource;
            s.enabled = true;
            s.Play();
        }
        return(comp);
    }
示例#8
0
    /// <summary>
    /// Update the tweening factor and call the virtual update function.
    /// </summary>

    protected void DoUpdate()
    {
        float delta = ignoreTimeScale && !useFixedUpdate ? Time.unscaledDeltaTime : Time.deltaTime;
        float time  = ignoreTimeScale && !useFixedUpdate ? Time.unscaledTime : Time.time;

        if (!mStarted)
        {
            delta      = 0;
            mStarted   = true;
            mStartTime = time + delay;
        }

        if (time < mStartTime)
        {
            return;
        }

        // Advance the sampling factor
        mFactor += (duration == 0f) ? 1f : amountPerDelta * delta;

        // Loop style simply resets the play factor after it exceeds 1.
        if (style == Style.Loop)
        {
            if (mFactor > 1f)
            {
                mFactor -= Mathf.Floor(mFactor);
            }
        }
        else if (style == Style.PingPong)
        {
            // Ping-pong style reverses the direction
            if (mFactor > 1f)
            {
                mFactor         = 1f - (mFactor - Mathf.Floor(mFactor));
                mAmountPerDelta = -mAmountPerDelta;
            }
            else if (mFactor < 0f)
            {
                mFactor         = -mFactor;
                mFactor        -= Mathf.Floor(mFactor);
                mAmountPerDelta = -mAmountPerDelta;
            }
        }

        // If the factor goes out of range and this is a one-time tweening operation, disable the script
        if ((style == Style.Once) && (duration == 0f || mFactor > 1f || mFactor < 0f))
        {
            mFactor = Mathf.Clamp01(mFactor);
            Sample(mFactor, true);
            enabled = false;

            if (current != this)
            {
                ThunderTweener before = current;
                current = this;

                if (onFinished != null)
                {
                    mTemp      = onFinished;
                    onFinished = new List <EventDelegate>();

                    // Notify the listener delegates
                    EventDelegate.Execute(mTemp);

                    // Re-add the previous persistent delegates
                    for (int i = 0; i < mTemp.Count; ++i)
                    {
                        EventDelegate ed = mTemp[i];
                        if (ed != null && !ed.oneShot)
                        {
                            EventDelegate.Add(onFinished, ed, ed.oneShot);
                        }
                    }
                    mTemp = null;
                }

                // Deprecated legacy functionality support
                if (eventReceiver != null && !string.IsNullOrEmpty(callWhenFinished))
                {
                    eventReceiver.SendMessage(callWhenFinished, this, SendMessageOptions.DontRequireReceiver);
                }

                current = before;
            }
        }
        else
        {
            Sample(mFactor, false);
        }
    }