Пример #1
0
 def update_physics(self):
     if self.unit.health <= 0:
         physics.body_update_list.remove(self)
         self.unit.die()
         physics.space.remove(self.body)
         sound.play(resources.expl_medium)
         particle.new_explosion(self.unit.x, self.unit.y)
         self.unit = None
         self.obj_id = 0
Пример #2
0
 def detonate(self):        
     for body in physics.body_update_list:
         if hasattr(body, 'x'):
             if self.in_range(body.x, body.y):
                 if hasattr(body, 'explode'):
                     body.explode()
                 if hasattr(body, 'health'):
                     body.health -= physics.default_damage*5
     for unit in physics.unit_update_list:
         if hasattr(unit, 'health') and  self.in_range(unit.x, unit.y):
                 unit.health -= physics.default_damage*5
     sound.play(resources.expl_huge)                
     sound.play(resources.expl_large)
     particle.new_explosion(self.x, self.y, 40, 200, 50, 200)
     self.health = 0
     physics.update_bodies_now = True
     self.ignore_death = True
     event.quake()
Пример #3
0
 def check_death(self):
     remove_list = []
     for unit in self.units:
         if unit.health <= 0:
             for unit2 in self.units:
                 if unit2.parent_unit == unit:
                     self.release_unit(unit2)
             unit.deactivate()
             physics.update_bodies_now = True
             env.unbind_keys_for_unit(unit)
             unit.die()
             remove_list.append(unit)
             sound.play(resources.expl_medium)
             particle.new_explosion(
                 unit.x, unit.y, 
                 int(30*unit.explosion_size),
                 int(150*unit.explosion_size),
                 int(15*unit.explosion_size)
             )
     
     if self.units[0] in remove_list:
         for unit in self.units:
             unit.health = 0
             if unit.x != 0 or unit.y != 0:
                 particle.new_explosion(unit.x, unit.y)
      
     if len(remove_list) > 0: 
         for unit in remove_list:
             self.units.remove(unit)
         self.update_center_of_mass()
         
     if len(self.units) == 0:
         physics.body_update_list.remove(self)
         physics.space.remove(self.body)
         if self == level.player:
             level.restart_countdown = 3.0
             level.player = None
             sound.play(resources.expl_large)
Пример #4
0
 def update_physics(self):
     if not self.alive: return
     if self.should_dislodge and self.health > 0: self.dislodge()
     if self.health <= 0:
         physics.update_bodies_now = True
         try:
             physics.body_update_list.remove(self)
         except:
             print 'Attempted update remove in turret, was already gone.'
             return
         physics.space.remove(self.circle)
         physics.space.remove(self.segment)
         sound.play(resources.expl_medium)
         particle.new_explosion(self.x, self.y)
         if event.destroy_funcs.has_key(self.obj_id):
             for func in event.destroy_funcs[self.obj_id]:
                 result = func()
         if self.base_sprite != None:
             decal.decals.append(
                 decal.Decal(self.base_sprite.image, self.x, self.y, self.base_sprite.rotation)
             )
             self.base_sprite.delete()
         self.visible = False
         self.alive = False