Ejemplo n.º 1
0
        /// <summary>
        /// Loads the images and creates the Aliens for the AlienSquad.
        /// </summary>
        protected override void LoadContent()
        {
            int basePoint = 60;

            Alien.SPEED = STARTING_SPEED;

            // Holds the images for the aliens.
            Texture2D[] images = new Texture2D[3];
            images[0] = game.Content.Load <Texture2D>("flyingsaucer1");
            images[1] = game.Content.Load <Texture2D>("bug1");
            images[2] = game.Content.Load <Texture2D>("satellite1");

            // Holds the distance between two aliens of the same type.
            int height = images[0].Height + images[0].Height / 4;

            // Creates the rows of Aliens.
            int twoAliens        = images[0].Width * 2;
            int startingPosition = (int)STARTING_POSITION.X;
            int positionX;
            int positionY = (int)STARTING_POSITION.Y;

            for (int a = 0; a < aliens.GetLength(0); a++)
            {
                int i = a % images.Length;
                positionX = startingPosition;
                for (int b = 0; b < aliens.GetLength(1); b++)
                {
                    aliens[a, b] = new AlienSprite(game, images[i],
                                                   positionX, positionY, basePoint);
                    aliens[a, b].Initialize();
                    positionX += twoAliens;
                }
                positionY += height;
                basePoint -= 10;
            }

            base.LoadContent();
        }
Ejemplo n.º 2
0
 public void kill(AlienSprite alien)
 {
     alien.kill();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// initializes all variables
        /// </summary>
        public override void Initialize()
        {
            imageAlien = game.Content.Load<Texture2D>(aliens[0]);
            int picNum = 0;
            float picHeight = imageAlien.Height;
            float picWidth = imageAlien.Width * 2;
            this.x = picWidth;
            this.y = picHeight + (picHeight /2);

            tolerance = TimeSpan.FromMilliseconds(speed);
            shootTolerance = TimeSpan.FromMilliseconds(shootingSpeed);

            for (int i = 0; i < numAlien; i++)
            {
                if (picNum == 4)
                    picNum = 0;

                for (int x = 0; x < 12; x++)
                {
                    squads[i, x] = new AlienSprite(game, aliens[picNum], picWidth, picHeight, (((numAlien + 1) - i)*10));
                    squads[i, x].addBombFactory(bombFactory);
                    squads[i, x].Initialize();
                    picWidth += this.x;
                }
                picWidth = this.x;
                picHeight += this.y;
                picNum++;
            }
            movingLeft = squads[3, 0];
            movingRight = squads[3, 5];
            length = squads.Length;
            pewpew.Collision1 += kill;

            base.Initialize();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// finds row is most to the right
 /// </summary>
 public void FindRight()
 {
     bool found = false;
     for (int i = squads.GetLength(1) -1; i > 0 ; i--)
     {
         for (int j = 0; j < squads.GetLength(0); j++)
         {
             if (squads[j, i].Remains)
             {
                 movingRight = squads[j, i];
                 found = true;
                 break;
             }
         }
         if (found)
             break;
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// finds row is most to the left
 /// </summary>
 public void FindLeft()
 {
     bool found = false;
     for (int i = 0; i < squads.GetLength(1); i++)
     {
         for (int j = 0; j < squads.GetLength(0); j++)
         {
             if (squads[j, i].Remains)
             {
                 movingLeft = squads[j, i];
                 found = true;
                 break;
             }
         }
         if (found)
             break;
     }
 }
Ejemplo n.º 6
0
 protected void onCollision1(AlienSprite alien)
 {
     if (Collision1 != null)
         Collision1(alien);
 }
Ejemplo n.º 7
0
 private void updateScore(AlienSprite alien)
 {
     currentScore += alien.getPts();
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Loads the images and creates the Aliens for the AlienSquad.
        /// </summary>
        protected override void LoadContent()
        {
            int basePoint = 60;

            Alien.SPEED = STARTING_SPEED;

            // Holds the images for the aliens.
            Texture2D[] images = new Texture2D[3];
            images[0] = game.Content.Load<Texture2D>("flyingsaucer1");
            images[1] = game.Content.Load<Texture2D>("bug1");
            images[2] = game.Content.Load<Texture2D>("satellite1");

            // Holds the distance between two aliens of the same type.
            int height = images[0].Height + images[0].Height / 4;

            // Creates the rows of Aliens.
            int twoAliens = images[0].Width * 2;
            int startingPosition = (int)STARTING_POSITION.X;
            int positionX;
            int positionY = (int)STARTING_POSITION.Y;

            for (int a = 0; a < aliens.GetLength(0); a ++)
            {
                int i = a % images.Length;
                positionX = startingPosition;
                for (int b = 0; b < aliens.GetLength(1); b++)
                {
                    aliens[a, b] = new AlienSprite(game, images[i],
                                                   positionX, positionY, basePoint);
                    aliens[a, b].Initialize();
                    positionX += twoAliens;
                }
                positionY += height;
                basePoint -= 10;
            }

            base.LoadContent();
        }