Esempio n. 1
0
    public void SetFrom(PRSType type, Vector3 from)
    {
        int index = getIndex(type);

        if (index > -1 && index < m_TweenList.Length)
        {
            PRSInfo info = (PRSInfo)m_TweenList[index];
            info.m_From = from;

            if (type == PRSType.Pos && info.m_IsSpeed)
            {
                pos        = info.m_From;
                info.m_Dir = info.m_To - info.m_From;
                info.m_Dir.Normalize();
            }
        }
    }
Esempio n. 2
0
    public void SetDuration(PRSType type, float duration)
    {
        int index = getIndex(type);

        if (index > -1 && index < m_TweenList.Length)
        {
            if (!m_TweenList[index].m_IsSpeed)
            {
                m_TweenList[index].m_AmountPerDelta = Mathf.Abs((duration > 0f) ? 1f / duration : 1000f);
                m_TweenList[index].m_Duration       = duration;
            }
            else
            {
                m_TweenList[index].m_Speed = duration;
                m_TweenList[index].m_Dir   = m_TweenList[index].m_To - m_TweenList[index].m_From;
                m_TweenList[index].m_Dir.Normalize();
            }
        }
    }
Esempio n. 3
0
    int getIndex(PRSType _type)
    {
        if (_type == PRSType.Pos)
        {
            return(0);
        }

        if (_type == PRSType.Rot)
        {
            return(1);
        }

        if (_type == PRSType.Scale)
        {
            return(2);
        }

        return(0);
    }
Esempio n. 4
0
        private void SetVariable(PRSType type, Vector3 newValue)
        {
            switch (type)
            {
            case PRSType.Position:
                transform.position = newValue;
                break;

            case PRSType.Rotation:
                transform.eulerAngles = newValue;
                break;

            case PRSType.Scale:
                transform.localScale = newValue;
                break;

            default:
                throw new ArgumentOutOfRangeException("type", type, null);
            }
        }
Esempio n. 5
0
        public void StartSeq(PRSType type)
        {
            StopSeq(type);
            switch (type)
            {
            case PRSType.Position:
                posCoroutine = StartCoroutine(SeqRunner(type));
                break;

            case PRSType.Rotation:
                rotCoroutine = StartCoroutine(SeqRunner(type));
                break;

            case PRSType.Scale:
                scaCoroutine = StartCoroutine(SeqRunner(type));
                break;

            default:
                throw new ArgumentOutOfRangeException("type", type, null);
            }
        }
Esempio n. 6
0
        private IEnumerator SeqRunner(PRSType type)
        {
            List <PRSTarget> sequence = GetSequence(type);

            do
            {
                foreach (var prsTarget in sequence)
                {
                    Vector3 start     = GetVariable(type);
                    Vector3 end       = prsTarget.Target;
                    float   startTime = Time.time;
                    float   endTime   = startTime + prsTarget.Duration;
                    do
                    {
                        Vector3 newValue = Vector3.zero;
                        newValue = prsTarget.Duration == 0 ? end : Vector3.Lerp(start, end, (Time.time - startTime) / prsTarget.Duration);
                        SetVariable(type, newValue);
                        yield return(null);
                    } while (Time.time <= endTime);
                }
            } while (GetLoop(type));
        }
Esempio n. 7
0
        //public PRSInfo()
        //{

        //}
        public PRSInfo(PRSType _type)
        {
            m_Type = _type;
        }