public static void Update() { // Update anims on the active list for (int animBaseIndex = m_animList.Count - 1; animBaseIndex >= 0; animBaseIndex--) { AnimBase animBase = m_animList[animBaseIndex]; if (animBase.GetElapsedTime() < animBase.m_animStartDelay) { continue; } if (animBase.GetType() == typeof(Spawn)) { Spawn spawn = (Spawn)animBase; bool bSpawnAnimsComplete = true; for (int animIndex = spawn.m_anims.Count - 1; animIndex >= 0; animIndex--) { Anim anim = spawn.m_anims[animIndex]; if (anim.targetObj == null) { Debug.Log("Warning! Animation target has become null! Removing associated anim."); spawn.m_anims.RemoveAt(animIndex); continue; } // Set anim start time if (anim.initTime < 0) { anim.initTime = Time.time; } // Check for anim start delay if (anim.GetElapsedTime() < anim.startDelay) { bSpawnAnimsComplete = false; continue; } if (spawn.m_animDelegate != null) { spawn.m_animDelegate.AnimCallback(spawn.m_id, AnimState.Update, spawn.GetElapsedTime()); } // Call update method for the appropriate anim type // All anims will be updated simultaneously in Spawn anim type if (anim.GetType() == typeof(MoveTo)) { bSpawnAnimsComplete &= UpdateMoveAnim((MoveTo)anim); } if (anim.GetType() == typeof(RotateTo)) { bSpawnAnimsComplete &= UpdateRotateAnim((RotateTo)anim); } if (anim.GetType() == typeof(UnityAnim)) { bSpawnAnimsComplete &= UpdateUnityAnim((UnityAnim)anim); } // if(anim.GetType() == typeof(PrefabAnim)) // bSpawnAnimsComplete &= UpdatePrefabAnim((PrefabAnim)anim); } // Check if all anims in the list are complete if (bSpawnAnimsComplete) { // Send callback if specified if (spawn.m_animDelegate != null) { spawn.m_animDelegate.AnimCallback(spawn.m_id, AnimState.Complete); } // Remove from anim list m_animList.RemoveAt(animBaseIndex); } } else if (animBase.GetType() == typeof(Sequence)) { Sequence sequence = (Sequence)animBase; // Get current anim in the sequence Anim anim = sequence.GetCurrentAnim(); if (anim.targetObj == null) { Debug.Log("Warning! Animation target has become null! Removing associated anim."); sequence.m_anims.Remove(anim); if (sequence.m_currentAnimIndex >= sequence.m_anims.Count) { if (sequence.m_animDelegate != null) { sequence.m_animDelegate.AnimCallback(sequence.m_id, AnimState.Interrupted); } m_animList.RemoveAt(animBaseIndex); } continue; } // Set anim start time if (anim.initTime < 0) { anim.initTime = Time.time; } // Check for anim start delay if (anim.GetElapsedTime() < anim.startDelay) { continue; } if (sequence.m_animDelegate != null) { sequence.m_animDelegate.AnimCallback(sequence.m_id, AnimState.Update, sequence.GetElapsedTime()); } // Call update method for the current anim in the sequence if (anim.GetType() == typeof(MoveTo)) { if (UpdateMoveAnim((MoveTo)anim)) { sequence.m_currentAnimIndex++; } } if (anim.GetType() == typeof(RotateTo)) { if (UpdateRotateAnim((RotateTo)anim)) { sequence.m_currentAnimIndex++; } } if (anim.GetType() == typeof(UnityAnim)) { if (UpdateUnityAnim((UnityAnim)anim)) { sequence.m_currentAnimIndex++; } } if (anim.GetType() == typeof(PrefabAnim)) { if (UpdatePrefabAnim((PrefabAnim)anim)) { sequence.m_currentAnimIndex++; } } // Check for end of sequence if (sequence.m_currentAnimIndex >= sequence.m_anims.Count) { // Send callback if specified if (sequence.m_animDelegate != null) { sequence.m_animDelegate.AnimCallback(sequence.m_id, AnimState.Complete); } //Debug.Log("crashed = " + m_animList.Count); // Remove from anim list if (m_animList != null && m_animList.Count > 0) { m_animList.RemoveAt(animBaseIndex); } } } } }
public MovementEvent(GameObject target, float speed, Quaternion initialRot, Quaternion finalRot, bool concurrent = false, bool forced = false) { animation = new FlatSpeedRotationAnim(target, speed, initialRot, finalRot, concurrent); this.forced = forced; }
public MovementEvent(GameObject target, float speed, List <Vector3> positions, bool concurrent = false, bool forced = false) { animation = new StitchedFlatSpeedMovementAnim(target, speed, positions, concurrent); this.forced = forced; }
public MovementEvent(GameObject target, float speed, Vector3 finalPos, bool concurrent = false, bool forced = false) { animation = new DeceleratingMovementAnim(target, speed, finalPos, concurrent); this.forced = forced; }