Mercurial > fife-parpg
comparison demos/rio_de_hola/scripts/agents/girl.py @ 499:3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
All demos and tools now use the new settings extension.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 14 May 2010 17:37:42 +0000 |
parents | 987307d12235 |
children |
comparison
equal
deleted
inserted
replaced
498:5ff83f209333 | 499:3dff106b945b |
---|---|
23 | 23 |
24 from agent import Agent | 24 from agent import Agent |
25 from fife import fife | 25 from fife import fife |
26 from fife.extensions.fife_settings import Setting | 26 from fife.extensions.fife_settings import Setting |
27 | 27 |
28 TDS = Setting(app_name="rio_de_hola") | 28 #TDS = Setting(app_name="rio_de_hola") |
29 | 29 |
30 _STATE_NONE, _STATE_IDLE, _STATE_RUN, _STATE_FOLLOW = 0, 1, 2, 3 | 30 _STATE_NONE, _STATE_IDLE, _STATE_RUN, _STATE_FOLLOW = 0, 1, 2, 3 |
31 | 31 |
32 GIRL_SPEED = 3 * float(TDS.readSetting("TestAgentSpeed")) | |
33 class Girl(Agent): | 32 class Girl(Agent): |
34 def __init__(self, model, agentName, layer, uniqInMap=True): | 33 def __init__(self, settings, model, agentName, layer, uniqInMap=True): |
35 super(Girl, self).__init__(model, agentName, layer, uniqInMap) | 34 super(Girl, self).__init__(settings, model, agentName, layer, uniqInMap) |
36 self.state = _STATE_NONE | 35 self.state = _STATE_NONE |
37 self.waypoints = ((67, 80), (75, 44)) | 36 self.waypoints = ((67, 80), (75, 44)) |
38 self.waypoint_counter = 0 | 37 self.waypoint_counter = 0 |
39 self.hero = self.layer.getInstance('PC') | 38 self.hero = self.layer.getInstance('PC') |
39 | |
40 self.GIRL_SPEED = 3 * float(self.settings.get("rio", "TestAgentSpeed")) | |
40 | 41 |
41 def onInstanceActionFinished(self, instance, action): | 42 def onInstanceActionFinished(self, instance, action): |
42 if self.state in (_STATE_RUN, _STATE_FOLLOW): | 43 if self.state in (_STATE_RUN, _STATE_FOLLOW): |
43 self.idle() | 44 self.idle() |
44 else: | 45 else: |
61 self.state = _STATE_IDLE | 62 self.state = _STATE_IDLE |
62 self.agent.act('stand', self.agent.getFacingLocation(), False) | 63 self.agent.act('stand', self.agent.getFacingLocation(), False) |
63 | 64 |
64 def follow_hero(self): | 65 def follow_hero(self): |
65 self.state = _STATE_FOLLOW | 66 self.state = _STATE_FOLLOW |
66 self.agent.follow('run', self.hero, GIRL_SPEED) | 67 self.agent.follow('run', self.hero, self.GIRL_SPEED) |
67 | 68 |
68 def run(self, location): | 69 def run(self, location): |
69 self.state = _STATE_RUN | 70 self.state = _STATE_RUN |
70 self.agent.move('run', location, GIRL_SPEED) | 71 self.agent.move('run', location, self.GIRL_SPEED) |