Пример #1
0
 def start():
     sound.play(resources.whoosh_1)
     level.change_entry_point(d, n)
     if settings.first_launch:
         gui.change_to_card(Card(gui.instruction_widgets_first()))
     else:
         gui.state_goer(gui.START)()
Пример #2
0
 def collide_player_free(self, a, b, contacts, normal_coef, data):
     return_val = True
     self.collided_last.append(b)
     if (self.keys[key.LSHIFT] or b.parent.auto_attach) and b.parent.gluebody.attachable and b == b.parent.circle:
         a.parent.gluebody.acquire_singlebody(b.parent.gluebody, a.parent)
         if b.parent.ask_key or (
             b.parent.__class__.__name__ not in event.instructions_seen and b.parent.instruction_image != None
         ):
             if self.mode == CHOOSE_KEY:
                 return True
             self.mode = CHOOSE_KEY
             keychooser.screenshot = pyglet.image.get_buffer_manager().get_color_buffer().get_texture()
             if b.parent.ask_key:
                 keychooser.unit_to_bind = b.parent
                 gui.current_card = gui.Card(keychooser.widgets(b.parent.instruction_image))
             else:
                 gui.current_card = gui.Card(keychooser.instr_widgets(b.parent.instruction_image))
                 event.instructions_seen.append(b.parent.__class__.__name__)
             gui.next_card = None
             gui.last_card = RETURN_FROM_CHOOSE
             gui.transition_time = 0
             gui.push_handlers()
             for u in physics.unit_update_list:
                 if u.uses_keys:
                     u.deactivate()
         sound.play(resources.big_metal_clank2)
     else:
         self.play_metal_collision(a, b)
         if hasattr(b, "obj_id"):
             if b.obj_id in event.collision_funcs.keys():
                 for func in event.collision_funcs[b.obj_id]:
                     result = func()
                     if result == False:
                         return_val = False
     return return_val
Пример #3
0
 def activate(self):
     self.active = True
     if self.using_sound:
         self.sound_player.volume = settings.sound_volume
         if self.loop_sound:
             self.sound_player.play()
         else:
             sound.play(self.sound)
Пример #4
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
Пример #5
0
 def open(self, fast=False):
     if fast and self.physically_closed:
         physics.space.remove_static([self.segment])
         self.physically_closed = False
     if self.closed:
         self.closed = False
         if fast:
             self.image = mappings.door_types[self.key]["open_static"]
         else:
             self.image = mappings.door_types[self.key]["open_anim"]
             sound.play(mappings.door_types[self.key]["sound"])
             self.swap_countdown = mappings.door_types[self.key]["collision_delay_open"]
Пример #6
0
 def close(self, fast=False):
     if fast and not self.physically_closed:
         physics.space.add_static(self.segment)
         self.physically_closed = True
     if not self.closed:
         self.closed = True
         if fast:
             self.image = mappings.door_types[self.key]["closed_static"]
         else:
             self.image = mappings.door_types[self.key]["close_anim"]
             sound.play(mappings.door_types[self.key]["sound"])
             self.swap_countdown = mappings.door_types[self.key]["collision_delay_close"]
Пример #7
0
 def play_metal_collision(self, a=None, b=None):
     a = a.parent.gluebody.body.velocity
     b = b.parent
     if hasattr(b, "gluebody"):
         b = b.gluebody
     if hasattr(b, "body"):
         b = b.body.velocity
     dx = a.x - b.x
     dy = a.y - b.y
     speed_sq = dx * dx + dy * dy
     if speed_sq > 100 * 100 and self.collide_sound_delay <= 0:
         sound.play(resources.big_metal_clank4)
         self.collide_sound_delay = 10
Пример #8
0
 def dislodge(self):
     physics.space.remove(self.circle)
     physics.space.remove(self.segment)
     physics.body_update_list.remove(self)
     self.alive = False
     unit_class = getattr(unit, self.__class__.__name__)
     new_obj = level.add_free_object(
         unit_class, self.x, self.y, -self.rotation, self.obj_id
     )
     new_obj.health = new_obj.health_full*0.2
     sound.play(resources.turret_rip)
     if event.destroy_funcs.has_key(self.obj_id):
         for func in event.destroy_funcs[self.obj_id]:
             result = func()
     self.delete()
Пример #9
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()
Пример #10
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)
Пример #11
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
Пример #12
0
 def collide_bullet_with_sound(self, a, b, *args, **kwargs):
     sound.play(resources.expl_tiny)
     return self.collide_bullet_silent(a, b, *args, **kwargs)
Пример #13
0
 def play_wall_collision(self, a=None, b=None):
     a = a.parent.gluebody.body.velocity
     speed_sq = a.x * a.x + a.y * a.y
     if speed_sq > 130 * 130 and self.collide_sound_delay <= 0:
         sound.play(resources.wall_sound)
         self.collide_sound_delay = 10
Пример #14
0
 def fire(self):
     super(NormalTurretA, self).fire()
     sound.play(resources.laser_3)
Пример #15
0
 def fire(self):
     fired = super(NormalTurretA, self).spawn_bullet()
     if fired: sound.play(resources.laser_3)