Ejemplo n.º 1
0
    def attack(self, unit):
      enemies = unit.in_range_enemies
      if len(enemies) > 0:
				enemy = self.select_target(unit, enemies)
				
				unit.shoot( self.enemy_predictor[enemy].predict(unit.position, settings.bullet.speed) )
				return True
Ejemplo n.º 2
0
  def attack_nearby_enemies(self):
    all_attack = None
    for p in self.positions:
      unit = getattr(self, p)
      if unit:
        ire = unit.in_range_enemies
        if ire:
          all_attack = ire[0]
          break

    if all_attack:
      for p in self.positions:
        unit = getattr(self, p)
        if not unit: continue

        if all_attack in unit.in_range_enemies:
          unit.shoot(all_attack.position)
        else:
          unit.move(all_attack.position)