// Constructor public CollisionsManager(PlayerShip player1Ship, PlayerShip player2Ship, AsteroidField asteroidField) { // Update internal variables this.player1Ship = player1Ship; this.player2Ship = player2Ship; this.asteroidField = asteroidField; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here // Render targets RenderTargetTop = new RenderTarget2D( GraphicsDevice, 960, 1080, false, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents ); RenderTargetBottom = new RenderTarget2D( GraphicsDevice, 960, 1080, false, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents ); RenderTargetFullscreen = new RenderTarget2D( GraphicsDevice, 1920, 1080, false, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents ); // Load lighting effect and set up material. Give material's color variables some values ShipMaterial = new LightningMaterial(); ShipMaterial.AmbientColor = Color.Red.ToVector3() * .15f; ShipMaterial.LightColor = Color.White.ToVector3() * .85f; SimpleEffect = Content.Load <Effect>("Effects/LightingEffect"); // SkyBox skyBox = new SkyBox(Content, GraphicsDevice, Content.Load <TextureCube>("Models/clouds")); // Static class menus MainMenu.LoadContent(Content, GraphicsDevice); GameOver.LoadContent(Content, GraphicsDevice); Credits.LoadContent(Content, GraphicsDevice); Tutorial.LoadContent(Content, GraphicsDevice); // Load Ship models for both players CustomModel ship1 = new CustomModel(Content.Load <Model>("Models/Ship"), Vector3.Zero, Vector3.Zero, new Vector3(1f), Vector3.Zero, Vector3.Zero, GraphicsDevice); CustomModel ship2 = new CustomModel(Content.Load <Model>("Models/Ship"), Vector3.Zero, Vector3.Zero, new Vector3(1f), Vector3.Zero, Vector3.Zero, GraphicsDevice); // Load cockpit models for both players CustomModel cockpit1 = new CustomModel(Content.Load <Model>("Models/Cockpit"), Vector3.Zero, Vector3.Zero, new Vector3(1f), Vector3.Zero, Vector3.Zero, GraphicsDevice); CustomModel cockpit2 = new CustomModel(Content.Load <Model>("Models/Cockpit"), Vector3.Zero, Vector3.Zero, new Vector3(1f), Vector3.Zero, Vector3.Zero, GraphicsDevice); // Set models' effect ship1.SetModelEffect(SimpleEffect, true); ship2.SetModelEffect(SimpleEffect, true); // Set models' material ship1.Material = ShipMaterial; ship2.Material = ShipMaterial; // BulletManagers player1bulletManager = new BulletManager(Content.Load <Model>("Models/bullet"), 3000); player2bulletManager = new BulletManager(Content.Load <Model>("Models/bullet"), 3000); // Create player ships and assign controllers player1Ship = new PlayerShip(ship1, cockpit1, player1bulletManager, Content.Load <Texture2D>("Textures/crosshair"), Content.Load <Texture2D>("Textures/marker"), Content.Load <Texture2D>("Textures/centerMarker1"), Content.Load <Texture2D>("Textures/centerMarker1"), new Vector3(0, 0, -150), new Vector3(0, 0, 0), PlayerIndex.One); player2Ship = new PlayerShip(ship2, cockpit2, player2bulletManager, Content.Load <Texture2D>("Textures/crosshair"), Content.Load <Texture2D>("Textures/marker"), Content.Load <Texture2D>("Textures/centerMarker1"), Content.Load <Texture2D>("Textures/centerMarker1"), new Vector3(0, 30, 150), new Vector3(0, MathHelper.Pi, 0), PlayerIndex.Two); // Player's cameras cameraPlayer1 = new CockpitCamera(new Vector3(0, 3.1f, -10), new Vector3(0, 3, 0), Vector3.Zero, GraphicsDevice, 8 / 9f); cameraPlayer2 = new CockpitCamera(new Vector3(0, 3, -10), new Vector3(0, 3, 0), Vector3.Zero, GraphicsDevice, 8 / 9f); // Load asteroid field asteroidField = new AsteroidField(Content.Load <Model>("Models/asteroid"), 10); // CollisionsManager collisionsManager = new CollisionsManager(player1Ship, player2Ship, asteroidField); // Load font used for HUD HudFont = Content.Load <SpriteFont>("Fonts/digitaldream"); // Get mouseState to prevent potential error with variable beeing null lastMouseState = Mouse.GetState(); // Load sounds SoundManager.LoadContent(Content); // Update input manager once before game start to prevent possible gamepad state == null error InputManager.Update(); }