Пример #1
1
        private void TestAddRemoveListenerImpl(Game game)
        {
            var audio = game.Audio;
            var notAddedToEntityListener = new AudioListenerComponent();
            var addedToEntityListener = new AudioListenerComponent();

            // Add a listenerComponent not present in the entity system yet and check that it is correctly added to the AudioSystem internal data structures
            Assert.DoesNotThrow(() => audio.AddListener(notAddedToEntityListener), "Adding a listener not present in the entity system failed");
            Assert.IsTrue(audio.Listeners.ContainsKey(notAddedToEntityListener), "The list of listeners of AudioSystem does not contains the notAddedToEntityListener.");

            // Add a listenerComponent already present in the entity system and check that it is correctly added to the AudioSystem internal data structures
            var entity = new Entity("Test");
            entity.Add(addedToEntityListener);
            throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
            //game.Entities.Add(entity);
            Assert.DoesNotThrow(() => audio.AddListener(addedToEntityListener), "Adding a listener present in the entity system failed");
            Assert.IsTrue(audio.Listeners.ContainsKey(addedToEntityListener), "The list of listeners of AudioSystem does not contains the addedToEntityListener.");

            // Add a listenerComponent already added to audio System and check that it does not crash
            Assert.DoesNotThrow(()=>audio.AddListener(addedToEntityListener), "Adding a listener already added to the audio system failed.");

            // Remove the listeners from the AudioSystem and check that they are removed from internal data structures.
            Assert.DoesNotThrow(() => audio.RemoveListener(notAddedToEntityListener), "Removing an listener not present in the entity system failed.");
            Assert.IsFalse(audio.Listeners.ContainsKey(notAddedToEntityListener), "The list of listeners of AudioSystem still contains the notAddedToEntityListener.");
            Assert.DoesNotThrow(() => audio.RemoveListener(addedToEntityListener), "Removing an listener present in the entity system fails");
            Assert.IsFalse(audio.Listeners.ContainsKey(addedToEntityListener), "The list of listeners of AudioSystem still contains the addedToEntityListener.");

            // Remove a listener not present in the AudioSystem anymore and check the thrown exception
            Assert.Throws<ArgumentException>(() => audio.RemoveListener(addedToEntityListener), "Removing the a non-existing listener did not throw ArgumentException.");
        }
Пример #2
0
            public void OneLoopTurnActionAftUpdate(Game game)
            {
                oneLoopTurnActionAftUpdate?.Invoke(game, loopCount, loopCountSum);

                ++loopCount;
                loopCountSum += loopCount;
            }
Пример #3
0
 static void Main(string[] args)
 {
     using (var game = new Game())
     {
         game.Run();
     }
 }
Пример #4
0
 private static void CheckTextureFormat(Game game, string textureUrl, AlphaFormat expectedFormat)
 {
     var expectedPixelFormat = PlaformAndAlphaToPixelFormats[Tuple.Create(Platform.Type, expectedFormat)];
     var texture = game.Asset.Load<Texture>(textureUrl);
     Assert.AreEqual(expectedPixelFormat, texture.Format);
     game.Asset.Unload(texture);
 }
Пример #5
0
 private static void TestScriptAudioAccessImpl(Game game)
 {
     using (var script = new ScriptClass(game.Services))
     {
         Assert.DoesNotThrow(() => script.AccessAudioService(), "Access to the audio service failed.");
         Assert.IsTrue(script.AudioServiceNotNull(), "The Audio service is null.");
     }
 }
Пример #6
0
 private void TestInitializeAudioEngine(Game game)
 {
     var audio = game.Audio;
     AudioEngine audioEngine = null;
     Assert.DoesNotThrow(()=>audioEngine = audio.AudioEngine, "Failed to get the AudioEngine");
     Assert.IsNotNull(audioEngine, "The audio engine is null");
     Assert.IsFalse(audioEngine.IsDisposed, "The audio engine is disposed");
 }
 static void Main(string[] args)
 {
     // Profiler.EnableAll();
     using (var game = new Game())
     {
         game.Run();
     }
 }
        private void EntityPositionUpdate(Game game, int loopCount, int loopCountSum)
        {
            rootSubEntity1.Transform.Position += new Vector3(loopCount, 2 * loopCount, 3 * loopCount);
            rootSubEntity2.Transform.Position += new Vector3(loopCount, 2 * loopCount, 3 * loopCount);

            listComp1Entity.Transform.Position += new Vector3(loopCount, 2 * loopCount, 3 * loopCount);
            listComp2Entity.Transform.Position -= new Vector3(loopCount, 2 * loopCount, 3 * loopCount);
        }
Пример #9
0
            public void OneLoopTurnActionAftUpdate(Game game)
            {
                if (oneLoopTurnActionAftUpdate != null)
                    oneLoopTurnActionAftUpdate(game, loopCount, loopCountSum);

                ++loopCount;
                loopCountSum += loopCount;
            }
Пример #10
0
 private static void TestSoundMusicLoadingImpl(Game game)
 {
     SoundMusic sound = null;
     Assert.DoesNotThrow(() => sound = game.Content.Load<SoundMusic>("EffectBip"), "Failed to load the SoundMusic.");
     Assert.IsNotNull(sound, "The SoundMusic loaded is null.");
     sound.Play();
     // Should hear the sound here.
 }
Пример #11
0
 static void Main(string[] args)
 {
     // Profiler.EnableAll();
     using (game = new Game())
     {
         game.GraphicsDeviceManager.DeviceCreated += GraphicsDeviceManager_DeviceCreated;
         game.Run();
     }
 }
Пример #12
0
 public LiveAssemblyReloader(Game game, AssemblyContainer assemblyContainer, List<Assembly> assembliesToUnregister, List<Assembly> assembliesToRegister)
 {
     if (game != null)
         this.entities.AddRange(game.SceneSystem.SceneInstance);
     this.game = game;
     this.assemblyContainer = assemblyContainer;
     this.assembliesToUnregister = assembliesToUnregister;
     this.assembliesToRegister = assembliesToRegister;
 }
Пример #13
0
 private static void TestSoundMusicLoadingImpl(Game game)
 {
     Sound sound = null;
     Assert.DoesNotThrow(() => sound = game.Content.Load<Sound>("EffectBip"), "Failed to load the SoundMusic.");
     Assert.IsNotNull(sound, "The SoundMusic loaded is null.");
     testInstance = sound.CreateInstance(game.Audio.AudioEngine.DefaultListener);
     testInstance.Play();
     // Should hear the sound here.
 }
Пример #14
0
 public void TestAccessToAudio()
 {
     using (var game = new Game())
     {
         AudioSystem audioInterface = null;
         Assert.DoesNotThrow(()=>audioInterface = game.Audio, "Failed to get the audio interface");
         Assert.IsNotNull(audioInterface, "The audio interface supplied is null");
     }
 }
