Пример #1
0
    public override void StartAttack()
    {
        if (lastAttackTime == 0.0f || Time.time > (lastAttackTime + attackCooldown))
        {
            // play the sound effect
            if (soundEffectPlayer != null)
            {
                soundEffectPlayer.PlayDaggerSound();
            }

            // remember time for cooldown purposes
            lastAttackTime = Time.time;

            // show the attack animation
            animator.SetBool("Attack", true);

            // deal damage
            foreach (GameObject collidingObject in collidingObjects)
            {
                Health health = collidingObject.GetComponent <Health>();
                if (health != null)
                {
                    health.TakeDamage(meleeDamage, this);
                }
            }
        }
    }