Mercurial > fife-parpg
annotate demos/rpg/scripts/scene.py @ 540:2e739ae9a8bc
Some misc code cleanup.
Added the EnterPortalAction action.
You can now move between town and level1.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 01 Jun 2010 19:17:30 +0000 |
parents | 764510a6d2f9 |
children | 67f6f3538e88 |
rev | line source |
---|---|
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 #!/usr/bin/env python |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # -*- coding: utf-8 -*- |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # #################################################################### |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # Copyright (C) 2005-2010 by the FIFE team |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # http://www.fifengine.net |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # This file is part of FIFE. |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # FIFE is free software; you can redistribute it and/or |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # modify it under the terms of the GNU Lesser General Public |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # License as published by the Free Software Foundation; either |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # version 2.1 of the License, or (at your option) any later version. |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # This library is distributed in the hope that it will be useful, |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # Lesser General Public License for more details. |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # You should have received a copy of the GNU Lesser General Public |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # License along with this library; if not, write to the |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # Free Software Foundation, Inc., |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 # #################################################################### |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 # This is the rio de hola client for FIFE. |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 import sys, os, re, math, random, shutil |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 from fife import fife |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 from fife.extensions.loaders import loadMapFile |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
31 from fife.extensions.loaders import loadImportFile |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
519
diff
changeset
|
32 from fife.extensions.fife_settings import Setting |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 |
518
e4cd18a179af
Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
516
diff
changeset
|
34 from scripts.actors.baseactor import Actor |
534
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
531
diff
changeset
|
35 from scripts.actors.questgiver import QuestGiver |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
531
diff
changeset
|
36 from scripts.quests.basequest import Quest |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
37 from scripts.actors.player import Player |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
519
diff
changeset
|
38 from scripts.objects.baseobject import GameObjectTypes |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
39 from scripts.objects.items import BaseItem, GoldStack, Portal |
536
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
40 from scripts.misc.exceptions import ObjectNotFoundError, ObjectAlreadyInSceneError |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
41 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 class Scene(object): |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 def __init__(self, gamecontroller): |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 self._gamecontroller = gamecontroller |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 self._map = None |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
47 self._mapname = None |
516
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
48 self._maincameraname = self._gamecontroller.settings.get("RPG", "DefaultCameraName", "camera1") |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 self._cameras = {} |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
51 self._actorlayer = None |
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
52 |
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
53 self._player = None |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
519
diff
changeset
|
54 self._objectlist = {} |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
55 |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
56 self._objectsettings = None |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
57 self._modelsettings = None |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
58 |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
59 def loadItem(self, itemid): |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
60 try: |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
61 itemdict = self._objectsettings.get("items", itemid, {}) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
62 modeldict = self._modelsettings.get("models", itemdict["typename"], {}) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
63 |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
64 loadImportFile(modeldict["file"], self._gamecontroller.engine) |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
65 |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
66 if modeldict["type"] == "GOLD": |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
67 newitem = GoldStack(self._gamecontroller, modeldict["model"], itemid) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
68 newitem.value = itemdict["value"] |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
69 elif modeldict["type"] == "PORTAL": |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
70 print "portal" |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
71 newitem = Portal(self._gamecontroller, modeldict["model"], itemid) |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
72 newitem.dest = itemdict["dest"] |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
73 else: |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
74 newitem = BaseItem(self._gamecontroller, modeldict["model"], itemid) |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
75 |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
76 newitem.setMapPosition(float(itemdict["posx"]), float(itemdict["posy"])) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
77 |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
78 except KeyError, e: |
536
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
79 raise ObjectNotFoundError |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
80 |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
81 return newitem |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
82 |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
83 def loadActor(self, actorid): |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
84 try: |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
85 objdict = self._objectsettings.get("npcs", actorid, {}) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
86 modeldict = self._modelsettings.get("models", objdict["typename"], {}) |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
87 |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
88 loadImportFile(modeldict["file"], self._gamecontroller.engine) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
89 |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
90 if modeldict["type"] == "QUESTGIVER": |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
91 actor = QuestGiver(self._gamecontroller, modeldict["model"], actorid, True) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
92 questcount = self._modelsettings.get(actorid, "questcount", 0) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
93 for x in range(1,questcount+1): |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
94 quest = "quest" + str(x) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
95 questdict = self._modelsettings.get(actorid, quest, {}) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
96 quest = Quest(actor, questdict['name'], questdict['desc']) |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
97 |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
98 for ritem in questdict['items'].split(" , "): |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
99 if ritem == "GoldStack": |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
100 quest.addRequiredGold(int(questdict['value'])) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
101 else: |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
102 quest.addRequiredItem(ritem) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
103 |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
104 actor.addQuest(quest) |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
105 |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
106 elif modeldict["type"] == "NPC": |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
107 actor = Actor(self._gamecontroller, modeldict["model"], npc, True) |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
108 |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
109 actor.setMapPosition(float(objdict["posx"]), float(objdict["posy"])) |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
110 |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
111 except KeyError, e: |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
112 raise ObjectNotFoundError |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
113 |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
114 return actor |
524
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
523
diff
changeset
|
115 |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
116 def loadItems(self, mapfilename): |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
117 for item in self._objectsettings.get("items", "itemlist", []): |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
118 try: |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
119 newitem = self.loadItem(item) |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
120 self._gamecontroller.logger.log_debug("Loaded item: " + item) |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
121 except ObjectNotFoundError, e: |
536
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
122 self._gamecontroller.logger.log_error("Error while loading item: " + item) |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
123 continue |
536
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
124 |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
125 try: |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
126 self.addObjectToScene(newitem) |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
127 except ObjectAlreadyInSceneError, e: |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
128 self._gamecontroller.logger.log_error("Item already part of scene: " + newitem) |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
129 |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
130 def loadActors(self, mapfilename): |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
131 for npc in self._objectsettings.get("npcs", "npclist", []): |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
132 try: |
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
133 actor = self.loadActor(npc) |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
134 self._gamecontroller.logger.log_debug("Loaded actor: " + npc) |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
135 except ObjectNotFoundError, e: |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
136 self._gamecontroller.logger.log_error("Error while loading actor:" + npc) |
535
9fbe3dce925a
Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
137 continue |
536
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
138 |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
139 try: |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
140 self.addObjectToScene(actor) |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
141 except ObjectAlreadyInSceneError, e: |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
142 self._gamecontroller.logger.log_error("Actor already part of scene:" + actor) |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
143 |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
144 def loadPlayer(self): |
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
145 """ |
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
146 @todo: once we have all art assets this should be able to load one of 3 player models |
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
147 """ |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
148 modeldict = self._modelsettings.get("models", "Player", {}) |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
149 |
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
150 loadImportFile(modeldict["file"], self._gamecontroller.engine) |
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
151 self._player = Player(self._gamecontroller, "warrior") |
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
152 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
153 def createScene(self, mapfilename): |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
154 if self._map: |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
155 self.destroyScene() |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
156 |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
157 self._map = loadMapFile(mapfilename, self._gamecontroller.engine) |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
158 |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
159 self._mapname = os.path.splitext(os.path.basename(mapfilename))[0] |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
160 objectfile = "maps/" + self._mapname + "_objects.xml" |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
161 modelfile = self._gamecontroller.settings.get("RPG", "AllObjectFile", "maps/allobjects.xml") |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
162 |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
163 self._objectsettings = Setting(app_name="",settings_file=objectfile) |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
164 self._modelsettings = Setting(app_name="", settings_file=modelfile) |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
165 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
166 for cam in self._map.getCameras(): |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
167 self._cameras[cam.getId()] = cam |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
168 |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
169 self._cameras[self._maincameraname].setZoom(self._gamecontroller.settings.get("RPG", "DefaultZoom", 1.0)) |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
170 |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
171 self._actorlayer = self._map.getLayer(self._gamecontroller.settings.get("RPG", "ActorLayer", "actor_layer")) |
524
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
523
diff
changeset
|
172 self._itemlayer = self._map.getLayer(self._gamecontroller.settings.get("RPG", "ItemLayer", "item_layer")) |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
173 |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
174 self.loadItems(mapfilename) |
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
175 self.loadActors(mapfilename) |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
519
diff
changeset
|
176 |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
177 #finally load the player |
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
178 self.loadPlayer() |
518
e4cd18a179af
Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
516
diff
changeset
|
179 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
180 def destroyScene(self): |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
519
diff
changeset
|
181 for obj in self._objectlist.values(): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
519
diff
changeset
|
182 obj.destroy() |
518
e4cd18a179af
Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
516
diff
changeset
|
183 |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
184 self._objectlist.clear() |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
185 self._objectlist = {} |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
186 self._cameras.clear() |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
187 self._cameras = {} |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
188 |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
189 self._player.destroy() |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
190 self._player = None |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
191 |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
192 for cam in self._map.getCameras(): |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
193 cam.resetRenderers() |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
194 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
195 if self._map: |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
196 self._gamecontroller.engine.getModel().deleteMap(self._map) |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
197 |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
537
diff
changeset
|
198 retval = self._gamecontroller.engine.getModel().deleteObjects() |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
199 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
200 self._map = None |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
201 self._mapname = None |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
202 |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
203 self._actorlayer = None |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
204 self._itemlayer = None |
516
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
205 |
530
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
206 self._objectsettings = None |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
207 self._modelsettings = None |
ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
208 |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
209 def getInstancesAt(self, clickpoint, layer): |
516
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
210 """ |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
211 Query the main camera for instances on the specified layer. |
516
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
212 """ |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
213 return self.cameras[self._maincameraname].getMatchingInstances(clickpoint, layer) |
516
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
214 |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
215 def getLocationAt(self, clickpoint): |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
216 """ |
519
14f777be6b94
Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
518
diff
changeset
|
217 Query the main camera for the Map location (on the actor layer) |
516
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
218 that a screen point refers to. |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
219 """ |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
220 target_mapcoord = self._cameras[self._maincameraname].toMapCoordinates(clickpoint, False) |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
221 target_mapcoord.z = 0 |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
222 location = fife.Location(self._actorlayer) |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
223 location.setMapCoordinates(target_mapcoord) |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
224 return location |
529
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
225 |
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
226 def addObjectToScene(self, obj): |
531
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
227 if not self._objectlist.has_key(obj.id): |
801746c5bb9a
Added the spawn console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
530
diff
changeset
|
228 self._objectlist[obj.id] = obj |
536
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
229 else: |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
230 obj.destroy() |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
535
diff
changeset
|
231 raise ObjectAlreadyInSceneError |
537
764510a6d2f9
Added the move command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
232 |
764510a6d2f9
Added the move command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
233 def getObject(self, objid): |
764510a6d2f9
Added the move command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
234 if self._objectlist.has_key(objid): |
764510a6d2f9
Added the move command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
235 return self._objectlist[objid] |
764510a6d2f9
Added the move command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
236 else: |
764510a6d2f9
Added the move command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
536
diff
changeset
|
237 return None |
529
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
238 |
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
239 def removeObjectFromScene(self, obj): |
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
240 obj.destroy() |
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
241 del self._objectlist[obj.id] |
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
242 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
243 def updateScene(self): |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
244 pass |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
245 |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
246 def _getActorLayer(self): |
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
247 return self._actorlayer |
524
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
523
diff
changeset
|
248 |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
523
diff
changeset
|
249 def _getItemLayer(self): |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
523
diff
changeset
|
250 return self._itemlayer |
516
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
251 |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
252 def _getCameras(self): |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
253 return self._cameras |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
254 |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
255 def _getPlayer(self): |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
256 return self._player |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
257 |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
519
diff
changeset
|
258 def _getObjectList(self): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
519
diff
changeset
|
259 return self._objectlist |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
519
diff
changeset
|
260 |
523
d01eb65b2726
Enabling the FloatingTextRenderer for the RPG demo. The NPC now complains at you if he doesn't have a quest to give you.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
521
diff
changeset
|
261 def _getMap(self): |
d01eb65b2726
Enabling the FloatingTextRenderer for the RPG demo. The NPC now complains at you if he doesn't have a quest to give you.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
521
diff
changeset
|
262 return self._map |
d01eb65b2726
Enabling the FloatingTextRenderer for the RPG demo. The NPC now complains at you if he doesn't have a quest to give you.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
521
diff
changeset
|
263 |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
264 actorlayer = property(_getActorLayer) |
524
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
523
diff
changeset
|
265 itemlayer = property(_getItemLayer) |
516
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
266 cameras = property(_getCameras) |
d70fc46c8aa5
Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
267 player = property(_getPlayer) |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
519
diff
changeset
|
268 objectlist = property(_getObjectList) |
523
d01eb65b2726
Enabling the FloatingTextRenderer for the RPG demo. The NPC now complains at you if he doesn't have a quest to give you.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
521
diff
changeset
|
269 map = property(_getMap) |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
270 |