public static void Shoot(Alien shooter) { BulletAliens b = GetFreeBullet(); if (b != null) { b.Shoot(new Vector2(shooter.Position.X, shooter.Position.Y + shooter.GetHeight() / 2 + 15), new Vector2(0, 250)); } }
public static void Init(int numOfAliens, int numOfRows) { numAliens = numOfAliens; numRows = numOfRows; aliensPerRow = numAliens / numRows; numAlives = numAliens; aliens = new Alien[numAliens]; int startX = 300; int posY = 150; int dist = 30; alienWidth = 60; alienHeight = 40; Color green = new Color(255, 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(20, 0), alienWidth, alienHeight, green); if (i >= numOfAliens - aliensPerRow) { aliens[i].CanShoot = true; } } bulletsAliens = new BulletAliens[aliensPerRow]; Color bulletCol = new Color(250, 200, 0); for (int i = 0; i < bulletsAliens.Length; i++) { bulletsAliens[i] = new BulletAliens(20, 15, bulletCol); } // aliens[0]= new Alien(tools, new Vector2(tools.Win.width / 2, 40), new Vector2(250, 0), 40, 40, new Color(0, 255, 0)); }