private IEnumerator PlayActionAnimation_LegacyAnimation(AnimActionType animActionType, int dataId, int index, float playSpeedMultiplier) { // If animator is not null, play the action animation ActionAnimation tempActionAnimation = GetActionAnimation(animActionType, dataId, index); if (legacyAnimation.GetClip(CLIP_ACTION) != null) { legacyAnimation.RemoveClip(CLIP_ACTION); } legacyAnimation.AddClip(tempActionAnimation.clip, CLIP_ACTION); AudioClip audioClip = tempActionAnimation.GetRandomAudioClip(); if (audioClip != null) { AudioSource.PlayClipAtPoint(audioClip, CacheTransform.position, AudioManager.Singleton == null ? 1f : AudioManager.Singleton.sfxVolumeSetting.Level); } isPlayingActionAnimation = true; CrossFadeLegacyAnimation(CLIP_ACTION, actionClipFadeLength, WrapMode.Once); // Waits by current transition + clip duration before end animation yield return(new WaitForSecondsRealtime(tempActionAnimation.GetClipLength() / playSpeedMultiplier)); CrossFadeLegacyAnimation(CLIP_IDLE, idleClipFadeLength, WrapMode.Loop); // Waits by current transition + extra duration before end playing animation state yield return(new WaitForSecondsRealtime(tempActionAnimation.GetExtraDuration() / playSpeedMultiplier)); isPlayingActionAnimation = false; }
private IEnumerator PlayActionAnimation_LegacyAnimation(AnimActionType animActionType, int dataId, int index, float playSpeedMultiplier) { // If animator is not null, play the action animation tempActionAnimation = GetActionAnimation(animActionType, dataId, index); if (tempActionAnimation != null && tempActionAnimation.clip != null) { if (CacheAnimation.GetClip(LEGACY_CLIP_ACTION) != null) { CacheAnimation.RemoveClip(LEGACY_CLIP_ACTION); } CacheAnimation.AddClip(tempActionAnimation.clip, LEGACY_CLIP_ACTION); var audioClip = tempActionAnimation.GetRandomAudioClip(); if (audioClip != null) { AudioSource.PlayClipAtPoint(audioClip, CacheTransform.position, AudioManager.Singleton == null ? 1f : AudioManager.Singleton.sfxVolumeSetting.Level); } CrossFadeLegacyAnimation(LEGACY_CLIP_ACTION, legacyAnimationData.actionClipFadeLength); // Waits by current transition + clip duration before end animation yield return(new WaitForSecondsRealtime(tempActionAnimation.GetClipLength() / playSpeedMultiplier)); CrossFadeLegacyAnimation(legacyAnimationData.idleClip, legacyAnimationData.idleClipFadeLength); // Waits by current transition + extra duration before end playing animation state yield return(new WaitForSecondsRealtime(tempActionAnimation.GetExtraDuration() / playSpeedMultiplier)); } }
private IEnumerator PlayActionAnimation_Animator(AnimActionType animActionType, int dataId, int index, float playSpeedMultiplier) { // If animator is not null, play the action animation ActionAnimation tempActionAnimation = GetActionAnimation(animActionType, dataId, index); CacheAnimatorController[CLIP_ACTION] = tempActionAnimation.clip; yield return(0); AudioClip audioClip = tempActionAnimation.GetRandomAudioClip(); if (audioClip != null) { AudioSource.PlayClipAtPoint(audioClip, CacheTransform.position, AudioManager.Singleton == null ? 1f : AudioManager.Singleton.sfxVolumeSetting.Level); } animator.SetFloat(ANIM_ACTION_CLIP_MULTIPLIER, playSpeedMultiplier); animator.SetBool(ANIM_DO_ACTION, true); animator.Play(0, actionStateLayer, 0f); // Waits by current transition + clip duration before end animation yield return(new WaitForSecondsRealtime(tempActionAnimation.GetClipLength() / playSpeedMultiplier)); animator.SetBool(ANIM_DO_ACTION, false); // Waits by current transition + extra duration before end playing animation state yield return(new WaitForSecondsRealtime(tempActionAnimation.GetExtraDuration() / playSpeedMultiplier)); }