示例#1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            projectileBoost = 0;
            healthMultiplier = 1;
            secondHealthMultiplier = 1;
            projectileColor = Color.White;
            // Initialize the player class
            player = new Player();
            miniShips = new List<MiniShip>();
            // Set a constant player move speed
            playerMoveSpeed = 6f;
            bgLayer1 = new ParallaxingBackground();
            bgLayer2 = new ParallaxingBackground();

            // Initialize the enemies list
            enemies = new List<Enemy>();
            asteroids = new List<Asteroid>();
            bosses = new List<Boss1>();
            powerups = new List<Powerup>();
            allyPowerups = new List<AllyPowerup>();
            healthPowerups = new List<HealthPowerup>();
            explosions = new List<Animation>();
            shootingEnemies = new List<ShootingEnemy>();
            enemyProjectiles = new List<Projectile>();

            bigBosses = new List<BigBoss>();
            bigBossPreviousWeaponFireTimes = new List<TimeSpan>();
            bigBossWeaponFireTimes = new List<TimeSpan>();
            bigBossProjectiles = new List<Projectile>();

            //Set player's score to zero
            score = 0;

            // Set the time keepers to zero
            previousSpawnTime = TimeSpan.Zero;
            previousPowerupSpawnTime = TimeSpan.Zero;
            previousHealthPowerupSpawnTime = TimeSpan.Zero;
            previousAsteroidSpawnTime = TimeSpan.Zero;
            healthPowerupSpawnTime = TimeSpan.FromSeconds(80f);
            allyPreviousPowerupSpawnTime = TimeSpan.Zero;
            allyPowerupSpawnTime = TimeSpan.FromSeconds(45f);
            // Used to determine how fast enemy respawns
            enemySpawnTime = TimeSpan.FromSeconds(1.0f);
            powerupSpawnTime = TimeSpan.FromSeconds(20.0f);
            shootingEnemySpawnTime = TimeSpan.FromSeconds(3f);
            asteroidSpawnTime = TimeSpan.FromSeconds(6f);
            previousShootingEnemySpawnTime = TimeSpan.Zero;
            // Initialize our random number generator
            random = new Random();

            projectiles = new List<Projectile>();
            missiles = new List<Missile>();

            // Set the laser to fire every quarter second
            fireTime = TimeSpan.FromSeconds(.15f);
            missileFireTime = TimeSpan.FromSeconds(3f);
            previousMissileFireTime = TimeSpan.Zero;
            miniFireTimes = new List<TimeSpan>();
            miniPreviousFireTimes = new List<TimeSpan>();
            miniMissileFireTimes = new List<TimeSpan>();
            previousMiniMissileFireTimes = new List<TimeSpan>();

            enemyFireTimes = new List<TimeSpan>();
            previousEnemyFireTimes = new List<TimeSpan>();

            max = 4;

            base.Initialize();
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            // Initialize the player class
            player = new Player();
            playerTwo = new Player();

            playerOnescore = 0;
            playerTwoscore = 0;

            startTime = TimeSpan.Zero;

            playerFacingLeft = false;
            // Set a constant player move speed
            playerMoveSpeed = 8.0f;

            bgLayer1 = new ParallaxingBackground();
            bgLayer2 = new ParallaxingBackground();

            // Initialize the enemies list
            enemies = new List<Enemy>();

            // Set the time keepers to zero
            previousSpawnTime = TimeSpan.Zero;

            // Used to determine how fast enemy respawns
            enemySpawnTime = TimeSpan.FromSeconds(1.0f);

            // Initialize our random number generator
            random = new Random();

            projectiles = new List<Projectile>();
            projectilesTwo = new List<Projectile>();

            // Set the laser to fire every quarter second
            fireTime = TimeSpan.FromSeconds(.15f);

            explosions = new List<Animation>();

            // Load the music
            gameplayMusic = Content.Load<Song>("sound/gameMusic");

            // Load the laser and explosion sound effect
            laserSound = Content.Load<SoundEffect>("sound/laserFire");
            explosionSound = Content.Load<SoundEffect>("sound/explosion");
            // Load the score font
            font = Content.Load<SpriteFont>("gameFont");
            // Start the music right away
            PlayMusic(gameplayMusic);

            base.Initialize();
        }