示例#1
0
 /// <summary>
 /// Adds the enemy to the list if it doesn't collide
 /// with another one in it.
 /// </summary>
 /// <param name="enemy"></param>
 public void Add( EntityEnemy enemy )
 {
     foreach( EntityEnemy e in _enemies )
         if( e.Collision( enemy ) )
             return;
     _enemies.Add( enemy );
 }
示例#2
0
 /// <summary>
 /// Adds the enemy to the list if it doesn't collide
 /// with another one in it.
 /// </summary>
 /// <param name="enemy"></param>
 public void Add(EntityEnemy enemy)
 {
     foreach (EntityEnemy e in _enemies)
     {
         if (e.Collision(enemy))
         {
             return;
         }
     }
     _enemies.Add(enemy);
 }
示例#3
0
        /// <summary>
        /// Collision method that is used during game play, to make it somewhat
        /// more realistic.
        /// </summary>
        /// <param name="enemy"></param>
        /// <returns></returns>
        public bool PlayingCollision(EntityEnemy enemy)
        {
            if (enemy == this || !enemy._canBeCollidedWith || !enemy.IsAlive || !IsAlive)
            {
                return(false);
            }

            Vector2 distance = Position - enemy.Position;

            return(distance.Length() < (Size.X + Size.Y) / 16);
        }
示例#4
0
        /// <summary>
        /// Kills the enemy. If the swarm is done, the next one will begin.
        /// </summary>
        /// <param name="enemy"></param>
        public void Kill(EntityEnemy enemy)
        {
            _enemies.Remove(enemy);
            _bodies.Add(enemy);

            if (random.NextDouble() < 0.20)
            {
                _powerUps.Add(_powerUpFactory.Create(enemy.Position));
            }

            if (isSwarmDone())
            {
                if (!_map.IsOnLastSwarm())
                {
                    startNextSwarm();
                }
                else
                {
                    displayMessage();
                }
            }
        }
示例#5
0
        /// <summary>
        /// Collision method that is used during game play, to make it somewhat
        /// more realistic.
        /// </summary>
        /// <param name="enemy"></param>
        /// <returns></returns>
        public bool PlayingCollision( EntityEnemy enemy )
        {
            if( enemy == this || !enemy._canBeCollidedWith || !enemy.IsAlive || !IsAlive )
                return false;

            Vector2 distance = Position - enemy.Position;
            return distance.Length() < (Size.X + Size.Y) / 16;
        }
示例#6
0
 /// <summary>
 /// Removes the enemy from the model.
 /// </summary>
 /// <param name="enemy"></param>
 public void Add(EntityEnemy enemy)
 {
     _enemies.Add(enemy);
 }
示例#7
0
        /// <summary>
        /// Kills the enemy. If the swarm is done, the next one will begin.
        /// </summary>
        /// <param name="enemy"></param>
        public void Kill( EntityEnemy enemy )
        {
            _enemies.Remove( enemy );
            _bodies.Add( enemy );

            if( random.NextDouble() < 0.20 )
                _powerUps.Add( _powerUpFactory.Create( enemy.Position ) );

            if( isSwarmDone() )
            {
                if( !_map.IsOnLastSwarm() )
                    startNextSwarm();
                else
                    displayMessage();
            }
        }
示例#8
0
 /// <summary>
 /// Removes the enemy from the model.
 /// </summary>
 /// <param name="enemy"></param>
 public void Add( EntityEnemy enemy )
 {
     _enemies.Add( enemy );
 }