public static void PlaySound(SoundEnum soundEnum)
        {
            var sound = soundEnum.ToString();
            // Get the sound from the XAP file
            var info = App.GetResourceStream(
                new Uri(String.Format("Resources/Music/{0}.wav", sound), UriKind.Relative));
            // Load the SoundEffect
            var effect = SoundEffect.FromStream(info.Stream);

            // Tell the XNA Libraries to continue to run
            FrameworkDispatcher.Update();

            // Play the Sound
            effect.Play();
        }
        public AbstractSoundEffect MakeSoundEffect(SoundEnum soundEffectType)
        {
            SoundEffect soundEffect = soundLoader.GetSoundEffect(soundEffectType);

            return(soundEffectType switch
            {
                SoundEnum.SwordSlash => new SwordSlashSoundEffect(soundEffect),
                SoundEnum.SwordShoot => new SwordShootSoundEffect(soundEffect),
                SoundEnum.Arrow => new ArrowSoundEffect(soundEffect),
                SoundEnum.Boomerang => new BoomerangSoundEffect(soundEffect),
                SoundEnum.Shield => new ShieldSoundEffect(soundEffect),
                SoundEnum.UseBomb => new UseBombSoundEffect(soundEffect),
                SoundEnum.BombExplode => new BombExplodeSoundEffect(soundEffect),
                SoundEnum.Candle => new CandleSoundEffect(soundEffect),
                SoundEnum.EnemyDamaged => new EnemyDamagedSoundEffect(soundEffect),
                SoundEnum.EnemyDeath => new EnemyDeathSoundEffect(soundEffect),
                SoundEnum.LinkDamaged => new LinkDamagedSoundEffect(soundEffect),
                SoundEnum.LinkDeath => new LinkDeathSoundEffect(soundEffect),
                SoundEnum.LowHealth => new LowHealthSoundEffect(soundEffect),
                SoundEnum.NewItem => new NewItemSoundEffect(soundEffect),
                SoundEnum.GetItem => new GetItemSoundEffect(soundEffect),
                SoundEnum.GetHeart => new GetHeartSoundEffect(soundEffect),
                SoundEnum.GetKey => new GetKeySoundEffect(soundEffect),
                SoundEnum.GetRupee => new GetRupeeSoundEffect(soundEffect),
                SoundEnum.Aquamentus => new AquamentusSoundEffect(soundEffect),
                SoundEnum.Gleeok => new GleeokSoundEffect(soundEffect),
                SoundEnum.Owl => new OwlSoundEffect(soundEffect),
                SoundEnum.Ganon => new GanonSoundEffect(soundEffect),
                SoundEnum.Dodongo => new DodongoSoundEffect(soundEffect),
                SoundEnum.Gohma => new GohmaSoundEffect(soundEffect),
                SoundEnum.Manhandla => new ManhandlaSoundEffect(soundEffect),
                SoundEnum.Digdogger => new DigdoggerSoundEffect(soundEffect),
                SoundEnum.Patra => new PatraSoundEffect(soundEffect),
                SoundEnum.Note1 => new Note1SoundEffect(soundEffect),
                SoundEnum.Note2 => new Note2SoundEffect(soundEffect),
                SoundEnum.Note3 => new Note3SoundEffect(soundEffect),
                SoundEnum.Note4 => new Note4SoundEffect(soundEffect),
                SoundEnum.Note5 => new Note5SoundEffect(soundEffect),
                SoundEnum.Note6 => new Note6SoundEffect(soundEffect),
                _ => throw new ArgumentException("Invalid sound effect! " + soundEffectType.ToString() + " Sound factory failed."),
            });
Example #3
0
        SoundInstance PlaySoundInst(SoundEnum soundEnum)
        {
            var dict = new Dictionary <SoundEnum, ContentRef <Sound> > ()
            {
                { SoundEnum.Pickup, Sound_Pickup },
                { SoundEnum.PlayerDeath, Sound_PlayerDeath },
                { SoundEnum.Drill, Sound_Drill },
                { SoundEnum.ExitReached, Sound_ExitReached },
                { SoundEnum.Jump, Sound_Jump }
            };

            ContentRef <Sound> soundRef = dict[soundEnum];

            if (soundRef == null)
            {
                Log.Game.WriteError($"Sound {soundEnum.ToString ()} not found");
                return(null);
            }

            return(DualityApp.Sound.PlaySound(soundRef));
        }