private Level setupRendering() { var level = createLevel(); var cam = TW.Data.Get <CameraInfo>(); cam.Mode = CameraInfo.CameraMode.ThirdPerson; var camEntity = new Entity(); cam.ThirdPersonCameraTarget = camEntity; var phys = new ClusterPhysicsService(level); var controller = new ClusterFlightController(TW.Graphics.Keyboard); engine.AddSimulator(new BasicSimulator(() => { controller.SimulateFlightStep(cameraIsland, cameraIsland.GetForward(), cameraIsland.Position); camEntity.WorldMatrix = Matrix.Translation( cameraIsland.GetIslandsInCluster().Aggregate(new Vector3(), (acc, el) => acc + el.Position) / cameraIsland.GetIslandsInCluster().Count()); phys.UpdateClusterMovement(); })); engine.AddSimulator(new ThirdPersonCameraSimulator()); //engine.AddSimulator(new LoadLevelSimulator(level)); engine.AddSimulator(new WorldRenderingSimulator()); return(level); }
private void simulateFlying() { if (TW.Graphics.Keyboard.IsKeyDown(Key.Escape)) { player.StopFlight(); return; } if (player.FlyingEngine.HasFuel) { var flightController = new ClusterFlightController(TW.Graphics.Keyboard); flightController.SimulateFlightStep(player.FlyingIsland, player.FlyingEngine.Node.Absolute.xna().Forward.dx(), player.FlyingEngine.Node.Position); } }
public void TestAutoConnector() { var level = createLevel(); var isl = level.CreateNewIsland(new Vector3(5, 3, 5)); cameraIsland = isl; var isl2 = level.CreateNewIsland(new Vector3(15, 3, 5)); var a = addBridge(isl, Vector3.UnitX, new Vector3(3, 0, 0)); var c = addBridge(isl, Vector3.UnitZ, new Vector3(0, 0, 3)); var b = addBridge(isl2, -Vector3.UnitX, new Vector3(-3, 0, 0)); var flight = new ClusterFlightController(TW.Graphics.Keyboard); Assert.False(flight.CanAutoDock(a, b)); Assert.False(flight.CanAutoDock(a, c)); Assert.False(flight.CanAutoDock(c, b)); isl.Position = new Vector3(9, 3, 5); Assert.True(flight.CanAutoDock(a, b)); Assert.False(flight.CanAutoDock(a, c)); Assert.False(flight.CanAutoDock(c, b)); isl.Node.Relative *= Matrix.RotationY(MathHelper.PiOver2); Assert.False(flight.CanAutoDock(a, b)); Assert.False(flight.CanAutoDock(a, c)); Assert.True(flight.CanAutoDock(c, b)); isl.Position = new Vector3(12, 3, 8); Assert.False(flight.CanAutoDock(a, b)); Assert.False(flight.CanAutoDock(a, c)); Assert.False(flight.CanAutoDock(c, b)); }