def activate(self, party_avatar, direction): if not self.scheduled_movement: print 'Grabbed and pulled rock' pulling_direction = inverse(direction) party_avatar.schedule_movement(Slide(pulling_direction, back=True), override=True) self.schedule_movement(Slide(pulling_direction), override=True)
def activate(self, party_avatar, direction): print 'Activated NPC' for _ in xrange(2): step = Step(inverse(direction), back=True) party_avatar.schedule_movement(step) dialog = MessageDialog(u"Ouch!", block_movement=True) dialog.sync_open() dialog = MessageDialog(u"Hey, why are you hitting me?", block_movement=True) dialog.sync_open() def on_choice(user_data, choice): map = user_data msg = MessageDialog('on_choice got %d' % (choice + 1)) map.schedule_message(msg) dialog = ChoiceDialog(u"Choose NOW:", ["Choice 1", "Choice 2", "Choice 3", "Choice 4"], user_data=self.map, completion_callback=on_choice, block_movement=True) dialog.sync_open() dialog = MessageDialog(u"Chose %d" % (dialog.result + 1), block_movement=True) dialog.sync_open() movement = PathMovement(self.map, party_avatar, Position(9, 4)) party_avatar.schedule_movement(movement)
def is_obstructed(self, old_terrain, old_scenario_list, new_terrain, new_scenario_list, new_object, direction): if new_object.obstacle is not None: return True if self.direction_obstructed(old_terrain, old_scenario_list, \ direction): return True inv = inverse(direction) if self.direction_obstructed(new_terrain, new_scenario_list, inv): return True return False
def try_to_move_object(self, obj, direction, slide=False, back=False): """ Try to move an object to the specified direction (UP, DOWN, LEFT or RIGHT). Return whether the object could be moved. If *slide* is True, the movement will use only the static frame of the object. If *back* is True, the movement will be backwards. """ if obj.movement_phase > 0: return False if back: obj.facing = inverse(direction) else: obj.facing = direction old_pos = obj.position desired = obj.position.step(direction) if not self.terrain_layer.valid(desired): return False if not obj.is_obstacle() or self.can_move(old_pos, desired, direction): # Move old_object = self.object_layer[old_pos] new_object = self.object_layer[desired] self.move_object(obj, old_object, new_object, desired, slide, back) if obj is self.party_avatar: for area in self.area_layer[old_pos]: if area not in self.area_layer[desired]: area.party_left(self.party_avatar, old_pos) return True else: # Do not move, something is on the way new_object = self.object_layer[desired] if obj is self.party_avatar and new_object.obstacle is not None: new_object.obstacle.collide_with_party(self.party_avatar, direction) return False
def activate(self, party_avatar, direction): print 'Activated rock' for _ in xrange(3): self.schedule_movement(Step(direction)) self.schedule_movement(Face(inverse(direction)))