示例#1
0
    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)
                            )
示例#2
0
    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)
                    )