def mousePressed(self, event): player = self.gamecontroller.application.world.get_entity("PlayerCharacter") if event.getButton() == fife.MouseEvent.LEFT: scr_point = self.gamecontroller.application.screen_coords_to_map_coords( (event.getX(), event.getY()), "actors" ) fifeagent.run(player, scr_point)
def mousePressed(self, event):#pylint: disable=W0221 application = self.gamecontroller.application player = application.world.get_or_create_entity("PlayerCharacter") if event.getButton() == fife.MouseEvent.LEFT: scr_point = application.screen_coords_to_map_coords( fife.ScreenPoint(event.getX(), event.getY()), "actors" ) fifeagent.run(player, scr_point) print player.Agent.position elif event.getButton() == fife.MouseEvent.RIGHT: if application.language == "en": application.language = "de" else: application.language = "en" world = application.world game_map = application.current_map if game_map: pt = fife.ScreenPoint(event.getX(), event.getY()) actor_instances = game_map.get_instances_at( pt, game_map.get_layer("actors")) if actor_instances: for actor in actor_instances: identifier = actor.getId() if identifier == "PlayerCharacter": continue entity = world.get_entity(identifier) possible_actions = ActionManager.get_possible_actions( player, entity) actions = {} for name, action in possible_actions.iteritems(): actions[name] = action(application, player, entity) print actions[name].menu_text if actions.has_key("MoveAgent"): fifeagent.approach_and_execute(player, entity, callback=lambda: actions["MoveAgent"].execute() ) elif actions.has_key("Read"): fifeagent.approach_and_execute(player, entity, callback=lambda: player.FifeAgent.instance.say( actions["Read"].execute(), 2000) ) elif actions.has_key("Look"): fifeagent.approach_and_execute(player, entity, callback=lambda: player.FifeAgent.instance.say( actions["Look"].execute(), 2000) )
def main(): app = RPGApplication(settings) app.load_components("combined.yaml") app.load_behaviours("combined.yaml") app.register_components() app.register_behaviours() view = GameSceneView(app) controller = GameSceneController(view, app, listener=Listener(app.engine)) app.create_world() app.load_maps() world = app.world world.import_agent_objects() world.load_and_create_entities() app.switch_map("Level1") player = world.get_entity("PlayerCharacter") fifeagent.run(player, (0, 7)) app.push_mode(controller) app.run()
def mousePressed(self, event): application = self.gamecontroller.application player = application.world.get_entity("PlayerCharacter") if event.getButton() == fife.MouseEvent.LEFT: map_point = application.screen_coords_to_map_coords( (event.getX(), event.getY()), "actors" ) fifeagent.run(player, map_point) elif event.getButton() == fife.MouseEvent.RIGHT: game_map = application.current_map if game_map: scr_point = fife.ScreenPoint(event.getX(), event.getY()) actor_instances = game_map.get_instances_at( scr_point, game_map.get_layer("actors") ) else: actor_instances = () for actor in actor_instances: identifier = actor.getId() outliner = self.gamecontroller.outliner if identifier in outliner.outline_ignore: continue entity = application.world.get_entity(identifier) possible_actions = ActionManager.get_possible_actions( player, entity) actions = {} for name, action in possible_actions.iteritems(): actions[name] = action(application, player, entity) if actions.has_key("Look"): fifeagent.approach_and_execute(player, entity, callback=lambda: player.FifeAgent.instance.say( actions["Look"].execute(), 2000) )