Ejemplo n.º 1
0
        public void SoundBufferLifecycleMethods_CreateAndDeleteObjects()
        {
            var buffer = new Mock <ISoundBuffer>(MockBehavior.Strict);

            buffer.Setup(_ => _.Dispose());
            _mockFactory.Setup(_ => _.Create <ISoundBuffer>()).Returns(buffer.Object);

            _target.CreateSoundBuffer();
            var result = _target.CreateSoundBuffer();

            _target.DeleteSoundBuffer(result);

            buffer.Verify(_ => _.Dispose(), Times.Once);
        }
Ejemplo n.º 2
0
        public void Attach()
        {
            _scene.Init();
            _physicsContainer.Gravity = new Vector3(0, -800, 0);

            var entity = _scene.CreateEntity();

            _scene.AddComponent(entity, new CameraComponent {
                Camera = _camera, Active = true
            });

            var texture = _factory.Create <ITexture2D>();

            texture.SetData("Assets/landscape.jpeg");

            var soundBuffer = _soundManager.CreateSoundBuffer();

            soundBuffer.SetData("Assets/jump.wav");

            var source = _soundManager.CreateSource();

            source.Gain = 1f;

            entity = _scene.CreateEntity();
            _scene.AddComponent(entity, new PositionComponent {
                Position = new Vector3(-400, -100, 0)
            });
            _scene.AddComponent(entity, new SizeComponent {
                Width = 100, Height = 100
            });
            _scene.AddComponent(entity, new TextureComponent {
                Texture = texture
            });
            var physicsComponent = new PhysicsComponent();

            _scene.AddComponent(entity, physicsComponent);
            var sourceComponent = new SourceComponent {
                Source = source, SoundBuffer = soundBuffer
            };

            _scene.AddComponent(entity, sourceComponent);
            _scene.AddComponent(entity, new ControlScript(physicsComponent, sourceComponent));

            entity = _scene.CreateEntity();
            _scene.AddComponent(entity, new PositionComponent {
                Position = new Vector3(0, -360, 0)
            });
            _scene.AddComponent(entity, new SizeComponent {
                Width = 1280, Height = 10
            });
            _scene.AddComponent(entity, new PhysicsComponent {
                Fixed = true
            });

            entity = _scene.CreateEntity();
            _scene.AddComponent(entity, new PositionComponent {
                Position = new Vector3(0, -200, 0)
            });
            _scene.AddComponent(entity, new SizeComponent {
                Width = 600, Height = 10
            });
            _scene.AddComponent(entity, new PhysicsComponent {
                Fixed = true
            });

            entity = _scene.CreateEntity();
            _scene.AddComponent(entity, new PositionComponent {
                Position = new Vector3(420, -95, 0), Rotation = new Vector3(0, 0, 45)
            });
            _scene.AddComponent(entity, new SizeComponent {
                Width = 300, Height = 10
            });
            _scene.AddComponent(entity, new PhysicsComponent {
                Fixed = true
            });

            entity = _scene.CreateEntity();
            _scene.AddComponent(entity, new PositionComponent {
                Position = new Vector3(0, -100, 0)
            });
            _scene.AddComponent(entity, new SizeComponent {
                Width = 10, Height = 300
            });
            _scene.AddComponent(entity, new PhysicsComponent {
                Fixed = true
            });

            _physicsContainer.Start(144, _scene.EntityContainer);
            _soundManager.Start(60, _scene.EntityContainer);
        }