Exemplo n.º 1
0
        public void CreateGrenadeTest()
        {
            var x        = 10;
            var y        = 10;
            var location = new PointF(x, y);
            var model    = new RoyalGameModel();
            var obj      = BuilderGameObject.CreateGrenade(model, location, new Box2DX.Common.Vec2(x, y), new GrenadeBullet());

            var body      = obj.Components.GetComponent <SolidBody>();
            var explosion = obj.Components.GetComponent <Explosion>();

            Assert.IsNotNull(body);
            Assert.IsNotNull(explosion);

            Assert.AreEqual(location, body.Shape.Location);
            Assert.AreEqual(obj, model.gameObjects[obj.ID]);
            Assert.AreEqual(TypesGameObject.Grenade, obj.Type);
            Assert.AreEqual(TypesBehaveObjects.Active, obj.TypeBehave);

            for (int i = 0; i < 10; i++)
            {
                model.MakeStep(i);
            }
            Assert.IsTrue((body.Shape.Location.X - x) > 0);
            Assert.IsTrue((body.Shape.Location.Y - y) > 0);
        }