Пример #1
0
 void PlayGunSound()
 {
     //Play gun sound
     if (gunSounds != null)
     {
         // Debug.Log("Player gun sound");
         gunSounds.PlayOnce();
     }
 }
Пример #2
0
    void OnTriggerEnter(Collider other)
    {
        //Retreive damageable
        Damageable dmg = other.GetComponent <Damageable>();

        //Exit if nothing hit
        if (dmg == null)
        {
            return;
        }

        //Prevent self harm
        if (dmg.gameObject == m_owner)
        {
            return;
        }

        //Bounce of an object that is not on target layer
        if ((targetLayers.value & (1 << other.gameObject.layer)) == 0)
        {
            return;
        }

        //Do the damage!
        dmg.TakeDamage(damage);

        //Play a sound
        if (impactSounds != null)
        {
            impactSounds.PlayOnce();
        }

        //Particles!
        if (hitParticle != null)
        {
            hitParticle.Play();
        }

        //Clean up (gun is responsible for destroying object)
        if (destroyOnContact)
        {
            Destroy(gameObject);
        }
    }
Пример #3
0
 //------- Accessible via unity events ------/
 private void PlayHitSound()
 {
     hitSounds.PlayOnce();
 }