/// <summary> /// Plays animation for when attack is dodged /// </summary> /// <param name="animationClipName"> Name of animation to play overtop of monster </param> /// <returns> IEnumerator for animations</returns> public IEnumerator DisplayAttackDodged(string animationClipName) { isAnimating = true; SetEffectsAnimatorClip(animationClipName); yield return(StartCoroutine(PlayAnimation(effectsAnimator, "attacked"))); dt.ShowDodged(); yield return(StartCoroutine(PlayAnimation(dt.textAnimator, "showDamage"))); dt.HideDamage(); isAnimating = false; }
/// <summary> /// Reduce monster's HP /// </summary> /// <param name="amount"> Amount of HP to lose, not negative </param> /// <param name="animationClipName"> Name of clip to play when monster is attacked </param> /// <returns> Starts coroutine of monster being attacked, before yielding control </returns> public IEnumerator LoseHP(int amount, string animationClipName) { CHP -= amount; if (CHP < 0) { CHP = 0; } SetEffectsAnimatorClip(animationClipName); yield return(StartCoroutine(PlayAnimation(effectsAnimator, "attacked"))); dt.ShowDamage(amount); HPBar.SetCurrent(CHP); yield return(StartCoroutine(PlayTwoAnimations(monsterAnimator, dt.textAnimator, "damaged", "showDamage"))); dt.HideDamage(); }