Ejemplo n.º 1
0
        IEnumerator AttackTargetRepeatedly()
        {
            // determine if alive (attacker and defender)
            bool attackerStillAlive = GetComponent <HealthSystem>().HealthAsPercentage >= Mathf.Epsilon;
            bool defenderStillAlive = target.GetComponent <HealthSystem>().HealthAsPercentage >= Mathf.Epsilon;

            // while the attacker and the defender still alive keep attacking ???
            // tneho que testar se o atacante ainda esta vivo, se esta continua atacando
            while (attackerStillAlive && defenderStillAlive)
            {
                var animationClip = currentWeaponConfig.GetAttackAnimationClip();

                // is the multiplier is 2 it will be twice as fast, them the clip time will be half as long
                float animationClipTime = animationClip.length / character.GetAnimSpeedMultiplier();

                float timeToWait = animationClipTime + currentWeaponConfig.GetTimeBetweenAnimationCycles();

                bool isTimeToHitAgain = Time.time - lastHitTime > timeToWait;

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

                yield return(new WaitForSeconds(timeToWait));
            }
        }
Ejemplo n.º 2
0
 void SetupAttackAndDeathAnimation()
 {
     if (!character.GetAnimatorOverrideController())
     {
         Debug.Break();
         Debug.LogAssertion("Provide " + gameObject + " with an animation Override Controller");
     }
     else
     {
         AnimatorOverrideController animatorOverrideController = character.GetAnimatorOverrideController();
         animator.runtimeAnimatorController = animatorOverrideController;
         animatorOverrideController[Constants.DEFAULT_ATTACK] = currentWeaponConfig.GetAttackAnimationClip();
         animatorOverrideController[Constants.DEFAULT_DEATH]  = currentWeaponConfig.GetDeathAnimationClip();
     }
 }