comparison clients/rio_de_hola/scripts/agents/hero.py @ 98:214e3eb81eb2

better structure for techdemo scripts + svn:ignore fixes
author jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 21 Jul 2008 13:46:15 +0000
parents clients/rio_de_hola/scripts/hero.py@4a0efb7baf70
children ae3b8139c7c7
comparison
equal deleted inserted replaced
97:346738d09188 98:214e3eb81eb2
1 import random
2 from agent import Agent
3 import settings as TDS
4
5 _STATE_NONE, _STATE_IDLE, _STATE_RUN, _STATE_KICK, _STATE_TALK = xrange(5)
6
7 class Hero(Agent):
8 def __init__(self, model, agentName, layer, uniqInMap=True):
9 super(Hero, self).__init__(model, agentName, layer, uniqInMap)
10 self.state = _STATE_NONE
11 self.idlecounter = 1
12
13 def onInstanceActionFinished(self, instance, action):
14 self.idle()
15 if action.getId() != 'stand':
16 self.idlecounter = 1
17 else:
18 self.idlecounter += 1
19 if self.idlecounter % 7 == 0:
20 txtindex = random.randint(0, len(TDS.heroTexts) - 1)
21 instance.say(TDS.heroTexts[txtindex], 2500)
22
23 def start(self):
24 self.idle()
25
26 def idle(self):
27 self.state = _STATE_IDLE
28 self.agent.act('stand', self.agent.getFacingLocation())
29
30 def run(self, location):
31 self.state = _STATE_RUN
32 self.agent.move('run', location, 4 * TDS.TestAgentSpeed)
33
34 def kick(self, target):
35 self.state = _STATE_KICK
36 self.agent.act('kick', target)
37
38 def talk(self, target):
39 self.state = _STATE_TALK
40 self.agent.act('talk', target)