Exemplo n.º 1
0
 /// <summary>
 /// Tries to fire a bullet in the given direction if the gun is ready to fire again.
 /// </summary>
 public virtual void Fire(Vector2 dir)
 {
     if (cooldown.CanUse())
     {
         SpawnBullet(dir);
     }
 }
Exemplo n.º 2
0
        public virtual bool ApplyDamage(float damage)
        {
            if (currentHealth <= 0 || (damage > 0 && !cooldown.CanUse()))
            {
                return(false);
            }

            currentHealth -= damage;

            if (hurtClip != null && damage > 0)
            {
                AudioSource.PlayClipAtPoint(hurtClip, Camera.main.transform.position, hurtVolume);
            }

            if (currentHealth <= 0)
            {
                OutOfHealth();
            }

            return(true);
        }