Ejemplo n.º 1
0
 public void stopSound(EnumsData.SoundEnum soundEnum)
 {
     foreach (var s in this.sounds)
     {
         if (s.sound == soundEnum)
         {
             s.audioSource.Stop();
             return;
         }
     }
 }
Ejemplo n.º 2
0
 public void playSoundOnce(EnumsData.SoundEnum soundEnum)
 {
     foreach (var s in this.sounds)
     {
         if (s.sound == soundEnum)
         {
             s.audioSource.Play();
             return;
         }
     }
 }
Ejemplo n.º 3
0
 public void playMusic(EnumsData.SoundEnum soundEnum)
 {
     foreach (var s in this.sounds)
     {
         if (s.sound == soundEnum && s.isMusic)
         {
             s.audioSource.Play();
             return;
         }
         else if (s.isMusic)
         {
             s.audioSource.Stop();
         }
     }
 }
Ejemplo n.º 4
0
    public void playSoundOnceAt(EnumsData.SoundEnum soundEnum, Vector3 playPosition)
    {
        playPosition.z = 0f;
        foreach (var s in this.sounds)
        {
            if (s.sound == soundEnum)
            {
                if (s.audioSource.isPlaying)
                {
                    AudioSource.PlayClipAtPoint(s.clip, playPosition);
                }
                else
                {
                    s.audioSource.transform.position = playPosition;
                    s.audioSource.Play();
                }

                return;
            }
        }
    }