public static void Play(SOUNDS sound, Vector3 pointToPlayAt, bool killWhenDone = true)
 {
     try {
         var clipInfo       = s_Instance.enumToSoundDataMap[sound];
         var tmpAudioSource = Instantiate(s_Instance.m_templateAudio) as AudioSource;
         tmpAudioSource.transform.position = pointToPlayAt;
         tmpAudioSource.clip    = clipInfo.clip;
         tmpAudioSource.volume  = clipInfo.volume;
         tmpAudioSource.volume += Random.Range(-1 * clipInfo.volumeVariance, 0f);
         tmpAudioSource.pitch  += Random.Range(-1 * clipInfo.frequencyVariance, clipInfo.frequencyVariance);
         tmpAudioSource.loop    = clipInfo.loop;
         tmpAudioSource.Play();
         if (killWhenDone)
         {
             s_Instance.StartCoroutine(s_Instance.killWhenDone(tmpAudioSource));
         }
         else
         {
             s_Instance.StartCoroutine(s_Instance.trackVRHeadset(tmpAudioSource));
         }
     }
     catch (Exception e) {
         Debug.LogWarning("Sound play error:" + e.Message);
     }
 }
        /// <summary>
        /// Loads the sound.
        /// </summary>
        /// <param name="sound">The sound.</param>
        /// <param name="file">The file.</param>
        private void LoadSound(SOUNDS sound, string file)
        {
            int soundIndex = (int)sound;

            this.sounds[soundIndex] = new SoundInfo(file);
            this.soundsBank.Add(this.sounds[soundIndex]);
        }
Exemple #3
0
        /// <summary>
        /// Loads the sound.
        /// </summary>
        /// <param name="sound">The sound.</param>
        /// <param name="file">The file.</param>
        private void LoadSound(SOUNDS sound, string file)
        {
            int soundIndex = (int)sound;

            this.sounds[soundIndex] = new SoundInfo(file);
            this.soundsBank.Add(this.sounds[soundIndex]);
        }
    public static void Play(SOUNDS sound)
    {
        if (muted)
            return;
        switch (sound)
        {
            case SOUNDS.SELECT:
                instance.source.clip = instance.Select;
                break;
        case SOUNDS.NEGATIVE:
            instance.source.clip = instance.Negative;
            break;

        case SOUNDS.COINGET:
            instance.source.clip = instance.Coinget;
            break;
        case SOUNDS.COINLOSE:
            instance.source.clip = instance.Coinlose;
            break;
        case SOUNDS.LOSEHEALTH:
            instance.source.clip = instance.loseHealth;
            break;
        case SOUNDS.SWORDDRAW:
            instance.source.clip = instance.SwordDraw;
            break;
        case SOUNDS.SWORDFIGHT:
            instance.source.clip = instance.SwordFight;
            break;
        }
        instance.source.Play();
    }
Exemple #5
0
    public static void PlayAudio(SOUNDS sound, float volume = 1f)
    {
        if (instance == null)
        {
            return;
        }

        instance._PlayAudio(sound, volume);
    }
Exemple #6
0
        /// <summary>
        /// Plays the sound.
        /// </summary>
        /// <param name="sound">The sound.</param>
        /// <param name="volume">The volume.</param>
        /// <param name="loop">if set to <c>true</c> [loop].</param>
        /// <returns></returns>
        public SoundInstance PlaySound(SOUNDS sound, float volume, bool loop)
        {
            int soundIndex = (int)sound;

            if (soundIndex >= 0 && soundIndex < this.sounds.Length && this.sounds[soundIndex] != null)
            {
                return(WaveServices.SoundPlayer.Play(this.sounds[soundIndex], volume, loop));
            }
            return(null);
        }
    public void Play(string name)
    {
        SOUNDS s = Array.Find(sounds, sound => sound.name == name);

        if (s == null)
        {
            return;
        }
        s.source.Play();
    }
Exemple #8
0
        public void AddSounds(string name)
        {
            if (SOUNDS == null)
            {
                SOUNDS = new List <string>();
            }

            name = name.Replace('/', '\\');

            if (!SOUNDS.Contains(name))
            {
                SOUNDS.Add(name);
            }
        }
Exemple #9
0
    public static void SoundController(SOUNDS key, bool play)
    {
        AudioSource s;

        if (soundCollection.TryGetValue(key, out s))
        {
            if (play)
            {
                s.Play();
            }
            else if (s.isPlaying)
            {
                s.Stop();
            }
        }
    }
