public GameEnvironment(Controller ctrl) : base(ctrl) { Pressure = 0.0f; Sound.StopAll(true); // Camera. Camera = new Camera2D(this); //Camera.Position = new Vector2(1280.0f, k_idealScreenSize.Y * 0.5f); Camera.MoveSpeed = defaultCameraMoveSpeed; Camera.ResetEffectScale(1.0f); // Set at slightly higher than 1.0 so we can do a zoom out pressure effect. // Window. Controller.Window.ClientSizeChanged += WindowSizeChanged; WindowSizeChanged(null, null); Controller.IsMouseVisible = true; // Collision. CollisionWorld = new Physics.Dynamics.World(Vector2.Zero); // Create a new SpriteBatch which can be used to draw textures. m_spriteBatch = new SpriteBatch(ctrl.GraphicsDevice); ParticleRenderer = new SpriteBatchRenderer { GraphicsDeviceService = ctrl.Graphics }; ParticleRenderer.LoadContent(contentManager); // Create collision notification callbacks. CollisionWorld.ContactManager.PreSolve += PreSolve; CollisionWorld.ContactManager.BeginContact += BeginContact; CollisionWorld.ContactManager.EndContact += EndContact; CollisionWorld.ContactManager.ContactFilter += ContactFilter; // HUD. HUD = new Menus.HUD(this); // Effects. m_tintEffect = contentManager.Load <Effect>("TintEffect"); FadeOut = new FaderOuter(this); SpawnController = new SpawnController(this); // Farseer freaks out unless we call Update here when changing Environments. FIXME: Why? Update(0.0f); }
public GameEnvironment(Controller ctrl) : base(ctrl) { Sound.StopAll(true); CollisionWorld = new Physics.Dynamics.World(Vector2.Zero); Controller.Window.ClientSizeChanged += WindowSizeChanged; Camera = new Camera2D(this); WindowSizeChanged(null, null); // Create a new SpriteBatch which can be used to draw textures. m_spriteBatch = new SpriteBatch(ctrl.GraphicsDevice); ParticleRenderer = new SpriteBatchRenderer { GraphicsDeviceService = ctrl.Graphics }; ExplosionEffect = contentManager.Load<ParticleEffect>("ExplosionEffect"); ThrusterEffect = contentManager.Load<ParticleEffect>("ThrusterEffect"); FrostThrusterEffect = contentManager.Load<ParticleEffect>("FrostThrusterEffect"); AttachEffect = contentManager.Load<ParticleEffect>("AttachEffect"); BlackHoleEffect = contentManager.Load<ParticleEffect>("BlackHoleEffect"); AlertEffect = contentManager.Load<ParticleEffect>("AlertEffect"); TractorBeamEffect = contentManager.Load<ParticleEffect>("TractorBeamEffect"); EffectsBelowShip.Add(ThrusterEffect); EffectsBelowShip.Add(FrostThrusterEffect); EffectsBelowShip.Add(TractorBeamEffect); EffectsAboveShip.Add(ExplosionEffect); EffectsAboveShip.Add(AttachEffect); EffectsAboveShip.Add(BlackHoleEffect); EffectsAboveShip.Add(AlertEffect); ParticleRenderer.LoadContent(contentManager); foreach (var e in EffectsBelowShip) { e.Initialise(); e.LoadContent(contentManager); } foreach (var e in EffectsAboveShip) { e.Initialise(); e.LoadContent(contentManager); } // Create collision notification callbacks. CollisionWorld.ContactManager.PreSolve += PreSolve; CollisionWorld.ContactManager.BeginContact += BeginContact; CollisionWorld.ContactManager.EndContact += EndContact; CollisionWorld.ContactManager.ContactFilter += ContactFilter; // first parameter controls how strong the pull is; the second parameter controls the radius of the pull. BlackHoleController = new BlackHolePhysicsController(500.0f, 250.0f * k_physicsScale, 9.0f * k_physicsScale); CollisionWorld.AddController(BlackHoleController); ShipCollisionAvoidanceController shipAvoid = new ShipCollisionAvoidanceController(150.0f * k_physicsScale); shipAvoid.MaxRadius = 80.0f * k_physicsScale; CollisionWorld.AddController(shipAvoid); // HUD. HUD = new Menus.HUD(this); // Farseer freaks out unless we call Update here when changing Environments. FIXME: Why? Update(0.0f); }