Пример #15
0
        public override void Start()
        {
            IsRunning = true;

            UIGame = (Game)Services.GetServiceAs<IGame>();

            AdjustVirtualResolution(this, EventArgs.Empty);
            Game.Window.ClientSizeChanged += AdjustVirtualResolution;

            CreateScene();
        }
        private void TestAddAudioSysThenEntitySysSetup(Game game)
        {
            var audio = game.Audio;

            BuildEntityHierarchy();
            CreateAndComponentToEntities();

            audio.AddListener(listComp1);
            audio.AddListener(listComp2);

            listComp2Entity.Transform.RotationEulerXYZ = new Vector3((float)Math.PI/2,0,0);
        }
        public void TestAttachDetachSounds()
        {
            var testInst = new AudioEmitterComponent();
            using (var game = new Game())
            {
                Game.InitializeAssetDatabase();
                using (var audioStream1 = AssetManager.FileProvider.OpenStream("EffectToneA", VirtualFileMode.Open, VirtualFileAccess.Read))
                using (var audioStream2 = AssetManager.FileProvider.OpenStream("EffectBip", VirtualFileMode.Open, VirtualFileAccess.Read))
                using (var audioStream3 = AssetManager.FileProvider.OpenStream("EffectStereo", VirtualFileMode.Open, VirtualFileAccess.Read))
                {
                    var sound1 = SoundEffect.Load(game.Audio.AudioEngine, audioStream1);
                    var sound2 = SoundEffect.Load(game.Audio.AudioEngine, audioStream2);
                    var sound3 = SoundEffect.Load(game.Audio.AudioEngine, audioStream3);

                    // Attach two soundEffect and check that their controller are correctly created.

                    AudioEmitterSoundController soundController1 = null;
                    AudioEmitterSoundController soundController2 = null;
                    Assert.DoesNotThrow(() => testInst.AttachSoundEffect(sound1), "Adding a first soundEffect failed");
                    Assert.DoesNotThrow(() => soundController1 = testInst.SoundEffectToController[sound1], "There are no sound controller for sound1.");
                    Assert.IsNotNull(soundController1, "Sound controller for sound1 is null");

                    Assert.DoesNotThrow(() => testInst.AttachSoundEffect(sound2), "Adding a second soundEffect failed");
                    Assert.DoesNotThrow(() => soundController2 = testInst.SoundEffectToController[sound2], "There are no sound controller for sound1.");
                    Assert.IsNotNull(soundController2, "Sound controller for sound2 is null");

                    // Remove the two soundEffect and check that their controller are correctly erased.

                    Assert.DoesNotThrow(() => testInst.DetachSoundEffect(sound2), "Removing a first soundEffect failed");
                    Assert.IsFalse(testInst.SoundEffectToController.ContainsKey(sound2), "The controller for sound2 is still present in the list.");

                    Assert.DoesNotThrow(() => testInst.DetachSoundEffect(sound1), "Removing a second soundEffect failed");
                    Assert.IsFalse(testInst.SoundEffectToController.ContainsKey(sound1), "The controller for sound1 is still present in the list.");

                    Assert.IsTrue(testInst.SoundEffectToController.Keys.Count == 0, "There are some controller left in the component list.");

                    // Check the exception thrwon by attachSoundEffect.

                    Assert.Throws<ArgumentNullException>(() => testInst.AttachSoundEffect(null), "AttachSoundEffect did not throw ArgumentNullException");
                    Assert.Throws<InvalidOperationException>(() => testInst.AttachSoundEffect(sound3), "AttachSoundEffect did not throw InvalidOperationException.");

                    // Check the exception thrown by detachSoundEffect.

                    Assert.Throws<ArgumentNullException>(() => testInst.DetachSoundEffect(null), "DetachSoundEffect did not throw ArgumentNullException.");
                    Assert.Throws<ArgumentException>(() => testInst.DetachSoundEffect(sound1), "DetachSoundEffect did not throw ArgumentException ");
                }
            }
        }
Пример #18
0
        private void AddSoundEffectToEmitterComponents(Game game)
        {
            sounds = new List<SoundEffect>
                {
                    game.Content.Load<SoundEffect>("EffectBip"),
                    game.Content.Load<SoundEffect>("EffectToneA"),
                };

            emitComps[0].AttachSoundEffect(sounds[0]);
            emitComps[0].AttachSoundEffect(sounds[1]);

            soundControllers = new List<AudioEmitterSoundController>
                {
                    emitComps[0].GetSoundEffectController(sounds[0]),
                    emitComps[0].GetSoundEffectController(sounds[1]),
                };

            mainController = soundControllers[0];
        }
 /// <summary>
 /// Add all the <see cref="AudioListenerComponent"/> to the <see cref="AudioSystem"/>.
 /// </summary>
 /// <param name="game"></param>
 private void AddListenersToAudioSystem(Game game)
 {
     foreach (var t in listComps)
         game.Audio.AddListener(t);
 }
 /// <summary>
 /// Add the root entity to the entity system
 /// </summary>
 /// <param name="game"></param>
 private void AddRootEntityToEntitySystem(Game game)
 {
     throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); // game.Entities.Add(rootEntity);
 }
        private void TestMulteListenerUpdate(Game game, int loopCount, int loopCountSum)
        {
            throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
            //var matchingEntities = game.Entities.Processors.OfType<AudioEmitterProcessor>().First().MatchingEntitiesForDebug;

            //var dataComp1 = matchingEntities[compEntities[0]];

            //if (loopCount == 0)
            //{
            //    soundControllers[0].Play();
            //}
            //else if (loopCount < 10)
            //{
            //    // check that the two instances are correctly create and playing
            //    var tupple1 = Tuple.Create(listComps[0], soundControllers[0]);
            //    var tupple2 = Tuple.Create(listComps[1], soundControllers[0]);
                
            //    Assert.IsTrue(dataComp1.ListenerControllerToSoundInstance.ContainsKey(tupple1));
            //    Assert.IsTrue(dataComp1.ListenerControllerToSoundInstance.ContainsKey(tupple2));

            //    var instance1 = dataComp1.ListenerControllerToSoundInstance[tupple1];
            //    var instance2 = dataComp1.ListenerControllerToSoundInstance[tupple2];

            //    Assert.AreEqual(SoundPlayState.Playing, instance1.PlayState);
            //    Assert.AreEqual(SoundPlayState.Playing, instance2.PlayState);
            //}
            //else
            //{
            //    game.Exit();
            //}
        }
