private void nextWave() { wave++; invaderDirection = Direction.Right; // if the wave is under 7, set frames skipped to 6 - current wave number if (wave < 7) { framesSkipped = 6 - wave; } else { framesSkipped = 0; } int currentInvaderYSpace = 0; for (int x = 0; x < 5; x++) { ShipType currentInvaderType = (ShipType)x; currentInvaderYSpace += invaderYSpacing; int currentInvaderXSpace = 0; for (int y = 0; y < 5; y++) { currentInvaderXSpace += invaderXSpacing; Point newInvaderPoint = new Point(currentInvaderXSpace, currentInvaderYSpace); // Need to add more varied invader score values Invader newInvader = new Invader(currentInvaderType, newInvaderPoint, 10); invaders.Add(newInvader); } } }
private void returnFire() { //// invaders check their location and fire at the player if (invaderShots.Count == wave) { return; } if (random.Next(10) < (10 - wave)) { return; } var invaderColumns = from invader in invaders group invader by invader.Location.X into columns select columns; int randomColumnNumber = random.Next(invaderColumns.Count()); var randomColumn = invaderColumns.ElementAt(randomColumnNumber); var invaderRow = from invader in randomColumn orderby invader.Location.Y descending select invader; Invader shooter = invaderRow.First(); Point newShotLocation = new Point (shooter.Location.X + (shooter.Area.Width / 2), shooter.Location.Y + shooter.Area.Height); Shot newShot = new Shot(newShotLocation, Direction.Down, formArea); invaderShots.Add(newShot); }
/// <summary> /// Return fire method /// </summary> private void returnFire() { //// invaders check their location and fire at the player if (invaderShots.Count == wave) { return; } if (random.Next(10) < (10 - wave)) { return; } if (wave != bossWave) { var invaderColumns = from invader in invaders group invader by invader.Location.X into columns select columns; int randomColumnNumber = random.Next(invaderColumns.Count()); var randomColumn = invaderColumns.ElementAt(randomColumnNumber); var invaderRow = from invader in randomColumn orderby invader.Location.Y descending select invader; Invader shooter = invaderRow.First(); Point newShotLocation = new Point (shooter.Location.X + (shooter.Area.Width / 2), shooter.Location.Y + shooter.Area.Height); Shot newShot = new Shot(newShotLocation, Direction.Down, formArea); invaderShots.Add(newShot); } else { if (bossShots.Count > 10) { return; } int randomNo = random.Next(3); Point newShotLocation = new Point(boss.Location.X + (boss.Area.Width / 2), boss.Location.Y + boss.Area.Height - 35); // Different shooting patterns for boss switch (randomNo) { case 1: { Shot newBossShot = new Shot(newShotLocation, Direction.Down, formArea); Shot newBossShot2 = new Shot(newShotLocation, Direction.Down20L, formArea); Shot newBossShot3 = new Shot(newShotLocation, Direction.Down20R, formArea); bossShots.Add(newBossShot); bossShots.Add(newBossShot2); bossShots.Add(newBossShot3); break; } case 2: { Shot newBossShot = new Shot(newShotLocation, Direction.Down, formArea); Shot newBossShot2 = new Shot(newShotLocation, Direction.Down20L, formArea); Shot newBossShot3 = new Shot(newShotLocation, Direction.Down20R, formArea); Shot newBossShot4 = new Shot(newShotLocation, Direction.Down40L, formArea); Shot newBossShot5 = new Shot(newShotLocation, Direction.Down40R, formArea); bossShots.Add(newBossShot); bossShots.Add(newBossShot2); bossShots.Add(newBossShot3); bossShots.Add(newBossShot4); bossShots.Add(newBossShot5); break; } } } }
/// <summary> /// Next wave method /// </summary> private void nextWave() { // Make sure the invaders is all cleared //if (invaders.Count > 1) //{ // foreach (Invader invader in invaders) // { // invaders.Remove(invader); // } //} invaders.Clear(); wave++; Random rnd = new Random(); //Lee: Created the random generator and the IF-ELSE statement so that when a new wave begins, if (rnd.Next(0, 2) == 0) // it will start moving either to the left or the right (random). { invaderDirection = Direction.Left; } else { invaderDirection = Direction.Right; } // if the wave is under 7, set frames skipped to 6 - current wave number if (wave < 7) { framesSkipped = 6 - wave; } else { framesSkipped = 0; } //if (wave == 3 || wave == 6) { // int currentAlienYSpace = 0; // for (int x = 0; x < 5; x++) // { // Alien currentAlien = (Alien)x; // currentAlienYSpace += alienYSpacing; // int currentAlienXSpace = 120; //Lee: Changed this value from 0, so the invaders will start in the middle of the screen // for (int y = 0; y < 5; y++) // { // currentAlienXSpace += alienXSpacing; // Point newAleinPoint = // new Point(currentAlienXSpace, currentAlienYSpace); // alien newAlien = // new Alien(currentAlienType, newAlienPoint, 10); // alien.Add(newAlien); // playerShots.Clear(); //Lee: Added these two lines to ensure that the // alienShots.Clear();//map is cleared of bullets when a new wave begins //} //} //} //else { // //} int currentInvaderYSpace = 0; for (int x = 0; x < 5; x++) { ShipType currentInvaderType = (ShipType)x; currentInvaderYSpace += invaderYSpacing; int currentInvaderXSpace = 120; //Lee: Changed this value from 0, so the invaders will start in the middle of the screen for (int y = 0; y < 5; y++) { currentInvaderXSpace += invaderXSpacing; Point newInvaderPoint = new Point(currentInvaderXSpace, currentInvaderYSpace); // Need to add more varied invader score values Invader newInvader = new Invader(currentInvaderType, newInvaderPoint, 10); invaders.Add(newInvader); playerShots.Clear(); //Lee: Added these two lines to ensure that the invaderShots.Clear(); //map is cleared of bullets when a new wave begins bossShots.Clear(); } } }
private void nextWave() { wave++; invaderDirection = Direction.Right; // if the wave is under 7, set frames skipped to 6 - current wave number if (wave < 7) { framesSkipped = 6 - wave; } else framesSkipped = 0; int currentInvaderYSpace = 0; for (int x = 0; x < 5; x++) { ShipType currentInvaderType = (ShipType)x; currentInvaderYSpace += invaderYSpacing; int currentInvaderXSpace = 0; for (int y = 0; y < 5; y++) { currentInvaderXSpace += invaderXSpacing; Point newInvaderPoint = new Point(currentInvaderXSpace, currentInvaderYSpace); // Need to add more varied invader score values Invader newInvader = new Invader(currentInvaderType, newInvaderPoint, 10); invaders.Add(newInvader); } } }