コード例 #1
0
        private void AddToMap(AudioConfig.SoundBlueprint[] files)
        {
            //INIT UI AUDIO
            int         i;
            int         allAudio = files.Length;
            SoundObject tempSoundObj;
            AudioClip   clip;
            string      audioName;

            for (i = 0; i < allAudio; i++)
            {
                AudioConfig.SoundBlueprint file = files[i];
                SoundBank.Type             key  = file.key;
                clip      = file.clip;
                audioName = file.name;
                if (clip)
                {
                    if (!_levelAudioMap.ContainsKey(key))
                    {
                        tempSoundObj        = new SoundObject(file, audioParent);
                        _levelAudioMap[key] = tempSoundObj;
                    }
                    else
                    {
                        Debug.Log("Key " + key + "exists in the Audio file map which means there are duplicate keys for Level audio in the Audio ScriptableObject");
                    }
                }
                else
                {
                    Debug.LogError("There is no Audio Clip Attached to " + audioName + " in the Level Audio List");
                }
            }
        }
コード例 #2
0
 public void PlayUISound(AudioFiles.UISoundClip sound)
 {
     if (uiSoundLookup == null)
     {
         CreateLookups();
     }
     if (!uiSoundLookup.ContainsKey(sound))
     {
         Debug.LogError("No Sound Found in Sound Lookup");
         return;
     }
     tempSoundObj = uiSoundLookup[sound];
     tempSoundObj.PlaySound();
 }
コード例 #3
0
 //play sound 3D
 public void PlayGameplaySound(AudioFiles.GameplaySoundClip sound, Vector3 position)
 {
     if (gameplaySoundLookup == null)
     {
         CreateLookups();
     }
     if (!gameplaySoundLookup.ContainsKey(sound))
     {
         Debug.LogError("No Sound Found in Sound Lookup");
         return;
     }
     tempSoundObj = gameplaySoundLookup[sound];
     tempSoundObj.PlaySound(position);
 }
コード例 #4
0
        private void CreateLookups()
        {
            gameplaySoundLookup = new Dictionary <AudioFiles.GameplaySoundClip, SoundObject>();
            uiSoundLookup       = new Dictionary <AudioFiles.UISoundClip, SoundObject>();

            foreach (AudioFiles.AudioBlueprint blueprint in files.gameplaySounds)
            {
                tempSoundObj = new SoundObject(blueprint);
                gameplaySoundLookup.Add((AudioFiles.GameplaySoundClip)Enum.Parse(typeof(AudioFiles.GameplaySoundClip), blueprint.clip.name), tempSoundObj);
            }
            foreach (AudioFiles.AudioBlueprint blueprint in files.UISounds)
            {
                tempSoundObj = new SoundObject(blueprint);
                uiSoundLookup.Add((AudioFiles.UISoundClip)Enum.Parse(typeof(AudioFiles.UISoundClip), blueprint.clip.name), tempSoundObj);
            }
        }
コード例 #5
0
        public void PlaySound(SoundBank.Type key, GameObject obj = null, bool Randompitch = false)
        {
            if (_levelAudioMap == null)
            {
                return;
            }

            if (!_levelAudioMap.ContainsKey(key))
            {
                Debug.LogError(key + " Not Found in Sound Lookup");
            }
            else
            {
                SoundObject soundObj = _levelAudioMap[key];
                soundObj.PlaySound(obj, Randompitch);
            }
        }