Ejemplo n.º 1
0
 def update(self, planet, dt):
     if not self.indicator:
         self.indicator = RangeIndicator(planet.pos,
                                         planet.DEFENSE_RANGE +
                                         planet.get_radius(),
                                         PICO_PINK,
                                         line_length=2,
                                         line_space=5)
         planet.scene.game_group.add(self.indicator)
         planet.selected_graphics.append(self.indicator)
     self.fire_time += dt
     threats = planet.get_threats()
     if self.fire_time > self.FIRE_RATE and threats:
         t = random.choice(threats)
         delta = t.pos - planet.pos
         _, angle = delta.as_polar()
         angle *= 3.14159 / 180
         angle += random.random() * 1.5 - 0.75
         self.fire_time = 0
         b = bullet.Bullet(planet.pos +
                           helper.from_angle(angle) * planet.get_radius(),
                           t,
                           planet,
                           vel=helper.from_angle(angle) * 20,
                           mods={
                               'homing': 1,
                               "damage_base": 10 * planet.planet_weapon_mul,
                               "blast_radius": 10,
                               "color": PICO_WHITE,
                               "life": 5,
                               "missile_speed": 0.5
                           })
         planet.scene.game_group.add(b)
Ejemplo n.º 2
0
 def get_threats(self, planet):
     return [
         s for s in planet.scene.get_enemy_ships_in_range(
             planet.owning_civ, planet.pos, self.THREAT_RANGE +
             planet.get_radius())
         if not s.stealth and (s.pos - planet.pos).length_squared() <=
         (self.THREAT_RANGE + planet.get_radius())**2
     ]
Ejemplo n.º 3
0
 def update(self, planet, dt):
     # Regenerate
     planet.health += 0.5 * dt
     # Fire at threats
     self.fire_time += dt
     threats = self.get_threats(planet)
     if self.fire_time > self.FIRE_RATE and threats:
         self.fire_time = 0
         threat = random.choice(threats)
         _, angle = (threat.pos - planet.pos).as_polar()
         angle *= 3.14159 / 180
         angle += random.random() * 0.5 - 0.25
         b = bullet.Bullet(
             planet.pos + helper.from_angle(angle) * planet.get_radius(),
             threat,
             planet,
             vel=helper.from_angle(angle) * 20,
             mods={
                 'homing': 1,
                 'color': PICO_YELLOW,
                 'damage_base': 3,
                 'missile_speed': -0.25,
                 'life': 5
             },
         )
         planet.scene.game_group.add(b)
Ejemplo n.º 4
0
 def update(self, planet, dt):
     if not self.indicator:
         self.indicator = RangeIndicator(planet.pos,
                                         planet.DEFENSE_RANGE +
                                         planet.get_radius(),
                                         PICO_PINK,
                                         line_length=2,
                                         line_space=5)
         planet.scene.game_group.add(self.indicator)
         planet.selected_graphics.append(self.indicator)
     threats = planet.get_threats()
     for ship in threats:
         if ship not in self.stunned_ships:
             ship.set_state("stunned")
             self.stunned_ships[ship] = True
Ejemplo n.º 5
0
 def update(self, planet, dt):
     self.fire_time += dt
     threats = planet.get_threats()
     if self.fire_time > self.FIRE_RATE and threats:
         self.fire_time = 0
         for i in range(planet.population):
             angle = random.random() * 6.2818
             b = bullet.Bullet(
                 planet.pos +
                 helper.from_angle(angle) * planet.get_radius(),
                 random.choice(threats),
                 planet,
                 vel=helper.from_angle(angle) * 20,
                 mods={
                     'homing': 1,
                     "damage_base": 3 * planet.planet_weapon_mul,
                     "color": PICO_WHITE,
                     "life": 5
                 })
             planet.scene.game_group.add(b)
Ejemplo n.º 6
0
 def update(self, planet, dt):
     if not self.indicator:
         self.indicator = RangeIndicator(planet.pos,
                                         self.RANGE,
                                         PICO_PINK,
                                         line_length=2,
                                         line_space=5)
         planet.scene.game_group.add(self.indicator)
         planet.selected_graphics.append(self.indicator)
     self.fire_time += dt
     threats = [
         o for o in planet.scene.get_enemy_objects(planet.owning_civ)
         if (o.pos - planet.pos).length_squared() < self.RANGE**2
         and o.health > 0 and not o.stealth
     ]
     if self.fire_time > self.FIRE_RATE and threats:
         self.fire_time = 0
         t = random.choice(threats)
         delta = t.pos - planet.pos
         _, angle = delta.as_polar()
         angle *= 3.14159 / 180
         angle += random.random() * 1.5 - 0.75
         b = bullet.Bullet(planet.pos +
                           helper.from_angle(angle) * planet.get_radius(),
                           t,
                           planet,
                           vel=helper.from_angle(angle) * 20,
                           mods={
                               'homing': 1,
                               "damage_base": 10 * planet.planet_weapon_mul,
                               "blast_radius": 10,
                               "color": PICO_WHITE,
                               "life": 5,
                               "missile_speed": 0.5
                           })
         planet.scene.game_group.add(b)