public static ChainElement CreateFor(PayloadChain payloadChain, int index, DynamicEntityWorld world, Body body) { var el = new ChainElement(payloadChain.Name + "_" + index); el._payloadChain = payloadChain; el._index = index; el.World = world; el.Body = body; return(el); }
public void LoadContent() { _spriteBatch = new SpriteBatch(_graphics); _world = new DynamicEntityWorld(_game.Services); var pp = _graphics.PresentationParameters; _debugView = new DebugViewXNA(_world.PhysicsWorld); _debugView.LoadContent(_graphics, _content); _camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight)); _cameraNode = _world.Scene.Root.CreateChild("Camera"); _cameraNode.Attach(_camera); // Create the tile map. var terrainSize = new Vector2(4096.0f, 2048.0f); _terrain = new Terrain(terrainSize, 128.0f, 7) { DebugEnabled = false, Position = new Vector3(50.0f, -terrainSize.Y / 2.0f, 0.0f), TextureName = @"Textures\SpaceRock" }; _world.Add(_terrain); GenerateTunnels(new Vector2(50.0f, 0)); // Create the circle brush. _circleBrush = new CircleBrush(2.5f); _circleBrushNode = _world.Scene.CreateSceneNode(); _circleBrushNode.Attach(new CircleRenderable(2.5f, 64) { Color = Vector3.One }); // Dust cloud _dustCloud = _world.Scene.CreateSceneNode("DustCloud"); _dustCloud.Position = new Vector3(0.0f, 0.0f, -1.0f); _dustCloud.Attach(new DustCloud()); _world.Scene.Root.AddChild(_dustCloud); // Player _playerEntity = new SpaceShip(); _playerEntity.Attach(new PlayerController()); _playerEntity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(90.0f)); _world.Add(_playerEntity); _payloadEntity = new Payload(); _payloadEntity.Orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(90.0f)); _world.Add(_payloadEntity); _payloadChain = PayloadChain.Connect(_playerEntity, _payloadEntity, Vector2.UnitX * -20.0f); }
public void LoadContent() { m_debug.LoadContent(); var pp = m_graphics.PresentationParameters; // Create our entity world. m_world = new DynamicEntityWorld(m_game.Services); // Create the debug view. m_debugView = new DebugViewXNA(m_world.PhysicsWorld); m_debugView.LoadContent(m_graphics, m_content); // Create the camera. m_camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight)); m_cameraNode = m_world.Scene.Root.CreateChild("Camera"); m_cameraNode.Attach(m_camera); // Create the player. m_player = new Entities.Player( new StaticSprite(Vector2.One * 10.0f, m_content.Load<Texture2D>(@"Sprites\Ship01"), "Player")); m_player.Attach(new Controllers.PlayerMovement(m_camera)); m_world.Add(m_player); m_player.Position = new Vector2(0.0f, 0.0f); // Create the layers. m_playerLayer = new DefaultLayer(typeof(ISprite), "Player", 0.5f) { Scene = m_world.Scene }; m_backgroundLayer = new DefaultLayer(0.0f) { Scene = m_world.Scene }; // Create the background. var deepSpaceSprite = new StaticSprite(Vector2.One * 200.0f, m_content.Load<Texture2D>(@"Textures\Background01"), null) { BlendState = BlendState.Additive }; var lessDeepSpaceSprite = new StaticSprite(Vector2.One * 400.0f, m_content.Load<Texture2D>(@"Textures\Background02"), null) { BlendState = BlendState.Additive }; m_deepSpaceNode = m_cameraNode.CreateChild("Background_DeepSpace"); m_deepSpaceNode.Depth = -1.0f; // Move the background into the back. m_deepSpaceNode.Attach(deepSpaceSprite); m_lessDeepSpaceNode = m_cameraNode.CreateChild("Background_LessDeepSpace"); m_lessDeepSpaceNode.Depth = -0.9f; // Move the background into the back, but in front of the other background. m_lessDeepSpaceNode.Attach(lessDeepSpaceSprite); m_backgroundLayer.AddRenderable(deepSpaceSprite); m_backgroundLayer.AddRenderable(lessDeepSpaceSprite); // Create the dust cloud. var dustCloud = new Movables.DustCloud(100); m_dustCloudNode = m_world.Scene.Root.CreateChild("DustCloud"); m_dustCloudNode.Depth = -0.8f; m_dustCloudNode.Attach(dustCloud); m_backgroundLayer.AddRenderable(dustCloud); // Create the planet. m_terrainLayer = new DefaultLayer(typeof(Entities.TerrainRegion), null, 0.0f) { Scene = m_world.Scene }; m_miscLayer = new DefaultLayer(typeof(ISprite), "MISC_", -0.5f) { Scene = m_world.Scene }; CreatePlanet(); }