Beispiel #1
0
 private void AttackTree()
 {
     if (!animationAttackStateBeenSet)
     {
         SetAttackState();
     }
     treeToAttack.TakeDamage(damage);
     readyToAttack = false;
     StartCoroutine(DisableAttack());
 }
Beispiel #2
0
 void Attack()
 {
     //   if(!initialized || finding) {
     //      return;
     //}
     if (treeHealth.currentHealth > 0 && Time.time >= nextFire && enemyHealth.currentHealth > 0)
     {
         animator.SetTrigger("attack");
         treeHealth.TakeDamage(attackDamage);
         nextFire  = Time.time + timeBetweenAttacks;
         attacking = true;
         //play audio
         int i = Random.Range(0, attackClip.Length);
         audioSource.PlayOneShot(attackClip[i], 0.5f);
     }
     else
     {
         attacking = false;
     }
 }