コード例 #1
0
        public override bool GetRandomLeftHandAttackAnimation(int dataId, out int animationIndex, out float triggerDuration, out float totalDuration)
        {
            ActionAnimation2D animation2D = null;

            if (!CacheLeftHandAttackAnimations.TryGetValue(dataId, out animation2D))
            {
                animation2D = defaultAttackAnimation2D;
            }
            animationIndex  = 0;
            triggerDuration = 0f;
            totalDuration   = 0f;
            if (animation2D == null)
            {
                return(false);
            }
            AnimationClip2D clip = animation2D.GetClipByDirection(CurrentDirectionType);

            if (clip == null)
            {
                return(false);
            }
            triggerDuration = clip.duration * animation2D.triggerDurationRate;
            totalDuration   = clip.duration + animation2D.extraDuration;
            return(true);
        }
コード例 #2
0
        IEnumerator PlayActionAnimationRoutine(AnimActionType animActionType, int dataId, int index, float playSpeedMultiplier)
        {
            // If animator is not null, play the action animation
            ActionAnimation2D animation2D = GetActionAnimation(animActionType, dataId);

            if (animation2D != null)
            {
                AnimationClip2D anim = animation2D.GetClipByDirection(CurrentDirectionType);
                if (anim != null)
                {
                    playingAction = true;
                    AudioClip audioClip = animation2D.GetRandomAudioClip();
                    if (audioClip != null)
                    {
                        AudioSource.PlayClipAtPoint(audioClip, CacheTransform.position, AudioManager.Singleton == null ? 1f : AudioManager.Singleton.sfxVolumeSetting.Level);
                    }
                    // Waits by current transition + clip duration before end animation
                    Play(anim);
                    yield return(new WaitForSecondsRealtime(anim.duration / playSpeedMultiplier));

                    Play(idleAnimation2D, CurrentDirectionType);
                    yield return(new WaitForSecondsRealtime(animation2D.extraDuration / playSpeedMultiplier));

                    playingAction = false;
                }
            }
        }
コード例 #3
0
        private bool MigrateSkillCastAnimations()
        {
            bool hasChanges = false;

            if (defaultSkillCastAnimation2D != null)
            {
                hasChanges = true;
                defaultSkillActivateAnimation2D = defaultSkillCastAnimation2D;
                defaultSkillCastAnimation2D     = null;
            }

            if (skillCastAnimations2D != null &&
                skillCastAnimations2D.Length > 0)
            {
                hasChanges        = true;
                skillAnimations2D = new SkillAnimations2D[skillCastAnimations2D.Length];
                for (int i = 0; i < skillCastAnimations2D.Length; ++i)
                {
                    SkillAnimations2D data = new SkillAnimations2D();
                    data.skill = skillCastAnimations2D[i].skill;
                    if (skillCastAnimations2D[i].animation != null)
                    {
                        data.activateAnimation = skillCastAnimations2D[i].animation;
                    }
                    skillAnimations2D[i] = data;
                }
                //skillCastAnimations2D = null;
            }
            return(hasChanges);
        }
コード例 #4
0
        private ActionAnimation2D GetActionAnimation(AnimActionType animActionType, int dataId)
        {
            ActionAnimation2D animation2D = null;

            switch (animActionType)
            {
            case AnimActionType.AttackRightHand:
                if (!CacheRightHandAttackAnimations.TryGetValue(dataId, out animation2D))
                {
                    animation2D = defaultAttackAnimation2D;
                }
                break;

            case AnimActionType.AttackLeftHand:
                if (!CacheLeftHandAttackAnimations.TryGetValue(dataId, out animation2D))
                {
                    animation2D = defaultAttackAnimation2D;
                }
                break;

            case AnimActionType.Skill:
                if (!CacheSkillCastAnimations.TryGetValue(dataId, out animation2D))
                {
                    animation2D = defaultSkillCastAnimation2D;
                }
                break;
            }
            return(animation2D);
        }
コード例 #5
0
        private ActionAnimation2D GetActionAnimation(AnimActionType animActionType, int dataId)
        {
            ActionAnimation2D animation2D = null;
            SkillAnimations2D skillAnimations2D;

            switch (animActionType)
            {
            case AnimActionType.AttackRightHand:
                if (!CacheRightHandAttackAnimations.TryGetValue(dataId, out animation2D))
                {
                    animation2D = defaultAttackAnimation2D;
                }
                break;

            case AnimActionType.AttackLeftHand:
                if (!CacheLeftHandAttackAnimations.TryGetValue(dataId, out animation2D))
                {
                    animation2D = defaultAttackAnimation2D;
                }
                break;

            case AnimActionType.Skill:
                if (!CacheSkillAnimations.TryGetValue(dataId, out skillAnimations2D))
                {
                    animation2D = defaultSkillActivateAnimation2D;
                }
                else
                {
                    animation2D = skillAnimations2D.activateAnimation;
                }
                break;

            case AnimActionType.ReloadRightHand:
                if (!CacheRightHandReloadAnimations.TryGetValue(dataId, out animation2D))
                {
                    animation2D = defaultReloadAnimation2D;
                }
                break;

            case AnimActionType.ReloadLeftHand:
                if (!CacheLeftHandReloadAnimations.TryGetValue(dataId, out animation2D))
                {
                    animation2D = defaultReloadAnimation2D;
                }
                break;
            }
            return(animation2D);
        }
コード例 #6
0
        public override bool HasSkillCastAnimations(int dataId)
        {
            ActionAnimation2D animation2D = null;

            if (!CacheSkillCastAnimations.TryGetValue(dataId, out animation2D))
            {
                animation2D = defaultSkillCastAnimation2D;
            }
            if (animation2D == null)
            {
                return(false);
            }
            var clip = animation2D.GetClipByDirection(currentDirectionType);

            if (clip == null)
            {
                return(false);
            }
            return(true);
        }