示例#1
0
        public void NoErrorIfThereAreNoVertices()
        {
            var entity = new Entity2D(Rectangle.One);

            entity.Add(new OutlineColor(Color.Red));
            Assert.DoesNotThrow(entity.OnDraw <DrawPolygon2DOutlines>);
        }
示例#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);
        }
示例#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);
		}
        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>();
 }
示例#6
0
		private static void AddSimplePhysicsDataIfNeeded(Entity2D entity)
		{
			if (!entity.Contains<SimplePhysics.Data>())
				entity.Add(new SimplePhysics.Data());
		}
示例#7
0
        public void CannotAddTheSameTypeOfComponentTwice()
        {
            var entity = new Entity2D(Rectangle.Zero);

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