comparison src/parpg/behaviours/base.py @ 73:58661f5b2f6b

Removed layer as attribute of BaseBehaviour and added it as a parameter to the attachToLayer method.
author KarstenBock@gmx.net
date Wed, 07 Sep 2011 13:54:02 +0200
parents ad75fa042b99
children c3350fc9cd45
comparison
equal deleted inserted replaced
72:9aebbf4e02f7 73:58661f5b2f6b
17 17
18 _AGENT_STATE_NONE, _AGENT_STATE_IDLE, _AGENT_STATE_APPROACH, _AGENT_STATE_RUN, _AGENT_STATE_WANDER, _AGENT_STATE_TALK = xrange(6) 18 _AGENT_STATE_NONE, _AGENT_STATE_IDLE, _AGENT_STATE_APPROACH, _AGENT_STATE_RUN, _AGENT_STATE_WANDER, _AGENT_STATE_TALK = xrange(6)
19 19
20 class BaseBehaviour (fife.InstanceActionListener): 20 class BaseBehaviour (fife.InstanceActionListener):
21 """Fife agent listener""" 21 """Fife agent listener"""
22 def __init__(self, layer=None): 22 def __init__(self):
23 fife.InstanceActionListener.__init__(self) 23 fife.InstanceActionListener.__init__(self)
24 self.layer = layer
25 self.agent = None 24 self.agent = None
26 self.state = None 25 self.state = None
27 self.speed = 0 26 self.speed = 0
28 self.idle_counter = 1 27 self.idle_counter = 1
29 28
30 def attachToLayer(self, agent_ID): 29 def attachToLayer(self, agent_ID, layer):
31 """Attaches to a certain layer 30 """Attaches to a certain layer
32 @type agent_ID: String 31 @type agent_ID: String
33 @param agent_ID: ID of the layer to attach to. 32 @param agent_ID: ID of the layer to attach to.
33 @type layer: Fife layer
34 @param layer: Layer of the agent to attach the behaviour to
34 @return: None""" 35 @return: None"""
35 self.agent = self.layer.getInstance(agent_ID) 36 self.agent = layer.getInstance(agent_ID)
36 self.agent.addActionListener(self) 37 self.agent.addActionListener(self)
37 self.state = _AGENT_STATE_NONE 38 self.state = _AGENT_STATE_NONE
38 39
39 def getX(self): 40 def getX(self):
40 """Get the NPC's x position on the map. 41 """Get the NPC's x position on the map.