예제 #1
0
        /// <summary>
        /// 根据移速矫正动画播放
        /// </summary>
        public void PlayRunAnimationByMoveSpeed()
        {
            if (this.Entity.GetComponent <StackFsmComponent>().GetCurrentFsmState().StateTypes != StateTypes.Run)
            {
                return;
            }

            HeroDataComponent heroDataComponent = this.Entity.GetComponent <HeroDataComponent>();
            float             animSpeed         = heroDataComponent.GetAttribute(NumericType.Speed) / heroDataComponent.GetAttribute(NumericType.SpeedBase);

            this.Entity.GetComponent <AnimationComponent>().PlayAnimByStackFsmCurrent(0.3f, animSpeed);
        }
        private async ETTask CommonAttack_Internal(Unit targetUnit, CancellationTokenSource cancellationTokenSource)
        {
            HeroDataComponent heroDataComponent = this.Entity.GetComponent <HeroDataComponent>();
            float             attackPre         = heroDataComponent.NodeDataForHero.OriAttackPre / (1 + heroDataComponent.GetAttribute(NumericType.AttackSpeedAdd));
            float             attackSpeed       = heroDataComponent.GetAttribute(NumericType.AttackSpeed);

            //这里假设诺手原始攻击动画0.32s是动画攻击奏效点
            float animationAttackPoint = 0.32f;

            float animationSpeed = animationAttackPoint / attackPre;

            //播放动画,如果动画播放完成还不能进行下一次普攻,则播放空闲动画
            this.m_AnimationComponent.PlayAnimAndReturnIdelFromStart(StateTypes.CommonAttack, speed: animationSpeed);

            Game.Scene.GetComponent <SoundComponent>().PlayClip("Sound_Darius_NormalAttack", 0.4f).Coroutine();

            await TimerComponent.Instance.WaitAsync((long)(1 / attackSpeed * 1000), cancellationTokenSource.Token);
        }