示例#1
0
 private void moveEachInFleetEnemyLeft(EnemyShip enemy)
 {
     if (enemy.X < this.backgroundWidth)
     {
         enemy.MoveLeft();
     }
 }
示例#2
0
 private void killEnemiesHit(EnemyShip enemy)
 {
     if (this.playerAmmo.Any())
     {
         this.removeEachEnemyHitByBulletFromGame(enemy);
     }
 }
示例#3
0
 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);
         }
     }
 }
示例#5
0
        private void fireShipWhenShipHasNotFired(EnemyShip firingShip)
        {
            var isEnemyWaiting = this.checkIfEnemyIsWaiting(firingShip);

            if (!this.enemyAmmo.Any() || !isEnemyWaiting)
            {
                this.addEnemyBulletsToScreen(firingShip);
                firingShip.HasFired = true;
            }
        }
示例#6
0
        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);
            }
        }
示例#7
0
        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();
            }
        }
示例#8
0
        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);
            }
        }
示例#9
0
        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);
        }
示例#10
0
 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);
     }
 }
示例#11
0
 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);
     }
 }
示例#12
0
        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);
                }
            }
        }
示例#13
0
 private void removeBonusShipFromGame()
 {
     this.currentBackground.Children.Remove(this.bonusEnemyShip.Sprite);
     this.bonusEnemyShip        = null;
     this.BonusEnemyShipVisible = false;
 }
示例#14
0
 private double calculateNextShipXOrigin(EnemyShip firstShipOfPreviousRow)
 {
     return(firstShipOfPreviousRow.X - (firstShipOfPreviousRow.Width +
                                        EnemyShipOffset));
 }
示例#15
0
 private void placeEnemyBullet(EnemyShip enemy, Bullet bullet)
 {
     bullet.X = enemy.X + enemy.Sprite.ActualWidth * Half + bullet.X * Half;
     bullet.Y = enemy.Y;
 }