Exemple #1
0
 public void StopSFX(SFXList type)
 {
     foreach (var entry in entries)
     {
         if (entry.type == type)
         {
             entry.sound.Stop();
         }
     }
 }
Exemple #2
0
 public void PlaySFX(SFXList type)
 {
     foreach (var entry in entries)
     {
         if (entry.type == type)
         {
             entry.sound.Play();
         }
     }
 }
Exemple #3
0
    public void PlaySoundEffect(string _soundName)
    {
        SFXList s = Array.Find(sounds, sound => sound.soundName == _soundName);

        if (s == null)
        {
            Debug.LogWarning(_soundName + " not found.");
            return;
        }
        s.source.Play();
    }
Exemple #4
0
    public static SFXList LoadSFXList(string path)
    {
        StreamReader reader       = new StreamReader(path);
        var          saveDataJson = reader.ReadToEnd();

        reader.Close();

        SFXList sfxList = JsonUtility.FromJson <SFXList>(saveDataJson);

        return(sfxList);
    }
Exemple #5
0
 public bool PlaySFX(SFXList soundIndex, float pitch = 1.0f, float volume = 1.0f)
 {
     if (m_SFXClips.Length - 1 < (int)soundIndex)
     {
         return(false);
     }
     m_SFXSource[m_iSESourceIndex].clip   = m_SFXClips[(int)soundIndex];
     m_SFXSource[m_iSESourceIndex].volume = volume;
     m_SFXSource[m_iSESourceIndex].pitch  = pitch;
     m_SFXSource[m_iSESourceIndex].Play();
     m_iSESourceIndex++;
     m_iSESourceIndex = m_iSESourceIndex % 5;
     return(true);
 }
    public static void CreateSFX()
    {
        string classDefinition = string.Empty;

        classDefinition += "public class SFX\n";

        classDefinition += "{\n";


        SFXList sfxList = SFXList.LoadSFXList(InputConfigPath);

        foreach (string sound in sfxList.SFX)
        {
            classDefinition += string.Format("\tpublic const string {0} = \"{0}\";\n", sound);
        }

        classDefinition += "}\n";

        File.WriteAllText(OutputPath, classDefinition);
    }
Exemple #7
0
        public SFXList LoadSound(string name, SoundEffect data)
        {
            name = name.ToLower();
            if (sounds.ContainsKey(name))
            {
                if (ContentDuplicateBehavior == ContentDuplicateBehaviors.Replace)
                {
                    sounds.Remove(name);
                }
                else
                {
                    return(sounds[name]);
                }
            }
            var sfxlist = new SFXList {
                data
            };

            sounds.Add(name, sfxlist);
            return(sfxlist);
        }
Exemple #8
0
        public SFXList LoadSounds(string name, params string[] paths)
        {
            SFXList sfxlist = new SFXList();

            foreach (var item in paths)
            {
                sfxlist.AddRange(LoadSound(item));
            }
            if (sounds.ContainsKey(name))
            {
                if (ContentDuplicateBehavior == ContentDuplicateBehaviors.Replace)
                {
                    sounds.Remove(name);
                }
                else
                {
                    return(sounds[name]);
                }
            }
            sounds.Add(name, sfxlist);
            return(sfxlist);
        }