示例#1
0
    public SDemoControl Scale(GameObject targetGO, Vector3 fromScale, Vector3 toScale, float time, LoopType loop = LoopType.None, Action onComplete = null)
    {
        SDemoControl control = new SDemoControl();

        StartCoroutine(_Scale(targetGO, fromScale, toScale, time, 0f, loop, onComplete, control));
        return(control);
    }
示例#2
0
    public SDemoControl Vector4To(Vector4 fromValue, Vector4 toValue, float time, float delay, Action <Vector4> onUpdate, LoopType loop = LoopType.None, Action onComplete = null)
    {
        SDemoControl control = new SDemoControl();

        StartCoroutine(_Vector4To(fromValue, toValue, time, delay, onUpdate, loop, onComplete, control));
        return(control);
    }
示例#3
0
    public SDemoControl Move(GameObject targetGO, Vector3 fromPosition, Vector3 toPosition, float time, float delay, LoopType loop = LoopType.None, Action onComplete = null)
    {
        SDemoControl control = new SDemoControl();

        StartCoroutine(_Move(targetGO, fromPosition, toPosition, time, delay, loop, onComplete, control));
        return(control);
    }
示例#4
0
    public SDemoControl FloatTo(float fromValue, float toValue, float time, Action <float> onUpdate, LoopType loop = LoopType.None, Action onComplete = null)
    {
        SDemoControl control = new SDemoControl();

        StartCoroutine(_FloatTo(fromValue, toValue, time, 0f, onUpdate, loop, onComplete, control));
        return(control);
    }
示例#5
0
    public SDemoControl Rotate(GameObject targetGO, Vector3 fromEulerAngle, Vector3 toEulerScale, float time, float delay, LoopType loop = LoopType.None, Action onComplete = null)
    {
        SDemoControl control = new SDemoControl();

        StartCoroutine(_Rotate(targetGO, fromEulerAngle, toEulerScale, time, delay, loop, onComplete, control));
        return(control);
    }
示例#6
0
    public SDemoControl WaitFrames(int frameNum, float delay, Action onComplete, LoopType loop = LoopType.None)
    {
        if (frameNum < 0)
        {
            return(null);
        }
        SDemoControl control = new SDemoControl();

        StartCoroutine(_WaitFrames(frameNum, delay, onComplete, loop, control));
        return(control);
    }
示例#7
0
    public SDemoControl WaitFrames(int frameNum, Action onComplete)
    {
        if (frameNum < 0)
        {
            return(null);
        }
        SDemoControl control = new SDemoControl();

        StartCoroutine(_WaitFrames(frameNum, 0f, onComplete, LoopType.None, control));
        return(control);
    }
示例#8
0
    public SDemoControl Wait(float time, float delay, Action onComplete, LoopType loop = LoopType.None)
    {
        if (time < 0)
        {
            return(null);
        }
        SDemoControl control = new SDemoControl();

        StartCoroutine(_Wait(time, delay, onComplete, loop, control));
        return(control);
    }
示例#9
0
    public void StartAnimationRevert(float inDelay = 0f)
    {
        if (m_Control != null)
        {
            m_Control.m_State = SDemoControl.State.Kill;                           // Kill the current tweening if existed
        }
        switch (m_SelfAnimType)
        {
        case SelfAnimType.Move:
            if (enableInitValue)
            {
                gameObject.transform.localPosition = toValue;
            }
            m_Control = SDemoAnimation.Instance.Move(gameObject, toValue, fromValue, time, inDelay, loop, OnComplete);
            break;

        case SelfAnimType.Rotate:
            if (enableInitValue)
            {
                gameObject.transform.localEulerAngles = toValue;
            }
            m_Control = SDemoAnimation.Instance.Rotate(gameObject, toValue, fromValue, time, inDelay, loop, OnComplete);
            break;

        case SelfAnimType.Scale:
            if (enableInitValue)
            {
                gameObject.transform.localScale = toValue;
            }
            m_Control = SDemoAnimation.Instance.Scale(gameObject, toValue, fromValue, time, inDelay, loop, OnComplete);
            break;

        case SelfAnimType.Move_RelativePosition:
            if (enableInitValue)
            {
                gameObject.transform.localPosition = _originPosition + toValue;
            }
            m_Control = SDemoAnimation.Instance.Move(gameObject, _originPosition + toValue, _originPosition + fromValue, time, inDelay, loop, OnComplete);
            break;
        }
    }
 public void StartAnimation()
 {
     m_Control = SDemoAnimation.Instance.Wait(time, OnComplete, loop);
 }
