Esempio n. 1
0
        IEnumerator AttackTargetRepeatedly()
        {
            bool attackerStillAlive = GetComponent <HealthSystem>().healthAsPercentage >= Mathf.Epsilon;
            bool targetStillAlive   = target.GetComponent <HealthSystem>().healthAsPercentage >= Mathf.Epsilon;

            while (attackerStillAlive && targetStillAlive)
            {
                var   animationClip     = currentWeaponConfig.GetAnimClip();
                float animationClipTime = animationClip.length / character.GetAnimationSpeedMultiplier();
                float timeToWait        = animationClipTime + currentWeaponConfig.GetTimeBetweenAnimationsCycle();
                bool  isTimeToHitAgain  = Time.time - lastHitTime > timeToWait;
                if (isTimeToHitAgain)
                {
                    AttackTargetOnce();
                    lastHitTime = Time.time;
                }
                yield return(new WaitForSeconds(timeToWait));
            }
        }
Esempio n. 2
0
        IEnumerator AttackTargetRepeatedly()
        {
            bool attackerStillAlive = GetComponent <HealthSystem>().healthAsPercentage >= Mathf.Epsilon;
            bool targetStillAlive   = target.GetComponent <HealthSystem>().healthAsPercentage >= Mathf.Epsilon;

            while (attackerStillAlive && targetStillAlive)
            {
                float animationClipTime = currentWeaponConfig.GetDeathAnimationClip().length;
                animationClipTime /= character.GetAnimationSpeedMultiplier();
                float timeToWait = animationClipTime + currentWeaponConfig.GetMinTimeBetweenAnimationCycles() + Random.Range(-Constants.ATTACK_TIME_OFFSET, Constants.ATTACK_TIME_OFFSET);

                bool isTimeToHitAgain = Time.time - lastHitTime > timeToWait;

                if (isTimeToHitAgain)
                {
                    AttackTargetOnce();
                    lastHitTime = Time.time;
                }

                yield return(new WaitForSeconds(timeToWait));
            }
        }
Esempio n. 3
0
        private IEnumerator AttackTargetRepeatedly()
        {
            bool attackerStillAlive = GetComponent <HealthSystem>().HealthAsPercentage() >= Mathf.Epsilon;
            bool targetStillAlive   = target.GetComponent <HealthSystem>().HealthAsPercentage() >= Mathf.Epsilon;

            while (attackerStillAlive && targetStillAlive)
            {
                AnimationClip animationClip     = currentWeaponConfig.GetAttackAnimClip();
                float         animationClipTime = animationClip.length / character.GetAnimationSpeedMultiplier();
                float         attackTime        = animationClipTime + currentWeaponConfig.GetWaitTimeBetweenAnimations();

                bool timeToAttack = (Time.time - lastHitTime) > attackTime;

                if (timeToAttack)
                {
                    lastHitTime = Time.time;

                    AttackTargetOnce();
                }

                yield return(new WaitForSeconds(attackTime));
            }
        }