Ignore:
Timestamp:
06/13/09 04:28:48 (10 years ago)
Author:
maximinus_parpg
Message:

Added meggies map changing code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/scripts/engine.py

    r122 r128  
    2020from agents.npc import NPC 
    2121from objects import GameObject 
     22from tele_tiles import TeleTile 
    2223from objLoader import LocalXMLParser 
    2324 
     
    4546        self.npcs = [] 
    4647        self.objects = [] 
     48        self.tele_tiles = [] 
     49 
     50    def reset(self): 
     51        """Clears the data on a map reload so we don't have objects/npcs from 
     52           other maps hanging around. Right now I'm clearing the PC, but we'll 
     53           have to evaluate that when we get more details on how the stepping  
     54           on tiles works.""" 
     55        self.PC = None 
     56        self.npcs = [] 
     57        self.objects = [] 
     58        self.tele_tiles = [] 
    4759 
    4860    def loadObjects(self, filename): 
     
    6880        self.addNPCs(cur_handler.npcs) 
    6981        self.addObjects(cur_handler.objects) 
     82        self.addTeleTiles(cur_handler.tele_tiles) 
    7083        return True 
    7184 
     
    97110            self.npcs.append(NPC(i[4], str(i[3]), self.view.agent_layer)) 
    98111            self.npcs[-1].start() 
     112 
     113    def addTeleTiles(self, tiles): 
     114        """Add all of the teleportation tiles we found into this class""" 
     115        # we want to use the ground layer for now 
     116        layer = self.view.map.getLayer('GroundLayer') 
     117        for i in tiles: 
     118            self.tele_tiles.append(TeleTile(i[0], i[1], i[2], layer)) 
    99119 
    100120    def objectActive(self, ident): 
     
    142162        self.view.load(map_file) 
    143163        # then we update FIFE with the PC, NPC and object details 
     164        self.reset() 
    144165        self.loadObjects(map_file[:-4]+"_objects.xml") 
     166 
     167    def checkTeleTiles(self, location): 
     168        """Iterates through the possible teleportation tiles to see if the  
     169            given location is a teleportation tile 
     170        @param location: a fife.Location to check against the tiles 
     171        @return: the TeleTile if a tile is matched or False""" 
     172        for tile in self.tele_tiles: 
     173            if tile.matchLocation(location): 
     174                return tile 
     175        return False 
    145176 
    146177    def handleMouseClick(self,position): 
Note: See TracChangeset for help on using the changeset viewer.