diff demos/rpg/scripts/actors/baseactor.py @ 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.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 02 Jun 2010 21:43:03 +0000
parents 2e739ae9a8bc
children 8fee2d2286e9
line wrap: on
line diff
--- a/demos/rpg/scripts/actors/baseactor.py	Tue Jun 01 21:38:14 2010 +0000
+++ b/demos/rpg/scripts/actors/baseactor.py	Wed Jun 02 21:43:03 2010 +0000
@@ -30,6 +30,7 @@
 from fife.extensions.loaders import loadMapFile
 
 from scripts.objects.baseobject import ObjectActionListener, BaseGameObject, GameObjectTypes
+from scripts.objects.items import GoldStack
 
 Actions = {'NONE':0,
 		   'PICKUP':1,
@@ -95,8 +96,10 @@
 			self._object.performNextAction()
 
 class Actor(BaseGameObject):
-	def __init__(self, gamecontroller, actortype, instancename, instanceid=None, createInstance=False):
-		super(Actor, self).__init__(gamecontroller, actortype, instancename, instanceid, createInstance)
+	def __init__(self, gamecontroller, layer, typename, instancename, instanceid=None, createInstance=False):
+		super(Actor, self).__init__(gamecontroller, layer, typename, instancename, instanceid, createInstance)
+
+		self._type = GameObjectTypes["DEFAULT"]
 
 		self._walkspeed = self._gamecontroller.settings.get("RPG", "DefaultActorWalkSpeed", 4.0)
 		
@@ -128,12 +131,12 @@
 		if len(self._inventory) >= self._maxinventoryitems:
 			return
 		else:
-			if item.modelname == "goldstack":
+			if type(item) == GoldStack:
 				self._gold += item.value
 			else:
 				self._inventory.append(item)
 		
-			item.onLeftClick()
+			item.onPickUp()
 			
 	def enterPortal(self, portal):
 		if self._id == "player":