Ejemplo n.º 1
0
        public void ResetToEnd(AnimSetupType a_animType)
        {
            m_timer = GetDuration(a_animType);

            if (IsUiAnimatorSubModule)
            {
                m_uiAnimatorSubModule.ResetToEnd(a_animType);
            }
            else
            {
                if (m_animationSteps != null)
                {
                    for (int aIdx = 0; aIdx < m_animationSteps.Count; aIdx++)
                    {
                        m_animationSteps [aIdx].ResetToEnd(a_animType);
                    }
                }

                CheckTargetIndexesArray();

                for (int idx = 0; idx < m_targetStepIndexes.Length; idx++)
                {
                    m_targetStepIndexes [idx] = m_animationSteps.Count;
                }
            }
        }
Ejemplo n.º 2
0
        public void ResetToStart(AnimSetupType a_animSetupType)
        {
            m_currentStageIndex = 0;
            m_timer             = 0;

            if (m_animationSetups == null || (int)a_animSetupType >= m_animationSetups.Count)
            {
                return;
            }

            if (a_animSetupType != AnimSetupType.Loop)
            {
                m_currentLoopIterationCount = 0;
            }

            List <AnimationStage> currentAnimStages = m_animationSetups [(int)a_animSetupType].AnimationStages;

            if (currentAnimStages != null)
            {
                for (int sIdx = 0; sIdx < currentAnimStages.Count; sIdx++)
                {
                    currentAnimStages [sIdx].ResetToStart(a_animSetupType);
                }
            }

            if (!Application.isPlaying)
            {
                ForceStopAllAudioSources();
            }
        }
