Mercurial > fife-parpg
annotate demos/rpg/scripts/objects/baseobject.py @ 530:ea26e7b6f56c
Added the loadActor and loadItem functions so you can load single items at any time.
Cleaned up the base object a bit so you can modify it's position easily.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 28 May 2010 20:10:33 +0000 |
parents | d0bce896a526 |
children | 2e739ae9a8bc |
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, |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
518
diff
changeset
|
38 "ENEMY":5 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
518
diff
changeset
|
39 } |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
518
diff
changeset
|
40 |
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
|
41 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
|
42 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
|
43 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
|
44 obj.instance.addActionListener(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
|
45 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
|
46 self._object = 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
|
47 |
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
|
48 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
|
49 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
|
50 |
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
|
51 |
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
|
52 class BaseGameObject(object): |
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 def __init__(self, gamecontroller, instancename, instanceid=None, createInstance=False): |
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 """ |
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 @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
|
56 @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
|
57 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
|
58 @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
|
59 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
|
60 @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
|
61 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
|
62 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
|
63 """ |
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 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
|
65 self._fifeobject = None |
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 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
|
67 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
|
68 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
|
69 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
|
70 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
|
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 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
|
73 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
|
74 |
524
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
75 if not hasattr(self, "_type"): |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
76 self._type = GameObjectTypes["DEFAULT"] |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
77 |
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
|
78 if createInstance: |
524
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
79 if self._type == GameObjectTypes["ITEM"]: |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
80 layer = self._gamecontroller.scene.itemlayer |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
81 else: |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
82 layer = self._gamecontroller.scene.actorlayer |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
83 |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
84 self._createFIFEInstance(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
|
85 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
|
86 self._instance = self._gamecontroller.scene.actorlayer.getInstance(self._id) |
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._instance.thisown = 0 |
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 |
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
|
89 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
|
90 |
524
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
91 |
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
|
92 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
|
93 """ |
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
|
94 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
|
95 """ |
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
|
96 if self._instance : |
524
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
97 if self._type == GameObjectTypes["ITEM"]: |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
98 layer = self._gamecontroller.scene.itemlayer |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
99 else: |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
100 layer = self._gamecontroller.scene.actorlayer |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
101 |
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
102 layer.deleteInstance(self._instance) |
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
|
103 self._instance = None |
518
e4cd18a179af
Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
517
diff
changeset
|
104 |
e4cd18a179af
Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
517
diff
changeset
|
105 def setMapPosition(self, x, y): |
e4cd18a179af
Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
517
diff
changeset
|
106 curloc = self.location |
e4cd18a179af
Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
517
diff
changeset
|
107 |
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 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
|
109 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
|
110 self._position.y = y |
518
e4cd18a179af
Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
517
diff
changeset
|
111 |
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
|
112 curloc.setExactLayerCoordinates(self._position) |
518
e4cd18a179af
Added the PlayerActionListener.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
517
diff
changeset
|
113 self.location = curloc |
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
|
114 |
524
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
115 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
|
116 """ |
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
|
117 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
|
118 """ |
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
|
119 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
|
120 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
|
121 |
524
6037f79b0dcf
Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
520
diff
changeset
|
122 self._instance = layer.createInstance(self._fifeobject, fife.ModelCoordinate(0,0), 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
|
123 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
|
124 |
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
|
125 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
|
126 |
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
|
127 self.setMapPosition(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
|
128 |
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
|
129 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
|
130 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
|
131 |
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
|
132 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
|
133 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
|
134 |
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
|
135 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
|
136 return self._instance |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
518
diff
changeset
|
137 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
518
diff
changeset
|
138 def _getType(self): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
518
diff
changeset
|
139 return self._type |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
518
diff
changeset
|
140 |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
141 def _getId(self): |
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
142 return self._id |
529
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
143 |
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
144 def _getModelName(self): |
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
145 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
|
146 |
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
|
147 def _getPosition(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
|
148 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
|
149 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
|
150 |
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
|
151 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
|
152 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
|
153 |
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
|
154 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
|
155 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
|
156 |
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
|
157 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
|
158 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
|
159 |
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 |
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
|
161 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
|
162 instance = property(_getInstance) |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
518
diff
changeset
|
163 type = property(_getType) |
528
796d49ab9380
Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
164 id = property(_getId) |
529
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
528
diff
changeset
|
165 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
|
166 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
|
167 activated = property(_getActivated, _setActivated) |