//        /// <summary>
//        /// Check that the values of the <see cref="AudioEmitter"/> associated to the <see cref="AudioEmitterComponent"/> are or are not updated as they should be.
//        /// </summary>
//        /// <param name="emitter1ShouldBeValid">boolean indicating if emitter component 1 is supposed to be updated.</param>
//        /// <param name="emitter2ShouldBeValid">boolean indicating if emitter component 2 is supposed to be updated.</param>
//        /// <param name="matchingEntities">the matching entities of the <see cref="AudioEmitterProcessor"/></param>
//        /// <param name="loopCount">the current loopCount of the game</param>
//        private void CheckEmittersValues(bool emitter1ShouldBeValid, bool emitter2ShouldBeValid, Dictionary<Entity, AudioEmitterProcessor.AssociatedData> matchingEntities, int loopCount)
//        {
//            var dataComp1 = matchingEntities[compEntities[0]];
//            var dataComp2 = matchingEntities[compEntities[1]];
//
//            // check that the boolean value of the AudioEmitterComponent indicating the processor if the AudioEmitter should be updated is valid.
//            Assert.IsTrue(dataComp1.AudioEmitterComponent.ShouldBeProcessed == emitter1ShouldBeValid, "value of ShouldBeProcessed for emitter 1 is not correct at loop turn" + loopCount);
//            Assert.IsTrue(dataComp2.AudioEmitterComponent.ShouldBeProcessed == emitter2ShouldBeValid, "value of ShouldBeProcessed for emitter 2 is not correct at loop turn" + loopCount);
//
//            var emitter1Velocity = 2 * new Vector3(loopCount, 2 * loopCount, 3 * loopCount) + Vector3.One;
//            if (emitter1ShouldBeValid)
//            {
//                // check the AudioEmitter 1 values are updated.
//                Assert.AreEqual(emitter1Velocity, dataComp1.AudioEmitter.Velocity, "The velocity of emitter 1 is not valid at loop turn" + loopCount);
//                Assert.AreEqual(loopCount, dataComp1.AudioEmitter.DistanceScale, "The distance scale of emitter 1 is not valid at loop turn" + loopCount);
//                Assert.AreEqual(2 * loopCount, dataComp1.AudioEmitter.DopplerScale, "The Doppler scale of emitter 1 is not valid at loop turn" + loopCount);
//            }
//            else
//            {
//                // check the AudioEmitter 1 values are not updated anymore
//                Assert.AreNotEqual(emitter1Velocity, dataComp1.AudioEmitter.Velocity, "The velocity of emitter 1 is calculated for nothing at loop turn" + loopCount);
//                Assert.AreNotEqual(loopCount, dataComp1.AudioEmitter.DistanceScale, "The distance scale of emitter 1 is calculated for nothing at loop turn" + loopCount);
//                Assert.AreNotEqual(2 * loopCount, dataComp1.AudioEmitter.DopplerScale, "The Doppler scale of emitter 1 is calculated for nothing loop turn" + loopCount);
//            }
//
//            var emitter2Velocity = new Vector3(loopCount, 2 * loopCount, 3 * loopCount);
//            if (emitter2ShouldBeValid)
//            {
//                // check the AudioEmitter 2 values are updated.
//                Assert.AreEqual(emitter2Velocity, dataComp2.AudioEmitter.Velocity, "The velocity of emitter 2 is not valid at loop turn" + loopCount);
//                Assert.AreEqual(3 * loopCount, dataComp2.AudioEmitter.DistanceScale, "The distance scale of emitter 2 is not valid at loop turn" + loopCount);
//                Assert.AreEqual(4 * loopCount, dataComp2.AudioEmitter.DopplerScale, "The Doppler scale of emitter 2 is not valid at loop turn" + loopCount);
//            }
//            else
//            {
//                // check the AudioEmitter 2 values are not updated anymore
//                Assert.AreNotEqual(emitter2Velocity, dataComp2.AudioEmitter.Velocity, "The velocity of emitter 2 is calculated for nothing at loop turn" + loopCount);
//                Assert.AreNotEqual(3 * loopCount, dataComp2.AudioEmitter.DistanceScale, "The distance scale of emitter 2 is calculated for nothing at loop turn" + loopCount);
//                Assert.AreNotEqual(4 * loopCount, dataComp2.AudioEmitter.DopplerScale, "The Doppler scale of emitter 2 is calculated for nothing loop turn" + loopCount);
//            }
//        }

