Mercurial > parpg-source
comparison objects/action.py @ 44:98f26f7636d8
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 | 7b31de1dc964 |
children | d3a9caba067b |
comparison
equal
deleted
inserted
replaced
43:8f9e9f47c363 | 44:98f26f7636d8 |
---|---|
287 self.npc = npc | 287 self.npc = npc |
288 | 288 |
289 def execute(self): | 289 def execute(self): |
290 """Talk with the NPC when close enough, otherwise move closer. | 290 """Talk with the NPC when close enough, otherwise move closer. |
291 @return: None""" | 291 @return: None""" |
292 player_char = self.model.game_state.player_character | 292 player_char = self.model.game_state.getObjectById("PlayerCharacter").fifeagent |
293 npc_coordinates = self.npc.getLocation().getLayerCoordinates() | 293 npc_coordinates = self.npc.getLocation().getLayerCoordinates() |
294 pc_coordinates = player_char.behaviour.agent.\ | 294 pc_coordinates = player_char.behaviour.agent.\ |
295 getLocation().getLayerCoordinates() | 295 getLocation().getLayerCoordinates() |
296 | 296 |
297 distance_squared = (npc_coordinates.x - pc_coordinates.x) *\ | 297 distance_squared = (npc_coordinates.x - pc_coordinates.x) *\ |
318 self.controller.application.manager.push_mode(dialogue_controller) | 318 self.controller.application.manager.push_mode(dialogue_controller) |
319 dialogue_controller.startTalk(self.npc) | 319 dialogue_controller.startTalk(self.npc) |
320 else: | 320 else: |
321 self.npc.behaviour.agent.say("Leave me alone!", 1000) | 321 self.npc.behaviour.agent.say("Leave me alone!", 1000) |
322 | 322 |
323 self.model.game_state.player_character.behaviour.idle() | 323 self.model.game_state.getObjectById("PlayerCharacter").fifeagent.behaviour.idle() |
324 self.model.game_state.player_character.nextAction = None | 324 self.model.game_state.getObjectById("PlayerCharacter").fifeagent.nextAction = None |
325 super(TalkAction, self).execute() | 325 super(TalkAction, self).execute() |
326 | 326 |
327 class UseAction(Action): | 327 class UseAction(Action): |
328 """Action for carryable items. It executes special commands that can be only | 328 """Action for carryable items. It executes special commands that can be only |
329 used on carryable utens""" | 329 used on carryable utens""" |
367 self.view = controller.view | 367 self.view = controller.view |
368 | 368 |
369 def execute(self): | 369 def execute(self): |
370 real_item = self.map_item.item | 370 real_item = self.map_item.item |
371 self.model.deleteObject(self.map_item.ID) | 371 self.model.deleteObject(self.map_item.ID) |
372 self.model.game_state.player_character.\ | 372 self.model.game_state.getObjectById("PlayerCharacter").fifeagent.\ |
373 inventory.placeItem(real_item) | 373 inventory.placeItem(real_item) |
374 self.view.hud.inventory.updateInventoryButtons() | 374 self.view.hud.inventory.updateInventoryButtons() |
375 super(PickUpAction, self).execute() | 375 super(PickUpAction, self).execute() |
376 | 376 |
377 class DropItemAction(Action): | 377 class DropItemAction(Action): |
385 map_item_values = {} | 385 map_item_values = {} |
386 map_item_values["ViewName"] = self.item.name | 386 map_item_values["ViewName"] = self.item.name |
387 map_item_values["ObjectType"] = "MapItem" | 387 map_item_values["ObjectType"] = "MapItem" |
388 map_item_values["ItemType"] = self.item.item_type | 388 map_item_values["ItemType"] = self.item.item_type |
389 map_item_values["Map"] = map_name | 389 map_item_values["Map"] = map_name |
390 coords = self.model.game_state.player_character.\ | 390 coords = self.model.game_state.getObjectById("PlayerCharacter").fifeagent.\ |
391 getLocation().getExactLayerCoordinates() | 391 getLocation().getExactLayerCoordinates() |
392 map_item_values["Position"] = (coords.x, coords.y) | 392 map_item_values["Position"] = (coords.x, coords.y) |
393 map_item_values["Rotation"] = 0 | 393 map_item_values["Rotation"] = 0 |
394 map_item_values["item"] = self.item | 394 map_item_values["item"] = self.item |
395 agent = {} | 395 agent = {} |
422 has_water = False | 422 has_water = False |
423 has_yeast = False | 423 has_yeast = False |
424 has_fruit = False | 424 has_fruit = False |
425 has_wood = False | 425 has_wood = False |
426 has_bottle = False | 426 has_bottle = False |
427 player_character = self.model.game_state.player_character | 427 player_character = self.model.game_state.getObjectById("PlayerCharacter").fifeagent |
428 for item in self.pot.items.itervalues(): | 428 for item in self.pot.items.itervalues(): |
429 if item.item_type == "Questionable water": | 429 if item.item_type == "Questionable water": |
430 if has_water: | 430 if has_water: |
431 self.view.hud.addAction(unicode(\ | 431 self.view.hud.addAction(unicode(\ |
432 "Please put only 1 water in the pot")) | 432 "Please put only 1 water in the pot")) |