Exemple #10
0
    public void playSound(SOUNDS sound)
    {
        AudioClip clipToPlay = null;

        switch (sound)
        {
        case SOUNDS.NEW_MESSAGE:
            clipToPlay = newMessageSound;
            break;

        case SOUNDS.SHARED_LOCATION:
            clipToPlay = sharedLocationSound;
            break;

        default:
            print("invalid sound requested");
            break;
        }

        sc.attemptSound(clipToPlay, 0.03f, 1.0f);
    }
Exemple #11
0
    public static void Play(SOUNDS sound)
    {
        if (muted)
        {
            return;
        }
        switch (sound)
        {
        case SOUNDS.SELECT:
            instance.source.clip = instance.Select;
            break;

        case SOUNDS.NEGATIVE:
            instance.source.clip = instance.Negative;
            break;

        case SOUNDS.COINGET:
            instance.source.clip = instance.Coinget;
            break;

        case SOUNDS.COINLOSE:
            instance.source.clip = instance.Coinlose;
            break;

        case SOUNDS.LOSEHEALTH:
            instance.source.clip = instance.loseHealth;
            break;

        case SOUNDS.SWORDDRAW:
            instance.source.clip = instance.SwordDraw;
            break;

        case SOUNDS.SWORDFIGHT:
            instance.source.clip = instance.SwordFight;
            break;
        }
        instance.source.Play();
    }
Exemple #12
0
 public string[] GetSounds()
 {
     return(SOUNDS.ToArray());
 }
Exemple #13
0
 private void _PlayAudio(SOUNDS sound, float volume = 1)
 {
     aS.pitch += UnityEngine.Random.Range(-0.2f, 0.2f);
     aS.PlayOneShot(audioClipsDic[sound], volume * SaveManager.Settings.soundEffectVolume);
     aS.pitch = 1;
 }
 public static void Play(SOUNDS sound)     //default position is at the vr players head
 {
     Play(sound, InputTracking.GetLocalPosition(VRNode.Head));
 }
Exemple #15
0
    public void play(SOUNDS sound)
    {
        if (mSource == null)
        {
            return;
        }
        switch (sound)
        {
        case SOUNDS.BUTTON_CLICK:
            mSource.PlayOneShot(buttonClick);
            break;

        case SOUNDS.COLLECT_POSITIVE_POWERUP:
            mSource.PlayOneShot(collectPositivePowerup);
            break;

        case SOUNDS.COLLECT_NEGATIVE_POWERUP:
            mSource.PlayOneShot(collectNegativePowerup, 0.2f);
            break;

        case SOUNDS.COLLECT_TARGET:
            mSource.PlayOneShot(collectTarget);
            break;

        case SOUNDS.MENU:
            mLoopSource.clip = menu;
            mLoopSource.Play();
            break;

        case SOUNDS.BACKTRACK1:
            mLoopSource.clip = backtrack1;
            mLoopSource.Play();
            break;

        case SOUNDS.BACKTRACK2:
            mLoopSource.clip = backtrack2;
            mLoopSource.Play();
            break;

        case SOUNDS.BACKTRACK3:
            mLoopSource.clip = backtrack3;
            mLoopSource.Play();
            break;

        case SOUNDS.FAILEDCALIBRATION:
            mSource.PlayOneShot(failedCalibration);
            break;

        case SOUNDS.SUCCESSCALIBRATION:
            mSource.PlayOneShot(successCalibration);
            break;

        case SOUNDS.JOIN:
            mSource.PlayOneShot(join);
            break;

        case SOUNDS.PLAYERKICKED:
            mSource.PlayOneShot(playerKicked);
            break;

        case SOUNDS.NATIVE_FADE_IN:
            mSource.PlayOneShot(nativeFadeInClip);
            break;

        case SOUNDS.NATIVE_FADE_OUT:
            mSource.PlayOneShot(nativeFadeOutClip);
            break;

        case SOUNDS.NATIVE_INTERACT:
            mSource.PlayOneShot(nativeInteractClip);
            break;

        case SOUNDS.NATIVE_REJECT:
            mSource.PlayOneShot(nativeRejectClip);
            break;

        case SOUNDS.NATIVE_SELECT:
            mSource.PlayOneShot(nativeSelectClip);
            break;
        }
    }
