/// <summary> /// Coroutine which uses the attack, waits for the attack animation to finish and /// then re-sets the nextAttack object. /// This way, enemy starts moving again only after the attack is finished. /// </summary> /// <returns></returns> private IEnumerator UseAndResetAttack() { attacking = true; yield return(StartCoroutine(nextAttackToUse.UseAttack(this))); Debug.Log("Attacking coroutine finished."); nextAttackToUse = null; attacking = false; }
/// <summary> /// Coroutine which will raise attacking flag, executes actual attack /// and after its finished, resets the attacking flag again. /// </summary> /// <param name="attack">Attack to execute.</param> /// <returns></returns> private IEnumerator DoAttack(AbstractAttack attack) { isAttacking = true; yield return(StartCoroutine(attack.UseAttack(this))); Debug.Log("Player attack finished."); isAttacking = false; killedEnemies += attack.GetTargetKillCount(); Debug.Log("Killed enemies:" + killedEnemies); }