コード例 #1
0
        public Bullet(ContentManager content, Ship fc)
        {
            ship = fc;

            ForwardDirection = ship.ForwardDirection;
            AimDirection = ship.AimDirection;

            startPosition = ship.Position;

            Model = content.Load<Model>("Models/bullet4");

            BoundingSphere = CalculateBoundingSphere();
            BoundingSphere scaledSphere;
            scaledSphere = BoundingSphere;
            scaledSphere.Radius *=
                GameConstants.FuelCarrierBoundingSphereFactor;
            BoundingSphere =
                new BoundingSphere(scaledSphere.Center, scaledSphere.Radius);

            timer = 0;
        }
コード例 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            startScreen = Content.Load<Texture2D>("Images/Startup");
            instructionScreen = Content.Load<Texture2D>("Images/Instructions");
            controlsScreen = Content.Load<Texture2D>("Images/Controls");

            healthbar1 = Content.Load<Texture2D>("Images/healthbar");
            healthbar2 = Content.Load<Texture2D>("Images/healthbar2");

            crosshair = Content.Load<Texture2D>("Images/crosshair");

            ground.Model = Content.Load<Model>("Models/ground");
            boundingSphere.Model = Content.Load<Model>("Models/sphere1uR");

            spriteBatch = new SpriteBatch(GraphicsDevice);
            statsFont = Content.Load<SpriteFont>("Fonts/StatsFont");

            //Initialize fuel cells
            fuelCells = new FuelCell[GameConstants.NumFuelCells];
            for (int index = 0; index < fuelCells.Length; index++)
            {
                fuelCells[index] = new FuelCell();
                fuelCells[index].LoadContent(Content, "Models/fuelcell");
            }

            //Initialize barriers
            barriers = new Debris[GameConstants.NumBarriers];
            int randomBarrier = random.Next(3);
            string barrierName = null;

            for (int index = 0; index < barriers.Length; index++)
            {

                switch (randomBarrier)
                {
                    case 0:
                        barrierName = "Models/cube10uR";
                        break;
                    case 1:
                        barrierName = "Models/cylinder10uR";
                        break;
                    case 2:
                        barrierName = "Models/pyramid10uR";
                        break;
                }
                barriers[index] = new Debris();
                barriers[index].LoadContent(Content, barrierName);
                randomBarrier = random.Next(3);
            }
            PlaceFuelCellsAndDebris();

            //Initialize fuel carrier
            fuelCarrier = new Ship();
            fuelCarrier.LoadContent(Content, "Models/fuelcarrier");

            //int min = GameConstants.MinDistance;
            //int max = GameConstants.MaxDistance;

            //Load sound effects
            laserSound = Content.Load<SoundEffect>("Sounds/laserSound");
            laserSound2 = Content.Load<SoundEffect>("Sounds/laserSound2");
            refuel = Content.Load<SoundEffect>("Sounds/powerUp");
            explosion = Content.Load<SoundEffect>("Sounds/explosion");
        }