Exemplo n.º 1
0
        public void NoErrorIfThereAreNoVertices()
        {
            var entity = new Entity2D(Rectangle.One);

            entity.Add(new OutlineColor(Color.Red));
            Assert.DoesNotThrow(entity.OnDraw <DrawPolygon2DOutlines>);
        }
Exemplo n.º 2
0
        public void AddNewComponent()
        {
            var entity = new Entity2D(Rectangle.Zero);

            Assert.AreEqual(Rectangle.Zero, entity.DrawArea);
            Assert.AreEqual(Color.White, entity.Color);
            Assert.AreEqual(0, entity.NumberOfComponents);
            entity.Add(Size.Zero);
            Assert.AreEqual(1, entity.NumberOfComponents);
        }
Exemplo n.º 3
0
		public void ApplyUpdateWithVelocity()
		{
			var entity2D = new Entity2D(new Rectangle(0, 0, 1, 1));
			entity2D.Add(velocity);
			entity2D.Start<Velocity2D.PositionUpdate>();
			var originalPosition = entity2D.Center;
			entity2D.Get<Velocity2D.Data>().Accelerate(2.0f, 90.0f);
			AdvanceTimeAndUpdateEntities();
			Assert.AreNotEqual(originalPosition, entity2D.Center);
		}
Exemplo n.º 4
0
        public void ApplyUpdateWithVelocity()
        {
            var entity2D = new Entity2D(new Rectangle(0, 0, 1, 1));

            entity2D.Add(velocity);
            entity2D.Start <Velocity2D.PositionUpdate>();
            var originalPosition = entity2D.Center;

            entity2D.Get <Velocity2D.Data>().Accelerate(2.0f, 90.0f);
            AdvanceTimeAndUpdateEntities();
            Assert.AreNotEqual(originalPosition, entity2D.Center);
        }
 public static void AffixToPhysics(this Entity2D entity, PhysicsBody body)
 {
     entity.Add(body);
     entity.Start <AffixToPhysics2D>();
 }
Exemplo n.º 6
0
		private static void AddSimplePhysicsDataIfNeeded(Entity2D entity)
		{
			if (!entity.Contains<SimplePhysics.Data>())
				entity.Add(new SimplePhysics.Data());
		}
Exemplo n.º 7
0
        public void CannotAddTheSameTypeOfComponentTwice()
        {
            var entity = new Entity2D(Rectangle.Zero);

            Assert.Throws <Entity.ComponentOfTheSameTypeAddedMoreThanOnce>(() => entity.Add(Rectangle.One));
        }
Exemplo n.º 8
0
		public void NoErrorIfThereAreNoVertices()
		{
			var entity = new Entity2D(Rectangle.One);
			entity.Add(new OutlineColor(Color.Red));
			Assert.DoesNotThrow(entity.OnDraw<DrawPolygon2DOutlines>);
		}