def unpause(): global to_release for u in to_release: env.unbind_keys_for_unit(u) level.player.release_unit(u) to_release = [] gui.state_goer(1)()
def release(self): try: for unit in self.gluebody.units: if hasattr(unit, 'update_patients'): unit.patients = [unit] except: if hasattr(self, 'patients'): self.patients = [self] env.unbind_keys_for_unit(self)
def on_key_press(self, symbol, modifiers): if symbol == key.ESCAPE: return True if self.mode != PLAYING: return if symbol == key.Z: if len(level.player.units) > 5: dead_unit = level.player.units[-1] env.unbind_keys_for_unit(dead_unit) level.player.release_unit(dead_unit) else: for u in env.key_bindings[symbol]: u.activate()
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)