Mercurial > fife-parpg
diff demos/rpg/scripts/objects/baseobject.py @ 560:69d50e751c9a
Lots of changes.
- Added the Serializer class
- Made exceptions a little more usable
- Added actor attributes (not used yet but will be with the combat engine)
- Made the quest dialogs more customizable
- Many other small changes
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 23 Jun 2010 19:20:24 +0000 |
parents | 718e154a43c8 |
children | f85762e634c5 |
line wrap: on
line diff
--- a/demos/rpg/scripts/objects/baseobject.py Tue Jun 22 15:41:36 2010 +0000 +++ b/demos/rpg/scripts/objects/baseobject.py Wed Jun 23 19:20:24 2010 +0000 @@ -22,13 +22,15 @@ # Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # #################################################################### -# This is the rio de hola client for FIFE. import sys, os, re, math, random, shutil from fife import fife from fife.extensions.loaders import loadMapFile +from scripts.misc.exceptions import * +from scripts.misc.serializer import Serializer + GameObjectTypes = { "DEFAULT": 0, "ITEM":1, @@ -66,7 +68,7 @@ pass -class BaseGameObject(object): +class BaseGameObject(Serializer): def __init__(self, gamecontroller, layer, typename, baseobjectname, instancename, instanceid=None, createInstance=False): """ @param gamecontroller: A reference to the master game controller @@ -129,9 +131,12 @@ #This doesnt work #self._instance.get2dGfxVisual().setVisible(True) - self._position.x = x - self._position.y = y - self._createFIFEInstance(self, self._layer) + if self._instance: + self._setMapPostion(x,y) + else: + self._position.x = x + self._position.y = y + self._createFIFEInstance(self, self._layer) self._activated = True @@ -155,7 +160,10 @@ return lvars - def deserialize(self, valuedict): + def deserialize(self, valuedict=None): + if not valuedict: + return + if valuedict.has_key("posx"): x = float(valuedict['posx']) else: @@ -179,14 +187,16 @@ fife.InstanceVisual.create(self._instance) self._instance.thisown = 0 - + def _findFIFEInstance(self, layer): """ - @todo: throw InstanceNotFoundError + Throws InstanceNotFound if the instance was not found on the specified layer. """ self._instance = self._layer.getInstance(self._id) if self._instance: - self._instance.thisown = 0 + self._instance.thisown = 0 + else: + raise InstanceNotFoundError(self._id + " was not found on the layer!") def _getLocation(self): return self._instance.getLocation()