Esempio n. 1
0
        private void AddEnemy()
        {
            //create the animation object
            Animation enemyAnimation = new Animation();
            //Animation balloonEnemyAnimation = new Animation();
            //initizlize theanimation with the correct ahimation information
            enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.White, 1f, true);
            // balloonEnemyAnimation.Initialize(balloonEnemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.White, 1f, true);
            //randomly generate the position of the enemy or later change this to a specific spot
            Vector2 position = new Vector2(ScreenManager.GraphicsDevice.Viewport.Width + enemyTexture.Width / 2, random.Next(100, ScreenManager.GraphicsDevice.Viewport.Height - 100));
            // Vector2 balloonPosition = new Vector2(ScreenManager.GraphicsDevice.Viewport.Width + balloonEnemyTexture.Width / 2, randomEnemy.Next(100, ScreenManager.GraphicsDevice.Viewport.Height - 100));

            //create an enemy
            Enemy enemy = new Enemy();
            //Enemy balloonEnemy = new Enemy();
            //initizlize the enemy
            enemy.Initialize(enemyAnimation, position);
            //balloonEnemy.Initialize(balloonEnemyAnimation, balloonPosition);
            // add the enemy to the active enemies list
            enemies.Add(enemy);
            //balloonEnemies.Add(balloonEnemy);
        }
Esempio n. 2
0
 private void AddExplosion(Vector2 position)
 {
     Animation explosion = new Animation();
     explosion.Initialize(explosion1Texture, position, 134, 134, 12, 45, Color.White, 1f, false);
     explosions.Add(explosion);
 }
Esempio n. 3
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            //todo figure out which background to use
            newBackground = new Background(content, @"Graphics\Backgrounds\PrimaryStar", @"Graphics\Backgrounds\ParallaxStars", ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);

            // bgLayer1 = new ParallaxingBackground();
            //bgLayer2 = new ParallaxingBackground();
            // star1 = new ScrollingBackground();
            // star2 = new ScrollingBackground();

            // score postion setting
            scorePosition = new Vector2(ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.X, ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y);
               // scoreString = GetScoreString(player.Score);

            //todo not working yet for effects
            standardEffect = content.Load<Effect>(@"Effects\Standard");

            iLivesLeft = 3;

            gameFont = content.Load<SpriteFont>(@"Graphics\gamefont");

            //load paralzxing background
            // bgLayer1.Initialize(content, @"Graphics\bgLayer1", ScreenManager.GraphicsDevice.Viewport.Width, -1);
            // bgLayer2.Initialize(content, @"Graphics\bglayer2", ScreenManager.GraphicsDevice.Viewport.Width, -2);
            // try scrolling
            // star1.Initialize(content, @"Graphics\Backgrounds\star1", ScreenManager.GraphicsDevice.Viewport.Width, -1);
            // star2.Initialize(content, @"Graphics\Backgrounds\star6", ScreenManager.GraphicsDevice.Viewport.Width, -1);

            //load enemies textures
            fireHairTexture = content.Load<Texture2D>(@"graphics\FireHair");
            asteroidTexture2 = content.Load<Texture2D>(@"Graphics\asteroid01");
            //asteroidTexture = content.Load<Texture2D>(@"Graphics\asteroid01");
            enemyTexture = content.Load<Texture2D>(@"Graphics\mineAnimation");
            balloonEnemyTexture = content.Load<Texture2D>(@"Graphics\mineGreenAnimation");
            powerupDamageTexture = content.Load<Texture2D>(@"Graphics\powerup");
            powerupShieldTexture = content.Load<Texture2D>(@"Graphics\shieldpowerup");
            mainBackground = content.Load<Texture2D>(@"Graphics\mainbackground");

            scoreFont = content.Load<SpriteFont>(@"Graphics\gameFont");
            //initialize projectile
            projectiles = new List<Projectile>();

            //powerups
            damagePowerUps = new List<PowerUp>();
            shieldPowerUps = new List<PowerUp>();
            //set the laser to fie every quarter second
            //fireTime = TimeSpan.FromSeconds(.15f);

            //load projectile
            projectileTexture = content.Load<Texture2D>(@"Graphics\lasergreen");

            // explosions
            explosions = new List<Animation>();
            explosion1Texture = content.Load<Texture2D>(@"Graphics\explosion");

            //initialize fire Hair
            fireHairEnemies = new List<FireHair>();
            previousFireHairSpawnTime = TimeSpan.Zero;
            fireHairSpawnTime = TimeSpan.FromSeconds(8f);
            //randomFireHair = new Random();

            //initialize asteroid
            asteroids2 = new List<AsteroidEnemy2>();
            //asteroids = new List<AsteroidEnemy>();
            previousAsteroidSpawnTime = TimeSpan.Zero;
            asteroidSpawnTime = TimeSpan.FromSeconds(10f);
            //randomAsteroid = new Random();

            //initialize enemies list etc..

            enemies = new List<Enemy>();
            //seperate enemies to balloon to add other ones.
            balloonEnemies = new List<GreenMineEnemy>();
            //set enemy spawn time keepers to zero
            previousSpawnTime = TimeSpan.Zero;
            previousBalloonSpawnTime = TimeSpan.Zero;
            //used to determine how fast enemy respawns
            enemySpawnTime = TimeSpan.FromSeconds(2.0f);
            balloonEnemySpawnTime = TimeSpan.FromSeconds(5.0f);
            powerUpSpawnTime = TimeSpan.FromSeconds(10.0f);
            previousPowerUpSpawnTime = TimeSpan.Zero;
            previousDeathTime = TimeSpan.Zero;
            deathTime = TimeSpan.FromSeconds(1.0f);
            //initialize random number for enemies
               // randomEnemy = new Random();
            //randomPowerUp = new Random();
            //initialize a new player. not sure why have to do it here.
            player = new Player();

            //try projectile hee

            gameOver = false;

            //score = 0;

            //use animation now.

            Animation playerAnimation = new Animation();
            Texture2D playerTexture = content.Load<Texture2D>(@"Graphics\shipAnimation");

            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);
            Vector2 playerPosition3 = new Vector2(ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.X, ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
            player.Initialize(playerAnimation, playerPosition3);

            //----animation section ^

            // player.Initialize(content.Load<Texture2D>(@"Graphics\player"), playerPosition3);
            playerMoveSpeed = 8.0f;
            Thread.Sleep(1000);

            //todo take out music when switch menus
            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }