private void moveEachInFleetEnemyLeft(EnemyShip enemy) { if (enemy.X < this.backgroundWidth) { enemy.MoveLeft(); } }
private void killEnemiesHit(EnemyShip enemy) { if (this.playerAmmo.Any()) { this.removeEachEnemyHitByBulletFromGame(enemy); } }
private void moveEachEnemyInFleetRight(EnemyShip enemy) { if (enemy.X < this.backgroundWidth) { enemy.MoveRight(); } }
/// <summary> /// Removes the enemy from fleet.\ /// Precondition: enemyRows /// Postcondition: Enemy is removed from one its list and the size of that list is decreased. /// </summary> /// <param name="enemyShip">The enemy ship to be removed.</param> public void RemoveEnemyFromFleet(EnemyShip enemyShip) { foreach (var enemyRow in Fleet) { if (enemyRow.Contains(enemyShip)) { enemyRow.Remove(enemyShip); } } }
private void fireShipWhenShipHasNotFired(EnemyShip firingShip) { var isEnemyWaiting = this.checkIfEnemyIsWaiting(firingShip); if (!this.enemyAmmo.Any() || !isEnemyWaiting) { this.addEnemyBulletsToScreen(firingShip); firingShip.HasFired = true; } }
private void removeEachEnemyHitByBulletFromGame(EnemyShip enemy) { List <Bullet> playerBulletsFired = new List <Bullet>(this.playerAmmo); foreach (var bulletFired in playerBulletsFired) { this.removeEnemyHitByBulletFromGame(bulletFired, enemy); this.checkBonusShipHit(bulletFired); } }
private void addBonusEnemyToGame() { var randomInt = RandomUtil.GetNextRandomFromMax(30); if (this.bonusEnemyShip == null) { this.bonusEnemyShip = (EnemyShip)ShipFactory.SelectShip(ShipFactory.ShipSelections.BonusShip); this.currentBackground.Children.Add(this.bonusEnemyShip.Sprite); this.placeBonusEnemyShip(); } }
private void addEnemyBulletsToScreen(EnemyShip enemy) { var randomBullet = new Bullet(); var maxAmmo = 3; if (this.enemyAmmo.Count < maxAmmo) { this.enemyAmmo.Add(randomBullet); this.currentBackground.Children.Add(randomBullet.Sprite); this.placeEnemyBullet(enemy, randomBullet); } }
private bool checkIfEnemyIsWaiting(EnemyShip enemy) { bool isEnemyWaiting = false; if (this.enemyAmmo.Any()) { var bulletClosetToShip = this.enemyAmmo.Max(bullet => bullet.Y + bullet.Height); isEnemyWaiting = bulletClosetToShip < enemy.Y - enemy.Height; } return(isEnemyWaiting); }
private void setEnemyYLocation(int level, EnemyShip currentEnemy) { if (level == 1) { currentEnemy.Y = this.backgroundHeight * Half; } else { var previousLevel = level - 1; var prevEnemyRow = this.fleet.GetEnemyShipsByLevel(previousLevel); var higherLevelEnemy = prevEnemyRow.First(); currentEnemy.Y = higherLevelEnemy.Y - (EnemyShipOffset + currentEnemy.Height); } }
private void removeEnemyHitByBulletFromGame(Bullet bullet, EnemyShip enemy) { if (this.bulletHitShip(bullet, enemy)) { if (enemy.Level == 0) { this.gameScoreboard.IncreaseScore(10000); this.currentBackground.Children.Remove(this.bonusEnemyShip.Sprite); } this.gameScoreboard.IncreaseScore(enemy.Level); this.fleet.RemoveEnemyFromFleet(enemy); this.removeBulletFromGame(bullet); this.currentBackground.Children.Remove(enemy.Sprite); } }
public AllEnemyShips(int numberOfEachShip, int amountOfLevels) { int levelCap = ++amountOfLevels; this.enemies = new List <EnemyShip>(); for (int level = 1; level < levelCap; level++) { for (int i = 0; i < numberOfEachShip; i++) { EnemyShip enemy = new EnemyShip(level); this.enemies.Add(enemy); } } }
private void removeBonusShipFromGame() { this.currentBackground.Children.Remove(this.bonusEnemyShip.Sprite); this.bonusEnemyShip = null; this.BonusEnemyShipVisible = false; }
private double calculateNextShipXOrigin(EnemyShip firstShipOfPreviousRow) { return(firstShipOfPreviousRow.X - (firstShipOfPreviousRow.Width + EnemyShipOffset)); }
private void placeEnemyBullet(EnemyShip enemy, Bullet bullet) { bullet.X = enemy.X + enemy.Sprite.ActualWidth * Half + bullet.X * Half; bullet.Y = enemy.Y; }