Exemple #16
0
 /// <summary>
 /// Plays the sound.
 /// </summary>
 /// <param name="sound">The sound.</param>
 /// <param name="loop">if set to <c>true</c> [loop].</param>
 /// <returns></returns>
 public SoundInstance PlaySound(SOUNDS sound, bool loop)
 {
     return(this.PlaySound(sound, defaultVolume, loop));
 }
 /// <summary>
 /// Plays the sound.
 /// </summary>
 /// <param name="sound">The sound.</param>
 /// <param name="volume">The volume.</param>
 /// <param name="loop">if set to <c>true</c> [loop].</param>
 /// <returns></returns>
 public SoundInstance PlaySound(SOUNDS sound, float volume, bool loop)
 {
     int soundIndex = (int)sound;
     if (soundIndex >= 0
         && soundIndex < this.sounds.Length
         && this.sounds[soundIndex] != null
         )
     {
         return WaveServices.SoundPlayer.Play(this.sounds[soundIndex], volume, loop);
     }
     return null;
 }
 /// <summary>
 /// Plays the sound.
 /// </summary>
 /// <param name="sound">The sound.</param>
 /// <param name="loop">if set to <c>true</c> [loop].</param>
 /// <returns></returns>
 public SoundInstance PlaySound(SOUNDS sound, bool loop)
 {
     return this.PlaySound(sound, defaultVolume, loop);
 }
Exemple #19
0
    public void playSound(SOUNDS sound)
    {
        AudioClip clipToPlay = null;

        switch (sound)
        {
        case SOUNDS.CLONE:
            clipToPlay = cloneSound;
            break;

        case SOUNDS.SPLICE:
            clipToPlay = spliceSound;
            break;

        case SOUNDS.FARM:
            clipToPlay = farmSound;
            break;

        case SOUNDS.HARVEST:
            clipToPlay = harvestSound;
            break;

        case SOUNDS.HARVEST_ROTTEN:
            clipToPlay = harvestRottenSound;
            break;

        case SOUNDS.PLACE_IN_SPLICE_MACHINE:
            clipToPlay = placeBaseSpecieInSpliceMachineSound;
            break;

        case SOUNDS.SELECT_SHELF_OBJ:
            clipToPlay = selectShelfObjectSound;
            break;

        case SOUNDS.FEAST:
            clipToPlay = feastSound;
            break;

        case SOUNDS.ERROR_LAB:
            clipToPlay = labErrorSound;
            break;

        case SOUNDS.ENTER_LAB:
            clipToPlay = enterLabSound;
            break;

        case SOUNDS.LEAVE_LAB:
            clipToPlay = enterLabSound;
            break;

        case SOUNDS.NIGHT_DEFAULT:
            clipToPlay = normalNightSound;
            break;

        case SOUNDS.NIGHT_EARTHQUAKE:
            clipToPlay = earthquakeNightSound;
            break;

        case SOUNDS.NIGHT_WIND:
            clipToPlay = windNightSound;
            break;

        case SOUNDS.NIGHT_WATER:
            clipToPlay = waterNightSound;
            break;

        case SOUNDS.DEFAULT_UI:
            clipToPlay = defaultUISound;
            break;

        case SOUNDS.READ_MESSAGE:
            clipToPlay = readBottleMessage;
            break;

        default:
            print("invalid sound requested");
            break;
        }
        sc.attemptSound(clipToPlay, 0.1f);
    }
Exemple #20
0
 /// <summary>
 /// Plays the sound.
 /// </summary>
 /// <param name="sound">The sound.</param>
 /// <returns></returns>
 public SoundInstance PlaySound(SOUNDS sound)
 {
     return(this.PlaySound(sound, defaultVolume, false));
 }
 public void PlaySound(SOUNDS _sound)
 {
     GetComponent <AudioSource>().clip  = sounds[(int)_sound];
     GetComponent <AudioSource>().pitch = 1.0f;
     GetComponent <AudioSource>().Play();
 }
Exemple #22
0
 public void PlaySound(SOUNDS sound, float volume = 0.3f)
 {
     _audioSource.PlayOneShot(_loadedSounds[sound], volume * MasterVolume);
 }
Exemple #23
0
 /// <summary>
 /// Plays the sound.
 /// </summary>
 /// <param name="sound">The sound.</param>
 /// <param name="volume">The volume.</param>
 /// <returns></returns>
 public SoundInstance PlaySound(SOUNDS sound, float volume)
 {
     return(this.PlaySound(sound, volume, false));
 }
 /// <summary>
 /// Plays the sound.
 /// </summary>
 /// <param name="sound">The sound.</param>
 /// <returns></returns>
 public SoundInstance PlaySound(SOUNDS sound)
 {
     return this.PlaySound(sound, defaultVolume, false);
 }
 public void PlaySoundRandomPitch(SOUNDS _sound)
 {
     GetComponent <AudioSource>().clip  = sounds[(int)_sound];
     GetComponent <AudioSource>().pitch = 1.0f + Random.Range(-0.08f, 0.1f);
     GetComponent <AudioSource>().Play();
 }
 /// <summary>
 /// Plays the sound.
 /// </summary>
 /// <param name="sound">The sound.</param>
 /// <param name="volume">The volume.</param>
 /// <returns></returns>
 public SoundInstance PlaySound(SOUNDS sound, float volume)
 {
     return this.PlaySound(sound, volume, false);
 }