//        private bool soundController0WentToStopState;
//        private bool soundController2WentToStopState;

        private void TestEmitterUpdateValuesAtfUpdate(Game game, int loopCount, int loopCountSum)
        {
            //throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
            //var matchingEntities = game.Entities.Processors.OfType<AudioEmitterProcessor>().First().MatchingEntitiesForDebug;
            
            //var dataComp1 = matchingEntities[compEntities[0]];
            //var dataComp2 = matchingEntities[compEntities[1]];

            //// check that AudioEmitters position is always valid. (this is required to ensure that the velocity is valid from the first update).
            //Assert.AreEqual(2 * new Vector3(loopCountSum, 2 * loopCountSum, 3 * loopCountSum) + (loopCount + 1) * Vector3.One, dataComp1.AudioEmitter.Position, "Position of the emitter 1 is not correct");
            //Assert.AreEqual(new Vector3(loopCountSum, 2 * loopCountSum, 3 * loopCountSum), dataComp2.AudioEmitter.Position, "Position of the emitter 2 is not correct");

            //if (loopCount == 0)
            //{
            //    soundController0WentToStopState = false;
            //    soundController2WentToStopState = false;

            //    // check that initially AudioEmitter should not be updated.
            //    foreach (var data in matchingEntities.Values)
            //        Assert.IsFalse(data.AudioEmitterComponent.ShouldBeProcessed, "Initial value of ShouldBeProcessed is not correct at loop turn"+loopCount);

            //    soundControllers[0].Play();
            //}
            //else if (loopCount == 1)
            //{
            //    // check that emitter 1 is updated but not emitter 2
            //    CheckEmittersValues(true, false, matchingEntities, loopCount);

            //    soundControllers[2].Play();
            //}
            //else if(soundControllers[0].PlayState == SoundPlayState.Playing)
            //{
            //    // check that both emitters are updated.
            //    CheckEmittersValues(true, true, matchingEntities, loopCount);
            //}
            //else if (!soundController0WentToStopState)
            //{
            //    // transition state of controller 1 from play to stop 
            //    // since PlayState is updated asynchronously via callbacks, 
            //    // PlayState may have changed between the Update and this function calls
            //    // that is why we wait for next loop turn to perform the new test.
            //    soundController0WentToStopState = true;
            //}
            //else if (soundControllers[2].PlayState == SoundPlayState.Playing)
            //{
            //    // check that emitter 2 is still updated but not emitter1 anymore.
            //    CheckEmittersValues(false, true, matchingEntities, loopCount);
            //}
            //else if (!soundController2WentToStopState)
            //{
            //    // transition state of controller 2 from play to stop 
            //    // since PlayState is updated asynchronously via callbacks, 
            //    // PlayState may have changed between the Update and this function calls
            //    // that is why we wait for next loop turn to perform the new test.
            //    soundController2WentToStopState = true;
            //}
            //else
            //{
            //    // check that both emitter are not updated anymore.
            //    CheckEmittersValues(false, false, matchingEntities, loopCount);
            //    game.Exit();
            //}
        }
        /// <summary>
        /// Update the entities position and <see cref="AudioEmitterComponent"/> parameters at each loop turn.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="loopCount"></param>
        /// <param name="loopCountSum"></param>
        private void EntityPositionAndEmitterbfrUpdate(Game game, int loopCount, int loopCountSum)
        {
            rootSubEntity1.Transform.Position += new Vector3(loopCount, 2 * loopCount, 3 * loopCount);
            rootSubEntity2.Transform.Position += 2*new Vector3(loopCount, 2 * loopCount, 3 * loopCount);

            compEntities[0].Transform.Position += new Vector3(loopCount+1, 2 * loopCount+1, 3 * loopCount+1);
            compEntities[1].Transform.Position -= new Vector3(loopCount, 2 * loopCount, 3 * loopCount);

//            emitComps[0].DistanceScale = loopCount;
//            emitComps[0].DopplerScale = 2 * loopCount;
//            emitComps[1].DistanceScale = 3 * loopCount;
//            emitComps[1].DopplerScale = 4 * loopCount;
        }
 /// <summary>
 /// Setup configuration for the test.
 /// </summary>
 /// <param name="game"></param>
 private void TestEmitterUpdateValuesSetup(Game game)
 {
     BuildEntityHierarchy();
     CreateAndAddListenerComponentToEntities();
     CreateAndAddEmitterComponentToEntities();
     AddRootEntityToEntitySystem(game);
     AddSoundEffectToEmitterComponents(game);
     AddListenersToAudioSystem(game);
 }
        private void TestAddRemoveSoundEffect(Game game)
        {
            BuildEntityHierarchy();
            CreateAndAddListenerComponentToEntities();
            CreateAndAddEmitterComponentToEntities();
            AddRootEntityToEntitySystem(game);
            AddListenersToAudioSystem(game);

            throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
            //var matchingEntities = game.Entities.Processors.OfType<AudioEmitterProcessor>().First().MatchingEntitiesForDebug;

            //CheckSoundEffectExistance(matchingEntities);

            //var sound1 = game.Content.Load<SoundEffect>("EffectToneA");
            //var sound2 = game.Content.Load<SoundEffect>("EffectFishLamp");
            //var sound3 = game.Content.Load<SoundEffect>("EffectBip");

            //// attach new Soundeffects and check the SoundEffectInstance creation.
            //emitComps[0].AttachSoundEffect(sound1);
            //CheckSoundEffectExistance(matchingEntities);

            //emitComps[1].AttachSoundEffect(sound2);
            //CheckSoundEffectExistance(matchingEntities);

            //emitComps[0].AttachSoundEffect(sound3);
            //CheckSoundEffectExistance(matchingEntities);
            
            //// detach SoundEffect and check that the controllers have been deleted.
            //emitComps[0].DetachSoundEffect(sound1);
            //CheckSoundEffectExistance(matchingEntities);

            //emitComps[1].DetachSoundEffect(sound2);
            //CheckSoundEffectExistance(matchingEntities);

            //emitComps[0].DetachSoundEffect(sound3);
            //CheckSoundEffectExistance(matchingEntities);
        }
        private void TestAddRemoveEntityWithEmitter(Game game)
        {
            BuildEntityHierarchy();
            CreateAndAddListenerComponentToEntities();
            CreateAndAddEmitterComponentToEntities();
            AddSoundEffectToEmitterComponents(game);
            AddListenersToAudioSystem(game);
            AddRootEntityToEntitySystem(game);

            emitComps.Add(new AudioEmitterComponent());
            emitComps[2].AttachSound(game.Content.Load<Sound>("EffectToneA"));
            var extraEntity = new Entity();
            extraEntity.Add(emitComps[2]);

            throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer");
            //var matchingEntities = game.Entities.Processors.OfType<AudioEmitterProcessor>().First().MatchingEntitiesForDebug;

            //// check that initially there is no problems.
            //CheckSoundEffectExistance(matchingEntities);

            //// and an entity and check that the soundEffectInstances have been created.
            //compEntities.Add(extraEntity);
            //game.Entities.Add(extraEntity);
            //CheckSoundEffectExistance(matchingEntities);

            //// remove the entity and check that it is removed from the matchingComp list.
            //compEntities.Remove(extraEntity);
            //game.Entities.Remove(extraEntity);
            //CheckSoundEffectExistance(matchingEntities);
        }
        private void TestAddRemoveListeners(Game game)
        {
            BuildEntityHierarchy();
            CreateAndAddListenerComponentToEntities();
            CreateAndAddEmitterComponentToEntities();
            AddSoundEffectToEmitterComponents(game);
            AddRootEntityToEntitySystem(game);

            throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer"); 
            //var matchingEntities = game.Entities.Processors.OfType<AudioEmitterProcessor>().First().MatchingEntitiesForDebug;

            //// check that there are initially not SoundEffectInstance created.
            //CheckSoundEffectExistance(new HashSet<AudioListenerComponent> (), matchingEntities);

            //// add one listener
            //game.Audio.AddListener(listComps[0]);

            //// check that there is now one SoundEffectInstance for each SoundController
            //CheckSoundEffectExistance(new HashSet<AudioListenerComponent> { listComps[0] }, matchingEntities);

            //// add another listener
            //game.Audio.AddListener(listComps[1]);

            //// check that there is now two SoundEffectInstance for each SoundController
            //CheckSoundEffectExistance(new HashSet<AudioListenerComponent> (listComps), matchingEntities);

            //// remove one listener
            //game.Audio.RemoveListener(listComps[1]);

            //// check that there is now only one SoundEffectInstance for each SoundController left
            //CheckSoundEffectExistance(new HashSet<AudioListenerComponent> { listComps[0] }, matchingEntities);

            //// remove the other listener
            //game.Audio.RemoveListener(listComps[0]);

            //// check that there is no SoundEffectInstance left
            //CheckSoundEffectExistance(new HashSet<AudioListenerComponent>(), matchingEntities);
        }
