public void TestAspectOneMultiple()
        {
            Aspect      aspect      = Aspect.One(typeof(TestPowerComponent), typeof(TestPowerComponentPoolable));
            EntityWorld entityWorld = new EntityWorld();
            Entity      entity;

            entity = entityWorld.CreateEntity();
            Assert.IsFalse(aspect.Interests(entity), "Entity without components must NOT be subject to \"Powered by any means\" Aspect");

            entity = entityWorld.CreateEntity();
            entity.AddComponent(new TestHealthComponent());
            Assert.IsFalse(aspect.Interests(entity), "Entity with {TestHealthComponent} must NOT be subject to \"Powered by any means\" Aspect");

            entity = entityWorld.CreateEntity();
            entity.AddComponent(new TestPowerComponent());
            Assert.IsTrue(aspect.Interests(entity), "Entity with {TestPowerComponent} must be subject to \"Powered by any means\" Aspect");

            entity = entityWorld.CreateEntity();
            entity.AddComponent(new TestPowerComponentPoolable());
            Assert.IsTrue(aspect.Interests(entity), "Entity with {TestPowerComponentPoolable} must be subject to \"Powered by any means\" Aspect");

            entity = entityWorld.CreateEntity();
            entity.AddComponent(new TestHealthComponent());
            entity.AddComponent(new TestPowerComponent());
            Assert.IsTrue(aspect.Interests(entity), "Entity with {TestHealthComponent, TestPowerComponent} must be subject to \"Powered by any means\" Aspect");

            entity = entityWorld.CreateEntity();
            entity.AddComponent(new TestHealthComponent());
            entity.AddComponent(new TestPowerComponent());
            entity.AddComponent(new TestPowerComponentPoolable());
            Assert.IsTrue(aspect.Interests(entity), "Entity with {TestHealthComponent, TestPowerComponent, TestPowerComponentPoolable} must be subject to \"Powered by any means\" Aspect");
        }
示例#2
0
        public void IsInterestedInJustOneComponent()
        {
            var oneAspect = Aspect
                            .One(typeof(DummyComponent))
                            .Build(_componentManager);

            Assert.True(oneAspect.IsInterested(_entityA));
            Assert.False(oneAspect.IsInterested(_entityB));
        }
示例#3
0
        public void IsInterestedInEitherOneOfTheComponents()
        {
            var eitherOneAspect = Aspect
                                  .One(typeof(Transform2), typeof(DummyComponent))
                                  .Build(_componentManager);

            Assert.True(eitherOneAspect.IsInterested(_entityA));
            Assert.True(eitherOneAspect.IsInterested(_entityB));
        }
示例#4
0
 public override void Enchant(Entity enchantment, EntityWorld entityWorld)
 {
     foreach (Entity e in entityWorld.EntityManager.GetEntities(Aspect.One(typeof(Damage))))
     {
         if (e.GetComponent <Team>().team == enchantment.GetComponent <Team>().team)
         {
             e.GetComponent <Damage>().currentDamage = e.GetComponent <Damage>().damage + 1;
         }
     }
 }
示例#5
0
        public ViewportRenderSystem(GraphicsDevice graphicsDevice)
            : base(Aspect.One(typeof(LoadedModelComponent), typeof(PrimitiveComponent)).All(typeof(TransformComponent)))
        {
            _graphicsDevice = graphicsDevice;

            _viewportRenderers = new []
            {
                new ViewportRenderer(512, 512)
            };
        }
示例#6
0
        public override void Cast(Entity caster, EntityWorld entityWorld)
        {
            LOGGER.Debug("FireLance");

            foreach (Entity entity in entityWorld.EntityManager.GetEntities(Aspect.One(typeof(Health))))
            {
                LOGGER.Debug(entity.Id);

                if (entity.GetComponent <Team>().team != caster.GetComponent <Team>().team)
                {
                    if (Math.Abs(entity.GetComponent <Position>().position.Y - caster.GetComponent <Position>().position.Y) < 64)
                    {
                        entity.GetComponent <Health>().currentHealth -= 2;
                    }
                }
            }

            base.Cast(caster, entityWorld);
        }
示例#7
0
        public override void Cast(Entity caster, EntityWorld entityWorld)
        {
            base.Cast(caster, entityWorld);

            foreach (Entity e in entityWorld.EntityManager.GetEntities(Aspect.One(typeof(Enchantment))))
            {
                if (e.GetComponent <Team>().team == caster.GetComponent <Team>().team)
                {
                    if (e.GetComponent <Enchantment>().enchantmentSlot != 1 ||
                        e.GetComponent <Enchantment>().enchantmentSlot != 3)
                    {
                        e.GetComponent <Enchantment>().enchantmentSlot++;
                    }
                    else
                    {
                        e.Delete();
                    }
                }
            }


            entity = entityWorld.CreateEntityFromTemplate(EnchantmentTemplate.Name);
            entity.GetComponent <Team>().team = caster.GetComponent <Team>().team;
            LOGGER.Debug(caster.GetComponent <Team>().team);
            if (entity.GetComponent <Team>().team == 1)
            {
                entity.GetComponent <Enchantment>().enchantmentSlot = 0;
            }
            else
            {
                entity.GetComponent <Enchantment>().enchantmentSlot = 2;
            }

            entity.GetComponent <Enchantment>().spellBookSlot = caster.GetComponent <SpellBook>().currentSpell;


            entity.GetComponent <Appearance>().Initialize("Images/FireCaster.xml");
        }
