Exemplo n.º 1
0
        public static void Shoot(Alien shooter)
        {
            AlienBullet b = GetFreeBullet();

            if (b != null)
            {
                b.Shoot(new Vector2(shooter.Position.X, shooter.Position.Y + shooter.GetHeight() / 2 + 15), new Vector2(0, 250));
            }
        }
Exemplo n.º 2
0
        public static void Init(int numOfAliens, int numOfRows)
        {
            numAliens     = numOfAliens;
            numRows       = numOfRows;
            aliensPerRow  = numAliens / numRows;
            numVisibles   = numAlives = numAliens;
            ship          = new Ship();
            nextShipSpawn = RandomGenerator.GetRandom(5, 20);

            aliens = new Alien[numAliens];

            int startX = 40;
            int posY   = 40;
            int dist   = 5;

            alienWidth  = 55;
            alienHeight = 40;

            Color green = new Color(0, 255, 0);

            for (int i = 0; i < aliens.Length; i++)
            {
                if (i != 0 && i % aliensPerRow == 0)
                {
                    posY += alienHeight + dist;
                }
                int alienX = startX + (i % aliensPerRow) * (alienWidth + dist);
                aliens[i] = new Alien(new Vector2(alienX, posY), new Vector2(100, 0), alienWidth, alienHeight, green);

                if (i >= numOfAliens - aliensPerRow)
                {
                    aliens[i].CanShoot = true;
                }
            }

            bullets = new AlienBullet[aliensPerRow];

            Color bulletCol = new Color(200, 200, 200);


            for (int i = 0; i < bullets.Length; i++)
            {
                bullets[i] = new AlienBullet();
            }


            // aliens[0]= new Alien(tools, new Vector2(tools.Win.width / 2, 40), new Vector2(250, 0), 40, 40, new Color(0, 255, 0));
        }