Mercurial > fife-parpg
comparison demos/rpg/scripts/scene.py @ 661:e3140f01749d
* Merged the light branch back into trunk.
* Modified the demos so they work with the new loaders and setting.
author | helios2000@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 05 Nov 2010 15:21:10 +0000 |
parents | 9152ed2b5bb8 |
children |
comparison
equal
deleted
inserted
replaced
660:b0733d998d0f | 661:e3140f01749d |
---|---|
25 | 25 |
26 import sys, os, re, math, random, shutil, uuid | 26 import sys, os, re, math, random, shutil, uuid |
27 | 27 |
28 from fife import fife | 28 from fife import fife |
29 from fife.extensions.loaders import loadMapFile | 29 from fife.extensions.loaders import loadMapFile |
30 from fife.extensions.loaders import loadImportFile | 30 from fife.extensions.serializers.xml_loader_tools import loadImportFile |
31 from fife.extensions.serializers.simplexml import SimpleXMLSerializer | 31 from fife.extensions.serializers.simplexml import SimpleXMLSerializer |
32 from fife.extensions.serializers.xmlobject import XMLObjectLoader | |
32 | 33 |
33 from scripts.actors.baseactor import Actor | 34 from scripts.actors.baseactor import Actor |
34 from scripts.actors.questgiver import QuestGiver | 35 from scripts.actors.questgiver import QuestGiver |
35 from scripts.quests.basequest import Quest, ReturnItemQuest, QuestTypes | 36 from scripts.quests.basequest import Quest, ReturnItemQuest, QuestTypes |
36 from scripts.actors.player import Player | 37 from scripts.actors.player import Player |
55 self._objectlist = {} | 56 self._objectlist = {} |
56 | 57 |
57 self._objectsettings = None | 58 self._objectsettings = None |
58 self._modelsettings = None | 59 self._modelsettings = None |
59 | 60 |
61 self.obj_loader = XMLObjectLoader( | |
62 gamecontroller.engine.getImagePool(), | |
63 gamecontroller.engine.getAnimationPool(), | |
64 gamecontroller.engine.getModel(), | |
65 gamecontroller.engine.getVFS() | |
66 ) | |
67 | |
60 def loadObject(self, objectname, objectid=None, valuedict=None): | 68 def loadObject(self, objectname, objectid=None, valuedict=None): |
61 if objectid: | 69 if objectid: |
62 identifier = objectid | 70 identifier = objectid |
63 else: | 71 else: |
64 identifier = str(uuid.uuid1()) | 72 identifier = str(uuid.uuid1()) |
65 | 73 |
66 try: | 74 try: |
67 objdict = self._modelsettings.get("objects", objectname, {}) | 75 objdict = self._modelsettings.get("objects", objectname, {}) |
68 modeldict = self._modelsettings.get("models", objdict["modelname"], {}) | 76 modeldict = self._modelsettings.get("models", objdict["modelname"], {}) |
69 | 77 |
70 loadImportFile(modeldict["file"], self._gamecontroller.engine) | 78 loadImportFile(self.obj_loader, modeldict["file"], self._gamecontroller.engine) |
71 | 79 |
72 if objdict["type"] == "GOLD": | 80 if objdict["type"] == "GOLD": |
73 newobject = GoldStack(self._gamecontroller, self.itemlayer, objdict["type"], objectname, modeldict["model"], identifier) | 81 newobject = GoldStack(self._gamecontroller, self.itemlayer, objdict["type"], objectname, modeldict["model"], identifier) |
74 elif objdict["type"] == "PORTAL": | 82 elif objdict["type"] == "PORTAL": |
75 newobject = Portal(self._gamecontroller, self.itemlayer, objdict["type"], objectname, modeldict["model"], identifier) | 83 newobject = Portal(self._gamecontroller, self.itemlayer, objdict["type"], objectname, modeldict["model"], identifier) |
112 """ | 120 """ |
113 @todo: once we have all art assets this should be able to load one of 3 player models | 121 @todo: once we have all art assets this should be able to load one of 3 player models |
114 """ | 122 """ |
115 modeldict = self._modelsettings.get("models", "Player", {}) | 123 modeldict = self._modelsettings.get("models", "Player", {}) |
116 | 124 |
117 loadImportFile(modeldict["file"], self._gamecontroller.engine) | 125 loadImportFile(self.obj_loader, modeldict["file"], self._gamecontroller.engine) |
118 self._player = Player(self._gamecontroller, self.actorlayer, "warrior") | 126 self._player = Player(self._gamecontroller, self.actorlayer, "warrior") |
119 | 127 |
120 playerfilename = os.path.join("saves", "player_save.xml") | 128 playerfilename = os.path.join("saves", "player_save.xml") |
121 | 129 |
122 if os.path.isfile(playerfilename): | 130 if os.path.isfile(playerfilename): |