Beispiel #1
0
        private ISound FindSound(string name)
        {
            var list = new List <ISound>();

            list.AddRange(SoundEffects.Where(a => a.Key == name).Select(a => a.Value).ToList());
            list.AddRange(Songs.Where(a => a.Key == name).Select(a => a.Value).ToList());

            return(list.FirstOrDefault());
        }
Beispiel #2
0
 public bool AddSound(KeyValuePair <string, string> song)
 {
     if (IsUniqueName(song))
     {
         var soundFile = Content.Load <SoundEffect>(song.Value);
         SoundEffects.Add(song.Key.ToLower(), new SoundEffects(soundFile));
         return(true);
     }
     return(false);
 }
Beispiel #3
0
 public SoundEffect GetSoundEffect(string hoverSoundName)
 {
     return(SoundEffects.FirstOrDefault(a => a.Key == hoverSoundName).Value.sound);
 }
Beispiel #4
0
 private bool IsUniqueName(KeyValuePair <string, string> key)
 {
     return(!string.IsNullOrEmpty(key.Key.ToLower()) && !string.IsNullOrEmpty(key.Value) &&
            SoundEffects.Count(a => a.Key == key.Key.ToLower()) == 0 && Songs.Count(a => a.Key == key.Value) == 0);
 }