Beispiel #1
0
        public void Simulate_GravityMovesEntityDown()
        {
            var entity   = _entityContainer.CreateEntity();
            var position = new PositionComponent();

            _entityContainer.AddComponent(entity, position);
            _entityContainer.AddComponent(entity, new PhysicsComponent());

            _target.Gravity = new Vector3(0, -100, 0);
            _target.Simulate(1, _entityContainer);

            Assert.AreEqual(-75, position.Position.Y);
        }
Beispiel #2
0
        public void Create(IEntityContainer container)
        {
            IEntity z1 = container.CreateEntity();

            z1.SetComponent(new MultiverseIdComponent(226747));

            z1.GetComponent <EffectStackComponent>().AddEffect(new DamageEffect(3));
        }
Beispiel #3
0
        public void PlaySounds_WhenActiveListener_SetsListenerProperties()
        {
            _mockListener.SetupSet(_ => _.Gain     = It.IsAny <float>());
            _mockListener.SetupSet(_ => _.Position = It.IsAny <Vector3>());
            _mockListener.SetupSet(_ => _.Velocity = It.IsAny <Vector3>());

            var listener = _entityContainer.CreateEntity();

            _entityContainer.AddComponent(listener, new ListenerComponent {
                Active = true
            });
            _entityContainer.AddComponent(listener, new PositionComponent {
                Position = new Vector3(3, 4, 5)
            });
            _entityContainer.AddComponent(listener, new PhysicsComponent {
                Velocity = new Vector3(1, 2, 3)
            });

            _target.PlaySounds(_entityContainer);

            _mockListener.VerifySet(_ => _.Gain     = 1);
            _mockListener.VerifySet(_ => _.Position = new Vector3(3, 4, 5));
            _mockListener.VerifySet(_ => _.Velocity = new Vector3(1, 2, 3));
        }
Beispiel #4
0
        public void DeleteEntity_DeletesTheEntityAndAllComponents()
        {
            var scriptComponent   = new Mock <IScriptComponent>();
            var positionComponent = new PositionComponent();

            var entity = _target.CreateEntity();

            _target.AddComponent(entity, scriptComponent.Object);
            _target.AddComponent(entity, positionComponent);
            _target.DeleteEntity(entity);

            Assert.IsFalse(_target.GetComponents <IScriptComponent>().Any());
            Assert.IsFalse(_target.GetComponents <PositionComponent>().Any());
            Assert.IsFalse(_target.GetEntitiesWithComponent <IScriptComponent>().Any());
            Assert.IsFalse(_target.GetEntitiesWithComponent <PositionComponent>().Any());
            Assert.IsFalse(_target.Entities.Any());
        }