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(); } } }
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(); } } }
int getIndex(PRSType _type) { if (_type == PRSType.Pos) { return(0); } if (_type == PRSType.Rot) { return(1); } if (_type == PRSType.Scale) { return(2); } return(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); } }
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); } }
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)); }
//public PRSInfo() //{ //} public PRSInfo(PRSType _type) { m_Type = _type; }