Esempio n. 1
0
        /*************************************************************************************************************************/

        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load object models
            Model asteroidModel  = Content.Load <Model>(@"Models\asteroid1");
            Model shipModel      = Content.Load <Model>(@"Models\p1_wedge");
            Model bulletModel    = Content.Load <Model>(@"Models\pea_proj");
            Model boundaryModel  = Content.Load <Model>(@"Models\asteroid1");
            Model explosionModel = Content.Load <Model>(@"Models\Particle");

            // Set object graphical transforms
            Matrix[] asteroidTransforms  = CommonFunctions.SetupEffectDefaults(asteroidModel, camera);
            Matrix[] shipTransforms      = CommonFunctions.SetupEffectDefaults(shipModel, camera);
            Matrix[] bulletTransforms    = CommonFunctions.SetupEffectDefaults(bulletModel, camera);
            Matrix[] boundaryTransforms  = CommonFunctions.SetupEffectDefaults(boundaryModel, camera);
            Matrix[] explosionTransforms = CommonFunctions.SetupEffectDefaults(explosionModel, camera);

            // Load object hulls
            ConvexSegment asteroidHull = PhysicsEngine.CommonFunctions.LoadConvexHull(
                new System.IO.StreamReader(@"..\..\..\Content\Hulls\Asteroid1.hull"));
            ConvexSegment shipHull = PhysicsEngine.CommonFunctions.LoadConvexHull(
                new System.IO.StreamReader(@"..\..\..\Content\Hulls\Ship.hull"));
            ConvexSegment bulletHull = PhysicsEngine.CommonFunctions.LoadConvexHull(
                new System.IO.StreamReader(@"..\..\..\Content\Hulls\Projectile.hull"));

            // Create all game elements
            asteroids = new AsteroidList(GameConstants.numAsteroids, 70.0f, asteroidHull,
                                         physics, asteroidModel, asteroidTransforms);

            explosions = new ExplosionList(GameConstants.maxExplosions, physics, explosionModel, explosionTransforms);

            bullets = new BulletList(GameConstants.maxBullets, GameConstants.bulletSpeed, 25.0f, bulletHull, physics, bulletModel,
                                     bulletTransforms, soundBank, asteroids, explosions);

            ship = new Ship(70.0f, shipHull, physics, shipModel, shipTransforms,
                            new Vector3(GameConstants.playfieldSizeX / 2, GameConstants.playfieldSizeY / 2, 0), 0, soundBank, explosions, asteroids);

            // Prepare the perimeter
            perimeter = new AsteroidPerimeter(boundaryModel, boundaryTransforms);

            // Load the background texture
            stars = Content.Load <Texture2D>("Textures/B1_stars");

            // Load the font
            lucidaConsole = Content.Load <SpriteFont>("Fonts/Lucida Console");
        }
Esempio n. 2
0
 /// <summary>
 /// The default constructor for a bullet.
 /// </summary>
 /// <param name="radius">A radius that encloses the entire bullet model, centred at (0,0,0) in object space.</param>
 /// <param name="hulls">The convex hull segments that enclose the bullet.</param>
 /// <param name="environment">A reference to the physics engine.</param>
 /// <param name="model">The model used for the bullets.</param>
 /// <param name="transforms">The graphical transforms that are applied to the bullet.</param>
 /// <param name="initialPosition">The initial position of the bullet.</param>
 /// <param name="initialVelocity">The initial velocity of the bullet.</param>
 /// <param name="soundBank">A reference to the SoundBank used for the game's sound effects.</param>
 /// <param name="bullets">A reference to the list of bullets.</param>
 /// <param name="asteroids">A reference to the list of asteroids.</param>
 /// <param name="explosions">A reference to the list of explosions.</param>
 public Bullet(float radius, ConvexHull[] hulls, PhysicsEngine.Environment environment, Model model, Matrix[] transforms,
               Vector3 initialPosition, Vector3 initialVelocity, SoundBank soundBank, BulletList bullets, AsteroidList asteroids, ExplosionList explosions)
 {
     physicsReference = new NonForceEntity(initialPosition, Vector3.Up, 25, radius, new Hull(hulls), new BulletAsteroidCollision(1.0f, soundBank, bullets, asteroids, explosions));
     environment.Add(physicsReference);
     this.bulletModel          = model;
     this.transforms           = transforms;
     physicsReference.Velocity = initialVelocity;
 }