Changeset 197


Ignore:
Timestamp:
07/09/09 22:54:01 (10 years ago)
Author:
bretzel_parpg
Message:

Fixed examining and opening objects

Location:
trunk/PARPG/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/scripts/objects/actors.py

    r188 r197  
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717import fife 
     18from scripts import world 
    1819from base import * 
    1920 
     
    4647    def getY(self): 
    4748        """Get the NPC's y position on the map. 
    48            @rtype: integer 
     49s           @rtype: integer 
    4950           @return: the y coordinate of the NPC's location""" 
    5051        return self.agent.getLocation().getLayerCoordinates().y 
     
    6263        self.idlecounter = 1 
    6364        self.speed = float(TDS.readSetting("PCSpeed")) # TODO: rework/improve 
     65        self.nextAction = None 
     66        self.examineName = None 
     67        self.examineDesc = None 
    6468         
    6569    def onInstanceActionFinished(self, instance, action): 
     
    7175        if action.getId() == 'approachDoor': 
    7276            # issue map change 
    73             self.parent.engine.changeMap(self.targetMap, self.targetLocation) 
     77            self.engine.changeMap(self.targetMap, self.targetLocation) 
    7478        if self.state == _AGENT_STATE_TALK: 
    7579            # TODO: do something 
    7680            pass 
     81        if self.nextAction == "open_box": 
     82            self.engine.view.createBoxGUI() 
     83            self.nextAction = None 
     84        elif self.nextAction == "examine_obj": 
     85            self.engine.view.createExamineBox(self.examineName, self.examineDesc) 
     86            self.nextAction = None 
     87 
    7788        self.idle() 
    7889        if(action.getId() != 'stand'): 
     
    124135        self.state = _AGENT_STATE_RUN 
    125136        self.behaviour.agent.move('run', location, self.behaviour.speed) 
    126  
     137         
    127138    def approachNPC(self, npcLoc): 
    128139        """Approaches an npc and then ???. 
     
    167178        l.setLayerCoordinates(fife.ModelCoordinate(*boxLocation)) 
    168179        self.behaviour.agent.move('run', l, self.behaviour.speed) 
    169         self.atBox = True 
     180        self.behaviour.nextAction = "open_box" 
     181 
     182    def approachAndExamine(self, location, name, description): 
     183        """ 
     184        Approach something and then examine it 
     185        @type location: list 
     186        @param location: list that is converted to fife.Location 
     187        @type name: string 
     188        @param name: The name of the object 
     189        @type description: string 
     190        @param description: a detailed description of the object 
     191        @return: None 
     192        """ 
     193        self.state = _STATE_RUN 
     194        objLocation = tuple([int(float(i)) for i in location]) 
     195        l = fife.Location(self.agent.getLocation()) 
     196        l.setLayerCoordinates(fife.ModelCoordinate(*objLocation)) 
     197        self.behaviour.nextAction = "examine_obj" 
     198        self.behaviour.examineName = name 
     199        self.behaviour.examineDesc = description 
     200        self.behaviour.agent.move('run', l, self.speed) 
    170201 
    171202class NPCBehaviour(ActorBehaviour): 
  • trunk/PARPG/scripts/world.py

    r189 r197  
    416416        if ((self.boxCreated == True) and (self.boxOpen == False)): 
    417417            # if it has already been created, just show it 
     418            print 'show' 
    418419            self.box_container.showContainer() 
    419420            self.boxOpen = True 
    420421        else: 
     422            print 'create' 
    421423            # otherwise create it then show it 
    422             self.box_container = ContainerGUI(self.engine, unicode("Box"), "gui/inv_images/inv_backpack.png") 
     424            self.box_container = ContainerGUI(self.engine, unicode("Box"), "dagger01") 
    423425            def close_and_delete(): 
    424426                self.box_container.hideContainer() 
Note: See TracChangeset for help on using the changeset viewer.