/// <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 ); }
/// <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); }
/// <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); }
/// <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(); } } }
/// <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; }
/// <summary> /// Removes the enemy from the model. /// </summary> /// <param name="enemy"></param> public void Add(EntityEnemy enemy) { _enemies.Add(enemy); }
/// <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(); } }
/// <summary> /// Removes the enemy from the model. /// </summary> /// <param name="enemy"></param> public void Add( EntityEnemy enemy ) { _enemies.Add( enemy ); }