Пример #28
0
        private void TestLocalizationCoherencyLoopImpl(Game game, int loopCount, int loopCountSum)
        {
            // useless motion on the root entities just to check that is does not disturb to calculations.
            rootSubEntity1.Transform.Position += new Vector3(1, 2, 3);
            listCompEntities[0].Transform.Position += new Vector3(3, 2, -1);
            // have the emitter turn clockwise around the listener.
            emitCompEntities[0].Transform.Position = new Vector3((float)Math.Cos(loopCount * Math.PI / 100), 0, (float)Math.Sin(loopCount * Math.PI / 100));

            // the sound should turn around clockwise 
            if (loopCount == 800)
            {
                game.Exit();
            }
        }
Пример #29
0
        private void TestLocalizationCoherencySetup(Game game)
        {
            BuildEntityHierarchy();
            CreateAndAddListenerComponentToEntities();
            CreateAndAddEmitterComponentToEntities();
            AddSoundEffectToEmitterComponents(game);
            AddRootEntityToEntitySystem(game);

            game.Audio.AddListener(listComps[0]);

            soundControllers[0].IsLooped = true;
            soundControllers[0].Play();
        }
Пример #30
0
        private void TestAttenuationCoherencyLoopImpl(Game game, int loopCount, int loopCountSum)
        {
            // put away progressively the emitter.
            emitCompEntities[0].Transform.Position = new Vector3(0, 0, loopCount / 10f);

            // the sound should progressively attenuate
            if (loopCount == 800)
            {
                game.Exit();
            }
        }