示例#1
0
        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));
            }
        }
示例#2
0
        public ActionAnimation GetActionAnimation(AnimActionType animActionType, int dataId, int index)
        {
            ActionAnimation tempActionAnimation = default(ActionAnimation);

            switch (animActionType)
            {
            case AnimActionType.AttackRightHand:
                tempActionAnimation = GetRightHandAttackAnimations(dataId)[index];
                break;

            case AnimActionType.AttackLeftHand:
                tempActionAnimation = GetLeftHandAttackAnimations(dataId)[index];
                break;

            case AnimActionType.Skill:
                tempActionAnimation = GetSkillActivateAnimation(dataId);
                break;

            case AnimActionType.ReloadRightHand:
                tempActionAnimation = GetRightHandReloadAnimation(dataId);
                break;

            case AnimActionType.ReloadLeftHand:
                tempActionAnimation = GetLeftHandReloadAnimation(dataId);
                break;
            }
            return(tempActionAnimation);
        }
        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;
        }
示例#4
0
        public override bool GetLeftHandReloadAnimation(
            int dataId,
            out float triggerDuration,
            out float totalDuration)
        {
            ActionAnimation tempActionAnimation = GetLeftHandReloadAnimation(dataId);

            triggerDuration = tempActionAnimation.GetTriggerDuration();
            totalDuration   = tempActionAnimation.GetTotalDuration();
            return(true);
        }
示例#5
0
        public ActionAnimation GetActionAnimation(AnimActionType animActionType, int dataId, int index)
        {
            tempActionAnimation = null;
            switch (animActionType)
            {
            case AnimActionType.AttackRightHand:
                tempActionAnimation = GetRightHandAttackAnimations(dataId)[index];
                break;

            case AnimActionType.AttackLeftHand:
                tempActionAnimation = GetLeftHandAttackAnimations(dataId)[index];
                break;

            case AnimActionType.Skill:
                tempActionAnimation = GetSkillCastAnimations(dataId)[index];
                break;
            }
            return(tempActionAnimation);
        }
示例#6
0
        private IEnumerator PlayActionAnimation_Animator(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)
            {
                CacheAnimator.SetBool(ANIM_DO_ACTION, false);
                CacheAnimatorController[ANIM_STATE_ACTION_CLIP] = tempActionAnimation.clip;
                var audioClip = tempActionAnimation.GetRandomAudioClip();
                if (audioClip != null)
                {
                    AudioSource.PlayClipAtPoint(audioClip, CacheTransform.position, AudioManager.Singleton == null ? 1f : AudioManager.Singleton.sfxVolumeSetting.Level);
                }
                CacheAnimator.SetFloat(ANIM_ACTION_CLIP_MULTIPLIER, playSpeedMultiplier);
                CacheAnimator.SetBool(ANIM_DO_ACTION, true);
                // Waits by current transition + clip duration before end animation
                yield return(new WaitForSecondsRealtime(CacheAnimator.GetAnimatorTransitionInfo(0).duration + (tempActionAnimation.GetClipLength() / playSpeedMultiplier)));

                CacheAnimator.SetBool(ANIM_DO_ACTION, false);
                // Waits by current transition + extra duration before end playing animation state
                yield return(new WaitForSecondsRealtime(CacheAnimator.GetAnimatorTransitionInfo(0).duration + (tempActionAnimation.GetExtraDuration() / playSpeedMultiplier)));
            }
        }