Ejemplo n.º 3
0
        public void SetAnimationTimer(AnimSetupType a_animType, float a_timerValue, bool a_forceLinearTimings = false)
        {
            if (IsUiAnimatorSubModule)
            {
                m_uiAnimatorSubModule.SetAnimationTimer(a_animType, a_timerValue - m_startDelay);
                return;
            }

            float offset;

            for (int tIdx = 0; tIdx < m_targetObjects.Length; tIdx++)
            {
                offset = m_startDelay;

                for (int aIdx = 0; aIdx < m_animationSteps.Count; aIdx++)
                {
                    if (aIdx > 0)
                    {
                        if (a_forceLinearTimings || m_animationSteps [aIdx].WaitForPreviousComplete)
                        {
                            offset += m_animationSteps [aIdx - 1].TotalExecutionDuration;
                        }
                        else
                        {
                            offset += m_animationSteps [aIdx - 1].GetTotalExecutionDuration(tIdx);
                        }
                    }

                    if (a_timerValue - offset >= 0 || !m_animationSteps [aIdx].IsEffectStep)
                    {
                        m_animationSteps [aIdx].SetAnimationTimer(tIdx, a_animType, a_timerValue - offset, a_forceLinearTimings);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public bool UpdateState(UIAnimator a_uiAnimatorRef, AnimSetupType a_animType, float a_deltaTime)
        {
            m_timer += a_deltaTime;

            if (m_timer > m_startDelay)
            {
                m_finishedFlag = true;

                if (!m_finishedStage && m_animationInstances != null)
                {
                    for (int iIdx = 0; iIdx < m_animationInstances.Count; iIdx++)
                    {
                        if (!m_animationInstances [iIdx].UpdateState(a_uiAnimatorRef, a_animType, a_deltaTime))
                        {
                            m_finishedFlag = false;
                        }
                    }
                }

                if (m_finishedFlag)
                {
                    m_finishedStage = true;
                }

                if (m_finishedStage && m_timer > m_cachedTotalDuration)
                {
                    return(true);
                }
            }

            return(false);
        }
        public void UpdateState(UIAnimator a_uiAnimatorRef, int a_targetIndex, AnimSetupType a_animType, float a_deltaTime)
        {
            m_timers[a_targetIndex] += a_deltaTime;

            if (m_delay.GetValue(a_targetIndex) > 0 && m_timers[a_targetIndex] <= m_delay.GetValue(a_targetIndex))
            {
                // Animation is still waiting the allocated 'delay'
                return;
            }

            float postDelayStepTimer = (m_timers [a_targetIndex] - m_delay.GetValue(a_targetIndex));

            if (m_audioClipDatas != null && m_audioClipDatas.Length > 0)
            {
                // Check for whether an audio clip needs to be played
                for (int idx = 0; idx < m_audioClipDatas.Length; idx++)
                {
                    if (m_audioClipDatas [idx].Clip != null && !m_audioClipDatas [idx].HasAudioClipActivated(a_targetIndex))
                    {
                        if ((m_audioClipDatas [idx].TriggerPoint == AudioClipData.CLIP_TRIGGER_POINT.START_OF_ANIM_STEP && postDelayStepTimer > m_audioClipDatas [idx].Delay.GetValue(a_targetIndex)) ||
                            (m_audioClipDatas [idx].TriggerPoint == AudioClipData.CLIP_TRIGGER_POINT.END_OF_ANIM_STEP && postDelayStepTimer > m_duration.GetValue(a_targetIndex) - m_audioClipDatas [idx].Delay.GetValue(a_targetIndex)))
                        {
                            a_uiAnimatorRef.TriggerAudioClip(m_audioClipDatas [idx], a_targetIndex);

                            m_audioClipDatas [idx].MarkAudioClipActivated(a_targetIndex);
                        }
                    }
                }
            }

            SetAnimationProgress(a_targetIndex, a_animType, postDelayStepTimer / Mathf.Max(m_duration.GetValue(a_targetIndex), MIN_DURATION));
        }
Ejemplo n.º 6
0
        public void ResetToStart(AnimSetupType a_animType)
        {
            m_timer = 0;

            if (IsUiAnimatorSubModule)
            {
                m_uiAnimatorSubModule.ResetToStart(a_animType);
            }
            else
            {
                if (m_animationSteps != null)
                {
                    for (int sIdx = m_animationSteps.Count - 1; sIdx >= 0; sIdx--)
                    {
                        m_animationSteps [sIdx].ResetToStart(a_animType);
                    }
                }

                CheckTargetIndexesArray();

                for (int idx = 0; idx < m_targetStepIndexes.Length; idx++)
                {
                    m_targetStepIndexes [idx] = 0;
                }
            }
        }
        public void ResetToEnd(AnimSetupType a_animType)
        {
            SetTimerValues(TotalExecutionDuration);

            for (int idx = 0; idx < m_numTargets; idx++)
            {
                SetAnimationProgress(idx, a_animType, 1);
            }
        }
Ejemplo n.º 8
0
        public void ResetToEnd(AnimSetupType a_animType)
        {
            m_cachedTotalDuration = GetTotalDuration(a_animType);
            m_timer         = m_cachedTotalDuration;
            m_finishedStage = true;

            for (int iIdx = 0; iIdx < m_animationInstances.Count; iIdx++)
            {
                m_animationInstances [iIdx].ResetToEnd(a_animType);
            }
        }
Ejemplo n.º 9
0
        private List <AnimationStage> GetAnimationStepStages(AnimSetupType a_animType)
        {
            int setupIndex = (int)a_animType;

            if (m_animationSetups != null && m_animationSetups.Count > setupIndex)
            {
                return(m_animationSetups [setupIndex].AnimationStages);
            }

            return(null);
        }
Ejemplo n.º 10
0
        public override void OnInspectorGUI(int a_stepIndex, AnimSetupType a_animType, SerializedObject a_serializedObject, System.Action a_onAnimatedStateChanged)
        {
            bool setupChanged = false;

            m_shakeAmount.OnInspectorGUI(a_serializedObject.FindProperty("m_shakeAmount"), ref setupChanged, NumTargets > 1, new GUIContent("Shake Amount"));

            if (setupChanged)
            {
                a_onAnimatedStateChanged();
            }
        }
Ejemplo n.º 11
0
        public void SetAnimType(AnimSetupType a_animType)
        {
            m_currentAnimSetupIndex = (int)a_animType;

            ResetToDefault();

            if (Application.isPlaying)
            {
                ResetToStart();
            }
        }
        public override void OnInspectorGUI(int a_stepIndex, AnimSetupType a_animType, SerializedObject a_serializedObject, System.Action a_onAnimatedStateChanged)
        {
            bool stateChanged = false;

            string namePrefix = a_animType == AnimSetupType.Intro ? "Start" : "End";

            DrawPropertyField(a_serializedObject, "m_animatedAlpha", ref stateChanged, new GUIContent(namePrefix + " Alpha"));

            if (stateChanged)
            {
                a_onAnimatedStateChanged();
            }
        }
        public override void OnInspectorGUI(int a_stepIndex, AnimSetupType a_animType, SerializedObject a_serializedObject, System.Action a_onAnimatedStateChanged)
        {
            bool   setupChanged       = false;
            string animVariablePrefix = a_animType == AnimSetupType.Intro ? "Start" : "End";

            m_position.OnInspectorGUI(a_serializedObject.FindProperty("m_position"), ref setupChanged, NumTargets > 1, new GUIContent(animVariablePrefix + " Position"));
            m_scale.OnInspectorGUI(a_serializedObject.FindProperty("m_scale"), ref setupChanged, NumTargets > 1, new GUIContent(animVariablePrefix + " Scale"));
            m_rotation.OnInspectorGUI(a_serializedObject.FindProperty("m_rotation"), ref setupChanged, NumTargets > 1, new GUIContent(animVariablePrefix + " Rotation"));

            if (setupChanged)
            {
                a_onAnimatedStateChanged();
            }
        }
Ejemplo n.º 14
0
        public void SetAnimationTimer(int a_targetIndex, AnimSetupType a_animType, float a_timerValue, bool a_forceLinearTimings = false)
        {
            CheckTimerValueArray();

            m_timers [a_targetIndex] = a_timerValue;

            if (a_timerValue - m_delay.GetValue(a_forceLinearTimings ? 0 : a_targetIndex) < 0)
            {
                SetAnimationProgress(a_targetIndex, a_animType, 0);
            }
            else
            {
                SetAnimationProgress(a_targetIndex, a_animType, (a_timerValue - m_delay.GetValue(a_forceLinearTimings ? 0 : a_targetIndex)) / Mathf.Max(m_duration.GetValue(a_forceLinearTimings ? 0 : a_targetIndex), MIN_DURATION));
            }
        }
Ejemplo n.º 15
0
        public void ResetToStart(AnimSetupType a_animType)
        {
            for (int idx = 0; idx < m_numTargets; idx++)
            {
                SetAnimationTimer(idx, a_animType, 0);
            }

            // Reset AudioClipData's
            if (m_audioClipDatas != null)
            {
                for (int idx = 0; idx < m_audioClipDatas.Length; idx++)
                {
                    m_audioClipDatas [idx].ResetAll();
                }
            }
        }
Ejemplo n.º 16
0
        public void PlayAnimation(AnimSetupType a_animType, float a_delay, System.Action a_onFinish)
        {
            CheckDataInit();

            SetAnimType(a_animType);

            m_onFinishAction = a_onFinish;

            if (a_delay > 0)
            {
                StartCoroutine(PlayAnimationAfterDelay(a_animType, a_delay, a_onFinish));
            }
            else
            {
                PlayCurrentAnimationSetup();
            }
        }
Ejemplo n.º 17
0
        public float GetInstancesDuration(AnimSetupType a_animType)
        {
            float longestDuration = 0;
            float instanceDuration;

            for (int iIdx = 0; iIdx < m_animationInstances.Count; iIdx++)
            {
                instanceDuration = m_animationInstances [iIdx].GetDuration(a_animType);

                if (instanceDuration > longestDuration)
                {
                    longestDuration = instanceDuration;
                }
            }

            return(longestDuration);
        }
Ejemplo n.º 18
0
        public float GetAnimationDuration(AnimSetupType a_animType)
        {
            CheckDataInit();

            List <AnimationStage> currentAnimStages = m_animationSetups [(int)a_animType].AnimationStages;

            float totalDuration = 0;

            if (currentAnimStages != null)
            {
                for (int sIdx = 0; sIdx < currentAnimStages.Count; sIdx++)
                {
                    totalDuration += currentAnimStages [sIdx].GetTotalDuration(a_animType);
                }
            }

            return(totalDuration);
        }
Ejemplo n.º 19
0
        public bool UpdateState(UIAnimator a_uiAnimatorRef, AnimSetupType a_animType, float a_deltaTime)
        {
            m_timer += a_deltaTime;

            if (m_timer > m_startDelay)
            {
                if (IsUiAnimatorSubModule)
                {
                    return(m_uiAnimatorSubModule.UpdateState(a_animType, a_deltaTime, a_isPrimaryAnimator: false));
                }

                m_finishedFlag = true;

                for (int tIdx = 0; tIdx < m_targetObjects.Length; tIdx++)
                {
                    if (m_targetStepIndexes [tIdx] < m_animationSteps.Count)
                    {
                        if (m_targetStepIndexes [tIdx] > 0 && m_animationSteps [m_targetStepIndexes [tIdx]].WaitForPreviousComplete && !m_animationSteps [m_targetStepIndexes [tIdx]].HasStarted(tIdx))
                        {
                            if (!m_animationSteps [m_targetStepIndexes [tIdx] - 1].IsCompletelyFinished())
                            {
                                // Need to wait until previous anim step is completely finished
                                m_finishedFlag = false;
                                continue;
                            }
                        }

                        m_animationSteps [m_targetStepIndexes [tIdx]].UpdateState(a_uiAnimatorRef, tIdx, a_animType, a_deltaTime);

                        if (m_animationSteps [m_targetStepIndexes [tIdx]].IsFinished(tIdx))
                        {
                            // Finished this anim step, progress to next
                            m_targetStepIndexes [tIdx]++;
                        }

                        m_finishedFlag = false;
                    }
                }

                return(m_finishedFlag);
            }

            return(false);
        }
Ejemplo n.º 20
0
        public void ResetToEnd(AnimSetupType a_animSetupType)
        {
            if (m_animationSetups == null || (int)a_animSetupType >= m_animationSetups.Count)
            {
                return;
            }

            List <AnimationStage> currentAnimStages = m_animationSetups [(int)a_animSetupType].AnimationStages;

            m_currentStageIndex = currentAnimStages.Count - 1;
            m_timer             = GetAnimationDuration();

            if (currentAnimStages != null)
            {
                for (int sIdx = 0; sIdx < currentAnimStages.Count; sIdx++)
                {
                    currentAnimStages [sIdx].ResetToEnd(a_animSetupType);
                }
            }
        }
Ejemplo n.º 21
0
        public float GetDuration(AnimSetupType a_animType)
        {
            float duration = m_startDelay;

            if (IsUiAnimatorSubModule)
            {
                duration += m_uiAnimatorSubModule.GetAnimationDuration(a_animType);
            }
            else
            {
                for (int sIdx = 0; sIdx < m_animationSteps.Count; sIdx++)
                {
                    if (m_animationSteps [sIdx] != null)
                    {
                        duration += m_animationSteps [sIdx].TotalExecutionDuration;
                    }
                }
            }

            return(duration);
        }
Ejemplo n.º 22
0
        public void SetAnimationProgress(int a_targetIndex, AnimSetupType a_animType, float a_progress)
        {
            if (!IsEffectStep && a_animType == AnimSetupType.Outro)
            {
                a_progress = 1f - a_progress;
            }

            if (a_progress < 0)
            {
                a_progress = 0;
            }
            else if (a_progress > 1)
            {
                a_progress = 1;
            }

            if (UseEasing)
            {
                a_progress = EasingManager.GetEaseProgress(m_easing, (float)a_progress);
            }

            SetAnimation(a_targetIndex, a_progress);
        }
Ejemplo n.º 23
0
        public bool UpdateState(AnimSetupType a_animType, float a_deltaTime, bool a_isPrimaryAnimator)
        {
            m_currentAnimSetupIndex = (int)a_animType;

            return(UpdateState(a_deltaTime, a_isPrimaryAnimator));
        }
Ejemplo n.º 24
0
 public float GetTotalDuration(AnimSetupType a_animType)
 {
     return(m_startDelay + GetInstancesDuration(a_animType) + m_endDelay);
 }
Ejemplo n.º 25
0
 public void PlayAnimation(AnimSetupType a_animType, float a_delay)
 {
     PlayAnimation(a_animType, a_delay, null);
 }
Ejemplo n.º 26
0
 public void PlayAnimation(AnimSetupType a_animType, System.Action a_onFinish)
 {
     PlayAnimation(a_animType, 0, a_onFinish);
 }
Ejemplo n.º 27
0
        private IEnumerator PlayAnimationAfterDelay(AnimSetupType a_animType, float a_delay, System.Action a_onFinish)
        {
            yield return(new WaitForSeconds(a_delay));

            PlayCurrentAnimationSetup();
        }
Ejemplo n.º 28
0
        public void SetAnimationTimer(AnimSetupType a_animType, float a_timerValue, bool a_forceLinearTimings = false)
        {
            m_currentAnimSetupIndex = (int)a_animType;

            SetAnimationTimer(a_timerValue, a_forceLinearTimings);
        }
Ejemplo n.º 29
0
 public override void OnInspectorGUI(int a_stepIndex, AnimSetupType a_animType, SerializedObject a_serializedObject, System.Action a_onAnimatedStateChanged)
 {
 }
Ejemplo n.º 30
0
        public void SetAnimationTimer(float a_timerValue, bool a_forceLinearTimings = false)
        {
            List <AnimationStage> currentAnimStages = CurrentAnimStages;

            if (currentAnimStages == null)
            {
                return;
            }

            m_timer = a_timerValue;

            AnimSetupType currentAnimSetupType = CurrentAnimType;
            float         timerOffset          = a_timerValue;
            float         stageDuration        = 0;

            m_currentStageIndex = 0;

            for (int sIdx = 0; sIdx < currentAnimStages.Count; sIdx++)
            {
                stageDuration = currentAnimStages [sIdx].GetTotalDuration(currentAnimSetupType);

                if (timerOffset > stageDuration)
                {
                    // Set this stage to complete state
                    for (int iIdx = 0; iIdx < currentAnimStages [sIdx].AnimationInstances.Count; iIdx++)
                    {
                        for (int aIdx = 0; aIdx < currentAnimStages [sIdx].AnimationInstances[iIdx].AnimationSteps.Count; aIdx++)
                        {
                            // TODO: Tidy this up. Variables?!
                            if (currentAnimStages [sIdx].AnimationInstances[iIdx].AnimationSteps [aIdx].IsEffectStep)
                            {
                                continue;
                            }

                            currentAnimStages [sIdx].AnimationInstances[iIdx].AnimationSteps [aIdx].ResetToEnd(currentAnimSetupType);
                        }
                    }
                }
                else if (timerOffset >= 0)
                {
                    // Part way through this anim stage
                    for (int iIdx = 0; iIdx < currentAnimStages [sIdx].AnimationInstances.Count; iIdx++)
                    {
                        currentAnimStages [sIdx].AnimationInstances [iIdx].SetAnimationTimer(currentAnimSetupType, timerOffset - currentAnimStages [sIdx].StartDelay, a_forceLinearTimings);
                    }
                    m_currentStageIndex = sIdx;
                }
                else
                {
                    // Set this stage to disabled/not-started state
                    for (int iIdx = 0; iIdx < currentAnimStages [sIdx].AnimationInstances.Count; iIdx++)
                    {
                        for (int aIdx = 0; aIdx < currentAnimStages [sIdx].AnimationInstances[iIdx].AnimationSteps.Count; aIdx++)
                        {
                            if (currentAnimStages [sIdx].AnimationInstances[iIdx].AnimationSteps [aIdx].IsEffectStep)
                            {
                                continue;
                            }

                            currentAnimStages [sIdx].AnimationInstances[iIdx].AnimationSteps [aIdx].ResetToStart(currentAnimSetupType);
                        }
                    }
                }

                timerOffset -= stageDuration;
            }
        }