public void StepTest7() { Scene scene = new Scene(); Actor actor = new Actor(scene, PolygonFactory.CreateRectangle(2, 2)); actor.SetTransform(new Transform2(new Vector2(1, 1))); actor.SetVelocity(Transform2.CreateVelocity(new Vector2(0, 3))); Entity entity = new Entity(scene); entity.SetParent(actor); FloatPortal enter = new FloatPortal(scene); enter.SetTransform(new Transform2(new Vector2(1, 2), 1, (float)Math.PI / 2)); //enter.SetVelocity(Transform2.CreateVelocity(new Vector2(1, 0))); FloatPortal exit = new FloatPortal(scene); exit.SetTransform(new Transform2(new Vector2(10, 10))); exit.SetVelocity(Transform2.CreateVelocity(new Vector2(10, 0))); enter.Linked = exit; exit.Linked = enter; PortalCommon.UpdateWorldTransform(scene); SimulationStep.Step(scene.GetAll().OfType<IPortalCommon>(), scene.GetAll().OfType<IPortal>(), 1, null); Assert.IsTrue(entity.GetTransform() == new Transform2()); Assert.IsTrue(entity.GetVelocity() == Transform2.CreateVelocity()); Assert.IsTrue(actor.GetTransform() == actor.WorldTransform); Assert.IsTrue(actor.GetVelocity() == actor.WorldVelocity); }
public void StepTest5() { Scene scene = new Scene(); Actor p = new Actor(scene, PolygonFactory.CreateRectangle(2, 2)); Transform2 start = new Transform2(new Vector2(0, 0)); Transform2 velocity = Transform2.CreateVelocity(new Vector2(3, 0)); p.SetTransform(start); p.SetVelocity(velocity); FloatPortal enter = new FloatPortal(scene); enter.SetTransform(new Transform2(new Vector2(1, 0))); enter.SetVelocity(Transform2.CreateVelocity(new Vector2(1, 0))); FloatPortal exit = new FloatPortal(scene); exit.SetTransform(new Transform2(new Vector2(10, 10))); exit.SetVelocity(Transform2.CreateVelocity(new Vector2(10, 0))); enter.Linked = exit; exit.Linked = enter; FixturePortal child = new FixturePortal(scene, p, new PolygonCoord(0, 0.5f)); PortalCommon.UpdateWorldTransform(new IPortalCommon[] { p, enter, exit, child }); SimulationStep.Step(scene.GetAll().OfType<IPortalCommon>(), scene.GetAll().OfType<IPortal>(), 1, null); Assert.IsTrue(p.GetTransform().Position == new Vector2(19, 10)); Assert.IsTrue(p.GetVelocity().Position == new Vector2(8, 0)); }