Example #1
0
 public override void AffectHunter(IHunter hunter)
 {
     if (hunter.NumberOfLifes >= 1)
     {
         hunter.NumberOfLifes--;
     }
 }
        /* public bool IsInRange(Position position)
         * {
         *   return 0 <= position.Left && position.Left <= this.ScreenWidth &&
         *       0 <= position.Top - 200 && position.Top <= this.ScreenHeight;
         * }*/

        public void UpdateScoreOnRenderer(IHunter hunter)
        {
            var points = hunter.Points.ToString();
            var lifes  = hunter.NumberOfLifes.ToString();

            this.ShowScoreOnScreen(900, 30, points, Color.FromRgb(255, 255, 255));
            this.ShowScoreOnScreen(900, 60, lifes, Color.FromRgb(255, 255, 255));
        }
 private static void HuntIfYouAreAHunter(Animal animal)
 {
     if (animal is IHunter)
     {
         IHunter tiger = (IHunter)animal; //throws exception if conversion fails
         Console.WriteLine(tiger.Hunt());
     }
 }
Example #4
0
 public void SetUp()
 {
     _aquarium = new Aquarium(new Size(600, 600));
     _neon     = new BlueNeon(new PointF(400, 400), Settings.BlueNeon.Size, _aquarium);
     _hunter   = new Piranha(new PointF(420, 420), Settings.Piranha.Size, _aquarium);
     _aquarium.AddObject(_neon);
     _aquarium.AddObject((AFish)_hunter);
 }
 public bool IsHunterColliding(IHunter hunter, IList <IBird> birds)
 {
     foreach (var bird in birds)
     {
         if (AreCollided(hunter, bird))
         {
             bird.IsAlive = false;
             bird.Health  = 0;
             hunter.NumberOfLifes--;
             return(true);
         }
     }
     return(false);
 }
        //IList<IAffectableGameObject>
        private void HandleCollisionBetweenObjectsAndHunter(IHunter hunter, IList <IGameObject> gameObjects)
        {
            foreach (var gameObject in gameObjects)
            {
                if (this.AreCollided(hunter, gameObject) && !(gameObject is Hunter))
                {
                    var objectAsAffectableGameObject = gameObject as IAffectableGameObject;

                    //null propagation => C# 6.0
                    objectAsAffectableGameObject?.AffectHunter(hunter);

                    gameObject.IsAlive = false;
                }
            }
        }
Example #7
0
 public Cat(IHunter hunter, IValerian valerian)
 {
     _hunter   = hunter;
     _valerian = valerian;
 }
Example #8
0
 public override void AffectHunter(IHunter hunter)
 {
     hunter.NumberOfLifes++;
 }
Example #9
0
 public Dog(IHunter hunter, ITail tail)
 {
     _hunter = hunter;
     _tail   = tail;
 }
Example #10
0
 public CatDog(IHunter hunter, ITail tail, IValerian valerian)
 {
     _hunter   = hunter;
     _tail     = tail;
     _valerian = valerian;
 }
 public Turkey(IHunter hunter)
 {
 }
Example #12
0
 public Turkey(IHunter hunter)
 {
 }
 public void HandleCollisions(IList <IBullet> bullets, IList <IBird> birds, IHunter hunter, IList <IGameObject> gameObjects)
 {
     this.HandleCollisionBetweenBulletsAndObjects(bullets, birds, hunter);
     this.HandleCollisionBetweenObjectsAndHunter(hunter, gameObjects);
 }
 private void HandleCollisionBetweenBulletsAndObjects(IList <IBullet> bullets, IList <IBird> birds, IHunter hunter)
 {
     foreach (var bullet in bullets)
     {
         foreach (var bird in birds)
         {
             if (AreCollided(bird, bullet))
             {
                 bullet.IsAlive = false;
                 bird.IsAlive   = false;
                 bird.AffectHunterPointsByBullet(hunter);
                 break;
             }
         }
     }
 }
Example #15
0
 public virtual void AffectHunter(IHunter hunter)
 {
     hunter.Points += this.PointAffect;
 }
Example #16
0
 public void AffectHunterPointsByBullet(IHunter hunter)
 {
     hunter.Points += this.PointAffect;
 }