示例#8
0
        public override void Cast(Entity caster, EntityWorld entityWorld)
        {
            LOGGER.Debug("FireBall");
            Entity target;

            if (caster.Id == 1)
            {
                target = entityWorld.EntityManager.ActiveEntities[0];
            }
            else if (caster.Id == 0)
            {
                target = entityWorld.EntityManager.ActiveEntities[1];
            }
            else
            {
                throw new InvalidOperationException("The caster does not seem to be a player");
            }


            foreach (Entity entity in entityWorld.EntityManager.GetEntities(Aspect.One(typeof(Health))))
            {
                LOGGER.Debug(entity.Id);


                if (entity.GetComponent <Team>().team == target.GetComponent <Team>().team)
                {
                    if (Math.Abs(entity.GetComponent <Position>().position.X - caster.GetComponent <Position>().position.X) < Math.Abs(target.GetComponent <Position>().position.X - caster.GetComponent <Position>().position.X))
                    {
                        target = entity;
                    }
                }
            }
            target.GetComponent <Health>().currentHealth -= 1;

            base.Cast(caster, entityWorld);
        }
示例#9
0
 public PhysicsMouseObjectDetectSystem(Simulation simulation) : base(Aspect.One(typeof(ActivePhysicsComponent), typeof(StaticPhysicsComponent)))
 {
     _simulation = simulation;
 }
示例#10
0
 public ModelRenderSystem(GraphicsDevice graphicsDevice)
     : base(Aspect.One(typeof(LoadedModelComponent), typeof(PrimitiveComponent)).All(typeof(TransformComponent)))
 {
     _graphicsDevice = graphicsDevice;
 }
示例#11
0
 public AiSystem() : base(Aspect.One(typeof(AiComponent)))
 {
     _l = new Logger("AiSystem");
 }
示例#12
0
 public TurnSystem(Commander commander) : base(Aspect.One(typeof(TurnComponent)))
 {
     _commander = commander;
 }
示例#13
0
 public PlayerSystem() : base(Aspect.One(typeof(Player)))
 {
 }
示例#14
0
 public AISystem()
     : base(Aspect.One(typeof(AI), typeof(Input)))
 {
 }
示例#15
0
 public OverstepSystem()
     : base(Aspect.One(typeof(Input)))
 {
 }
示例#16
0
 // TODO: Maybe refactor all this mess?
 public RenderSystem(SpriteBatch spriteBatch) :
     base(Aspect.One(typeof(SpriteComponent), typeof(SpriteFontComponent)))
 {
     _spriteBatch = spriteBatch;
 }
示例#17
0
 public RenderSystem(Scene scene) : base(Aspect.One(typeof(Renderer)))
 {
     _scene = scene;
 }
示例#18
0
 public ActionSystem() : base(Aspect.One(typeof(ActionQueueComponent)))
 {
     _l = new Logger("ActionSystem");
 }
示例#19
0
 public TurnSystem() : base(Aspect.One(typeof(TurnComponent)))
 {
     _l = new Logger("TurnSystem");
 }
 // TODO: Maybe refactor all this mess?
 public RenderSystem(SpriteBatch spriteBatch, GameContent content) :
     base(Aspect.One(typeof(SpriteComponent), typeof(SpriteFontComponent)))
 {
     _spriteBatch = spriteBatch;
     _content     = content;
 }
示例#21
0
 public ABattleSystem() : base(Aspect.One(typeof(BattleComponent)))
 {
     _l = new Logger("BattleSystem");
 }
示例#22
0
 public LightingRenderSystem(GraphicsDevice graphicsDevice) : base(Aspect.One(typeof(DirectionalLightComponent), typeof(PointLightComponent)))
 {
     _graphicsDevice = graphicsDevice;
 }
示例#23
0
 public PickupSystem()
     : base(Aspect.One(typeof(Input), typeof(Pickupable)))
 {
 }
示例#24
0
 public AiSystem() : base(Aspect.One(typeof(AiComponent)))
 {
 }
示例#25
0
 public PlayerControlSystem() : base(Aspect.One(typeof(PlayerComponent)))
 {
 }
示例#26
0
 public LifeTimeReductionSystem() : base(Aspect.One(typeof(LifeTimeComponent)))
 {
 }
 /// <summary>Initializes a new instance of the <see cref="TestNormalEntityProcessingSystem2" /> class.</summary>
 public TestNormalEntityProcessingSystem2()
     : base(Aspect.One(typeof(TestPowerComponent), typeof(TestHealthComponent)))
 {
 }
示例#28
0
 public TextureRenderingSystem(SpriteBatch spriteBatch, OrthographicCamera camera) : base(Aspect.One(typeof(TextureComponent)))
 {
     _spriteBatch = spriteBatch;
     _camera      = camera;
 }