示例#11
0
    private IEnumerator _WaitFrames(int frameNum, float delay, Action onComplete, LoopType loop = LoopType.None, SDemoControl control = null)
    {
        if (delay > 0)
        {
            yield return(new WaitForSeconds(delay));
        }

        if (control.m_State == SDemoControl.State.Kill)
        {
            yield break;
        }

        int currFrame = 0;

        while (currFrame < frameNum)
        {
            if (control.m_State == SDemoControl.State.Playing)
            {
                currFrame++;
            }
            else if (control.m_State == SDemoControl.State.Kill)
            {
                loop = LoopType.None;
                break;
            }
            yield return(new WaitForEndOfFrame());
        }
        if (control.m_State == SDemoControl.State.Kill)
        {
            yield break;
        }

        if (onComplete != null)
        {
            onComplete();
        }

        if (loop == LoopType.Loop)
        {
            StartCoroutine(_WaitFrames(frameNum, delay, onComplete, loop, control));
        }
        else if (loop == LoopType.PingPong)
        {
            StartCoroutine(_WaitFrames(frameNum, delay, onComplete, loop, control));
        }
    }
示例#12
0
    private IEnumerator _Wait(float time, float delay, Action onComplete, LoopType loop = LoopType.None, SDemoControl control = null)
    {
        if (delay > 0)
        {
            yield return(new WaitForSeconds(delay));
        }

        if (control.m_State == SDemoControl.State.Kill)
        {
            yield break;
        }

        float elapsedTime = 0;

        while (elapsedTime < time)
        {
            if (control.m_State == SDemoControl.State.Playing)
            {
                elapsedTime += Time.deltaTime;
            }
            else if (control.m_State == SDemoControl.State.Kill)
            {
                loop = LoopType.None;
                break;
            }
            yield return(new WaitForEndOfFrame());
        }
        if (control.m_State == SDemoControl.State.Kill)
        {
            yield break;
        }

        if (onComplete != null)
        {
            onComplete();
        }

        if (loop == LoopType.Loop)
        {
            StartCoroutine(_Wait(time, delay, onComplete, loop, control));
        }
        else if (loop == LoopType.PingPong)
        {
            StartCoroutine(_Wait(time, delay, onComplete, loop, control));
        }
    }
示例#13
0
    private IEnumerator _Move(GameObject targetGO, Vector3 fromPosition, Vector3 toPosition, float time, float delay, LoopType loop = LoopType.None, Action onComplete = null, SDemoControl control = null)
    {
        if (delay > 0)
        {
            yield return(new WaitForSeconds(delay));
        }

        if (control.m_State == SDemoControl.State.Kill)
        {
            yield break;
        }

        targetGO.transform.localPosition = fromPosition;
        float elapsedTime = 0;

        while (elapsedTime < time)
        {
            if (control.m_State == SDemoControl.State.Playing)
            {
                elapsedTime += Time.deltaTime;
                targetGO.transform.localPosition = Vector3.Lerp(fromPosition, toPosition, (elapsedTime / time));
            }
            else if (control.m_State == SDemoControl.State.Kill)
            {
                loop = LoopType.None;
                break;
            }
            yield return(new WaitForEndOfFrame());
        }
        if (control.m_State == SDemoControl.State.Kill)
        {
            yield break;
        }

        targetGO.transform.localPosition = toPosition;
        if (onComplete != null)
        {
            onComplete();
        }

        if (loop == LoopType.Loop)
        {
            StartCoroutine(_Move(targetGO, fromPosition, toPosition, time, delay, loop, onComplete, control));
        }
        else if (loop == LoopType.PingPong)
        {
            StartCoroutine(_Move(targetGO, toPosition, fromPosition, time, delay, loop, onComplete, control));
        }
    }
示例#14
0
    private IEnumerator _Vector4To(Vector4 fromValue, Vector4 toValue, float time, float delay, Action <Vector4> onUpdate, LoopType loop = LoopType.None, Action onComplete = null, SDemoControl control = null)
    {
        if (delay > 0)
        {
            yield return(new WaitForSeconds(delay));
        }

        if (control.m_State == SDemoControl.State.Kill)
        {
            yield break;
        }

        float   elapsedTime = 0;
        Vector4 val         = Vector4.zero;

        while (elapsedTime < time)
        {
            if (control.m_State == SDemoControl.State.Playing)
            {
                elapsedTime += Time.deltaTime;
                val          = Vector4.Lerp(fromValue, toValue, (elapsedTime / time));
                onUpdate(val);
            }
            else if (control.m_State == SDemoControl.State.Kill)
            {
                loop = LoopType.None;
                break;
            }
            yield return(new WaitForEndOfFrame());
        }
        if (control.m_State == SDemoControl.State.Kill)
        {
            yield break;
        }

        onUpdate(toValue);
        if (onComplete != null)
        {
            onComplete();
        }

        if (loop == LoopType.Loop)
        {
            StartCoroutine(_Vector4To(fromValue, toValue, time, delay, onUpdate, loop, onComplete, control));
        }
        else if (loop == LoopType.PingPong)
        {
            StartCoroutine(_Vector4To(toValue, fromValue, time, delay, onUpdate, loop, onComplete, control));
        }
    }