Mercurial > parpg-core
diff src/parpg/gamemodel.py @ 69:ad75fa042b99
Changes to make PARPG "runable" with grease. (With the correct modified assets)
author | KarstenBock@gmx.net |
---|---|
date | Tue, 06 Sep 2011 15:22:51 +0200 |
parents | 96af64cf3b81 |
children | 58661f5b2f6b |
line wrap: on
line diff
--- a/src/parpg/gamemodel.py Tue Sep 06 15:21:36 2011 +0200 +++ b/src/parpg/gamemodel.py Tue Sep 06 15:22:51 2011 +0200 @@ -237,7 +237,7 @@ agent_dict = self.agents["All"][agent] agent_obj = None if agent == "PlayerCharacter": - agent_obj = self.game_state.player_character + agent_obj = self.game_state.getObjectById("PlayerCharacter").fifeagent else: agent_obj = self.game_state.getObjectById(agent, map_name) if agent_obj: @@ -521,17 +521,20 @@ inst_dict["target_x"] = agent["TargetPosition"][0] inst_dict["target_y"] = agent["TargetPosition"][1] if agent.has_key("Inventory"): - inventory = Inventory() - inventory_objs = agent["Inventory"] - for inventory_obj in inventory_objs: - self.createInventoryObject(inventory, - inventory_obj - ) - inst_dict["inventory"] = inventory + #TODO: Fix setting of inventory + #inventory = Inventory() + #inventory_objs = agent["Inventory"] + #for inventory_obj in inventory_objs: + # self.createInventoryObject(inventory, + # inventory_obj + # ) + #inst_dict["inventory"] = inventory + pass if agent.has_key("Items"): container_objs = agent["Items"] - items = self.createContainerItems(container_objs) + #TODO: Create inventory items + items = []#self.createContainerItems(container_objs) inst_dict["items"] = items if agent.has_key("ItemType"): @@ -539,7 +542,7 @@ item_data = {} item_data["type"] = agent["ItemType"] item_data["ID"] = inst_id - item_data = self.createContainerObject(item_data) + #TODO item_data = self.createContainerObject(item_data) else: item_data = agent["item"] inst_dict["item"] = item_data @@ -565,17 +568,17 @@ continue self.createAgent(agents[agent], agent, world) - def placePC(self): + def placePC(self, world): """Places the PlayerCharacter on the map""" agent = self.agents[self.ALL_AGENTS_KEY]["PlayerCharacter"] inst_id = "PlayerCharacter" - self.createAgent(agent, inst_id) + self.createAgent(agent, inst_id, world) # create the PlayerCharacter agent self.active_map.addPC() - self.game_state.player_character.start() + #self.game_state.getObjectById("PlayerCharacter").fifeagent.start() if agent.has_key("PeopleKnown"): - self.game_state.player_character.people_i_know = agent["PeopleKnown"] + self.game_state.getObjectById("PlayerCharacter").fifeagent.people_i_know = agent["PeopleKnown"] def changeMap(self, map_name, target_position = None): """Registers for a map change on the next pump(). @@ -630,12 +633,10 @@ extra['layer'] = layer attributes = self.checkAttributes(attributes) + obj_type = attributes["type"] obj = createEntity(attributes, extra) - - if obj.trueAttr("PC"): - self.addPC(layer, obj) - else: - self.addObject(layer, obj) + if obj: + self.addObject(layer, obj, obj_type) def addPC(self, layer, player_char): """Add the PlayerCharacter to the map @@ -649,12 +650,12 @@ # For now we copy the PlayerCharacter, # in the future we will need to copy # PlayerCharacter specifics between the different PlayerCharacter's - self.game_state.player_character = player_char - self.game_state.player_character.setup() - self.game_state.player_character.behaviour.speed = self.settings.parpg.PCSpeed + self.game_state.getObjectById("PlayerCharacter").fifeagent = player_char + self.game_state.getObjectById("PlayerCharacter").fifeagent.setup() + self.game_state.getObjectById("PlayerCharacter").fifeagent.behaviour.speed = self.settings.parpg.PCSpeed - def addObject(self, layer, obj): + def addObject(self, layer, obj, obj_type): """Adds an object to the map. @type layer: fife.Layer @param layer: FIFE layer object exists in @@ -663,26 +664,27 @@ @type instance: fife.Instance @param instance: FIFE instance of object @return: None""" - ref = self.game_state.getObjectById(obj.ID, \ + ref = self.game_state.getObjectById(obj.fifeagent.identifier, self.game_state.current_map_name) if ref is None: # no, add it to the game state self.game_state.addObject(self.game_state.current_map_name, obj) else: # yes, use the current game state data - obj.X = ref.X - obj.Y = ref.Y - obj.gfx = ref.gfx + obj.fifeagent.pos.X = ref.X + obj.fifeagent.pos.Y = ref.Y + obj.fifeagent.gfx = ref.gfx - if obj.trueAttr("NPC"): + if obj_type == "Character": + obj.fifeagent.behaviour.parent = obj # create the agent - obj.setup() - obj.behaviour.speed = self.settings.parpg.PCSpeed - 1 + #obj.setup() + #obj.behaviour.speed = self.settings.parpg.PCSpeed # create the PlayerCharacter agent - obj.start() - if obj.trueAttr("AnimatedContainer"): + #obj.start() + #if obj.trueAttr("AnimatedContainer"): # create the agent - obj.setup() + #obj.setup() def objectActive(self, ident): """Given the objects ID, pass back the object if it is active, @@ -693,7 +695,7 @@ @return: Status of result (True/False)""" for game_object in \ self.game_state.getObjectsFromMap(self.game_state.current_map_name): - if (game_object.ID == ident): + if (game_object.fifeagent.identifier == ident): # we found a match return game_object # no match @@ -705,9 +707,9 @@ @param position: Screen position to move to @return: None""" if(self.pc_run == 1): - self.game_state.player_character.run(position) + self.game_state.getObjectById("PlayerCharacter").fifeagent.run(position) else: - self.game_state.player_character.walk(position) + self.game_state.getObjectById("PlayerCharacter").fifeagent.walk(position) def teleportAgent(self, agent, position): """Code called when an agent should teleport to another location