public void FireShot() { if (playerShots.Count < 2) { Shot newShot = new Shot( new Point((playerShip.Location.X + (playerShip.image.Width / 2)) , playerShip.Location.Y), Direction.Up, formArea); playerShots.Add(newShot); } }
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); }