Example #1
0
        private void HandleCurrentShip()
        {
            BattleshipAssestProvider assetsprovider = new BattleshipAssestProvider(CurrentShip);

            // Shoot first
            var canons = assetsprovider.GetCanons();
            var radars = assetsprovider.GetRadars();

            var weaponscombi = new CanonAndRadarCombiList(canons, radars);

            IEnumerable <Missile> missiles = Shoot(weaponscombi, CurrentShip);

            this.FiredMissiles.AddRange(missiles);

            var incommin = new IncommingMissiles(TheSea, missiles);

            incommin.Launch();

            // show animations
            ShowAnimations(missiles);

            // Move
            var sail = new SailAway(CurrentShip, TheSea);

            sail.Navigate();
        }
Example #2
0
        public void Navigate()
        {
            var       assestprovider = new BattleshipAssestProvider(Ship);
            IKapitein captain        = assestprovider
                                       .GetCaptains()
                                       .FirstOrDefault();
            bool hasCaptain = captain != null;

            if (hasCaptain && captain.ShouldMove())
            {
                MoveShip(captain);
            }
        }
        private void HitShip(BattleShip targetShip, Missile missile)
        {
            var assestprovider = new BattleshipAssestProvider(targetShip);
            IEnumerable <IGoalkeeper> goalkeepers = assestprovider.GetGoalkeepers();
            IGoalkeeper goalkeeper    = goalkeepers.FirstOrDefault();
            bool        hasGoalkeeper = goalkeeper != null;

            if (hasGoalkeeper && IsMissileCatched(goalkeeper))
            {
                missile.SetEffect(MissileEffect.HitAndCatched);
                return;
            }

            MissileEffect effect = targetShip.AcceptMissile(missile);

            missile.SetEffect(effect);
        }