Esempio n. 1
0
    public void Shoot(HealthComponent.Team mySide)
    {
        if (!CanShoot())
        {
            return;
        }

        // Get spawn info
        Vector2    spawnPosition;
        Quaternion spawnRotation;

        if (BulletSpawnPos != null)
        {
            spawnPosition = BulletSpawnPos.position;
            spawnRotation = BulletSpawnPos.rotation;
        }
        else
        {
            spawnPosition = transform.position;
            spawnRotation = transform.rotation;
        }

        // Spawn bullet
        Projectile newBullet = Instantiate(ProjectilePrefab, spawnPosition, spawnRotation, BulletParent);

        Damage dmg = newBullet.GetComponentInChildren <Damage>();

        dmg.Amount = DmgPerSec * FireCooldown;
        dmg.Side   = mySide;

        // Fire Bullet
        FireBullet(newBullet);

        if (_audioSource != null)
        {
            // Play sound
            AudioClip clip = _soundClipManager.GetRandomSoundEffect(SoundEffectID);
            if (clip != null)
            {
                _audioSource.PlayOneShot(clip);
            }
        }


        // Spend Ammo
        --AmmoLeft;
    }
Esempio n. 2
0
    void PlayNoise()
    {
        if (_audioSource == null)
        {
            return;
        }

        AudioClip sound = _soundManager.GetRandomSoundEffect(SoundEffectID);

        if (sound == null)
        {
            return;
        }

        _prevSoundDuration = sound.length;
        _audioSource.PlayOneShot(sound);
    }