Exemple #1
0
        public bool CollidesPlayers(BaseAlien alienOne)
        {
            for (int i = 0; i < players.Length; i++)
            {
                if (Collider.Collide(alienOne._collisionRectangle, players[i].collisionRectangle)) return true;
            }

            return false;
        }
 public bool CollideCurrentEntities(BaseAlien alienOne)
 {
     return sections[currentSection].CollideAliens(alienOne);
 }
 public bool CollideAliens(BaseAlien alienOne)
 {
     for (int i = 0; i < _population.Count; i++)
     {
         BaseAlien ba = _population[i];
         if (ba == alienOne) continue;
         if (Collider.Collide(alienOne._collisionRectangle, ba._collisionRectangle))
         {
             return true;
         }
     }
     return false;
 }
 public void AddAlienToPopulation(BaseAlien ba)
 {
     _population.Add(ba);
     _currentTitle = "Aliens Left: " + _population.Count;
 }
        public IProjectile CheckHit(BaseAlien alien)
        {
            int i = pistolBulletPool.GetFirst();
            while (i != -1)
            {
                PistolBullet b = pistolBulletPool.GetByIndex(i);
                if (Collider.Collide(alien.GetBoundRect(), b.GetCenter())) return b;
                i = pistolBulletPool.NextIndex(b);
            }

            i = shotgunBulletPool.GetFirst();
            while (i != -1)
            {
                ShotgunBullet b = shotgunBulletPool.GetByIndex(i);
                if (Collider.Collide(alien.GetBoundRect(), b.GetCenter())) return b;
                i = shotgunBulletPool.NextIndex(b);
            }

            i = assaultBulletPool.GetFirst();
            while (i != -1)
            {
                AssaultBullet b = assaultBulletPool.GetByIndex(i);
                if (Collider.Collide(alien.GetBoundRect(), b.GetCenter())) return b;
                i = assaultBulletPool.NextIndex(b);
            }

            i = sniperBulletPool.GetFirst();
            while (i != -1)
            {
                SniperBullet b = sniperBulletPool.GetByIndex(i);
                if (Collider.Collide(alien.GetBoundRect(), b.GetCenter())) return b;
                i = sniperBulletPool.NextIndex(b);
            }
            return null;
        }