annotate demos/rpg/scripts/objects/baseobject.py @ 552:718e154a43c8

When you click on an object behind the player the click is no longer ignored. Fixed a bug where the players next action was performed even though the user clicked somewhere else on the map.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 16 Jun 2010 16:07:20 +0000
parents e59ece21ab3e
children 69d50e751c9a
rev   line source
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 #!/usr/bin/env python
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 # -*- coding: utf-8 -*-
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 # ####################################################################
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 # Copyright (C) 2005-2010 by the FIFE team
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 # http://www.fifengine.net
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 # This file is part of FIFE.
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 #
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 # FIFE is free software; you can redistribute it and/or
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 # modify it under the terms of the GNU Lesser General Public
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 # License as published by the Free Software Foundation; either
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 # version 2.1 of the License, or (at your option) any later version.
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 #
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 # This library is distributed in the hope that it will be useful,
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 # Lesser General Public License for more details.
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 #
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 # You should have received a copy of the GNU Lesser General Public
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21 # License along with this library; if not, write to the
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 # Free Software Foundation, Inc.,
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 # ####################################################################
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 # This is the rio de hola client for FIFE.
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 import sys, os, re, math, random, shutil
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 from fife import fife
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 from fife.extensions.loaders import loadMapFile
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31
520
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
32 GameObjectTypes = {
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
33 "DEFAULT": 0,
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
34 "ITEM":1,
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
35 "QUESTGIVER":2,
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
36 "PLAYER":3,
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
37 "NPC":4,
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
38 "ENEMY":5,
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
39 "GOLD":6,
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
40 "PORTAL":7
520
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
41 }
543
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
42
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
43 def getModuleByType(objtype):
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
44 if objtype == GameObjectTypes["ITEM"] or objtype == GameObjectTypes["GOLD"] or objtype == GameObjectTypes["PORTAL"]:
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
45 module = "items"
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
46 elif objtype == GameObjectTypes["QUESTGIVER"] or objtype == GameObjectTypes["ENEMY"]:
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
47 module = "npcs"
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
48 else:
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
49 module = "unknown"
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
50
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
51 return module
520
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
52
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 class ObjectActionListener(fife.InstanceActionListener):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 def __init__(self, gamecontroller, obj):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 fife.InstanceActionListener.__init__(self)
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 self._gamecontroller = gamecontroller
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 self._object = obj
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
58
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
59 def detachActionListener(self):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
60 self._object.instance.removeActionListener(self)
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
61
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
62 def attachActionListener(self):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
63 self._object.instance.addActionListener(self)
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 def onInstanceActionFinished(self, instance, action):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 pass
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 class BaseGameObject(object):
546
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
70 def __init__(self, gamecontroller, layer, typename, baseobjectname, instancename, instanceid=None, createInstance=False):
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 """
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 @param gamecontroller: A reference to the master game controller
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 @param instancename: The name of the object to load. The object's XML file must
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 be part of the map file or added with fife.extensions.loaders.loadImportFile
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 @param instanceid: used if you want to give a specific ID to the instance to
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 differenciate it from other instances
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 @param createInstance: If this is True it will attempt to be loaded from disk and not
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 use one that has already been loaded from the map file. See the note about the
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 instancename paramater above.
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 """
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 self._gamecontroller = gamecontroller
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 self._fifeobject = None
543
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
83
546
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
84 self._typename = typename
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
85 self._baseobjectname = baseobjectname
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
86
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 self._name = instancename
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 if instanceid:
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 self._id = instanceid
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90 else:
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 self._id = self._name
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 self._instance = 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
94 self._position = fife.DoublePoint(0.0, 0.0)
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
95
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
96 self._actionlistener = None
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
97
543
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
98 self._type = GameObjectTypes["DEFAULT"]
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
99
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
100 self._layer = layer
524
6037f79b0dcf Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 520
diff changeset
101
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102 if createInstance:
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
103 self._createFIFEInstance(self._layer)
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 else:
547
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
105 self._findFIFEInstance(self._layer)
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106
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
107 self._activated = True
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
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 def destroy(self):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 """
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 Deletes the FIFE instance from the actor layer on the map.
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 """
552
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
113
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
114 #This doesnt work
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
115 #self._instance.get2dGfxVisual().setVisible(False)
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
116
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
117 #remove from the scene instead
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
118 if self._actionlistener:
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
119 self._actionlistener.detachActionListener()
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
120 self._actionlistener = None
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
121
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 if self._instance :
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
123 self._layer.deleteInstance(self._instance)
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
124 self._instance = None
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
125
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 530
diff changeset
126 self._activated = False
552
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
127
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
128 def spawn(self, x, y):
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
129 #This doesnt work
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
130 #self._instance.get2dGfxVisual().setVisible(True)
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
131
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
132 self._position.x = x
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
133 self._position.y = y
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
134 self._createFIFEInstance(self, self._layer)
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
135
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
136 self._activated = True
518
e4cd18a179af Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
137
e4cd18a179af Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
138 def setMapPosition(self, x, y):
e4cd18a179af Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
139 curloc = self.location
e4cd18a179af Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
140
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
141 self._position = self.location.getExactLayerCoordinates()
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
142 self._position.x = x
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
143 self._position.y = y
518
e4cd18a179af Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
144
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
145 curloc.setExactLayerCoordinates(self._position)
518
e4cd18a179af Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
146 self.location = curloc
543
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
147
546
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
148 def serialize(self):
543
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
149 lvars = {}
546
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
150 (x,y) = self.position
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
151 lvars['posx'] = x
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
152 lvars['posy'] = y
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
153 lvars['type'] = self._typename
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
154 lvars['objectname'] = self._baseobjectname
543
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
155
546
8fee2d2286e9 Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 543
diff changeset
156 return lvars
543
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
157
547
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
158 def deserialize(self, valuedict):
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
159 if valuedict.has_key("posx"):
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
160 x = float(valuedict['posx'])
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
161 else:
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
162 x = 0
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
163
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
164 if valuedict.has_key("posy"):
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
165 y = float(valuedict['posy'])
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
166 else:
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
167 y = 0
543
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
168
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
169 self.setMapPosition(x,y)
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170
524
6037f79b0dcf Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 520
diff changeset
171 def _createFIFEInstance(self, layer):
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 """
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173 Should not be called directly. Use the constructor!
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 """
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 mapmodel = self._gamecontroller.engine.getModel()
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 self._fifeobject = mapmodel.getObject(self._name, self._gamecontroller.settings.get("RPG", "ObjectNamespace", "http://www.fifengine.de/xml/rpg"))
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177
552
718e154a43c8 When you click on an object behind the player the click is no longer ignored.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
178 self._instance = layer.createInstance(self._fifeobject, fife.ExactModelCoordinate(self._position.x,self._position.y), self._id)
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179 fife.InstanceVisual.create(self._instance)
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
180
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181 self._instance.thisown = 0
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
182
543
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
183 def _findFIFEInstance(self, layer):
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
184 """
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
185 @todo: throw InstanceNotFoundError
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
186 """
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
187 self._instance = self._layer.getInstance(self._id)
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
188 if self._instance:
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
189 self._instance.thisown = 0
cb7ec12214a9 Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 540
diff changeset
190
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191 def _getLocation(self):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 return self._instance.getLocation()
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 def _setLocation(self, loc):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
195 self._instance.setLocation(loc)
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 def _getInstance(self):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 return self._instance
520
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
199
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
200 def _getType(self):
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
201 return self._type
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
202
528
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
203 def _getId(self):
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
204 return self._id
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
205
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
206 def _getModelName(self):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
207 return self._name
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
208
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
209 def _getPosition(self):
547
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
210 #if there isn't a FIFE instance just return last known coordinates
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
211 if self._instance:
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
212 self._position = self.location.getExactLayerCoordinates()
e59ece21ab3e Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 546
diff changeset
213
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
214 return (self._position.x, self._position.y)
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
215
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
216 def _setPosition(self, tuplexy):
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
217 self.setMapPosition(tuplexy[0],tuplexy[1])
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
218
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
219 def _getActivated(self):
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
220 return self._activated
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
221
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
222 def _setActivated(self, activate):
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
223 self._activated = activate
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
224
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
225
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226 location = property(_getLocation, _setLocation)
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
227 instance = property(_getInstance)
520
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 518
diff changeset
228 type = property(_getType)
528
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
229 id = property(_getId)
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
230 modelname = property(_getModelName)
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
231 position = property(_getPosition, _setPosition)
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
232 activated = property(_getActivated, _setActivated)