annotate src/parpg/behaviours/player.py @ 58:d5491eb9e3e4

Set default value of layer parameter of BaseBehaviour to None
author KarstenBock@gmx.net
date Mon, 05 Sep 2011 14:09:04 +0200
parents 4311a0a5378c
children 2915dbb60940
rev   line source
55
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
1 # This file is part of PARPG.
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
2
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
3 # PARPG is free software: you can redistribute it and/or modify
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
4 # it under the terms of the GNU General Public License as published by
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
5 # the Free Software Foundation, either version 3 of the License, or
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
6 # (at your option) any later version.
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
7
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
8 # PARPG is distributed in the hope that it will be useful,
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
11 # GNU General Public License for more details.
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
12
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
13 # You should have received a copy of the GNU General Public License
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>.
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
15
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
16 from base import *
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
17
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
18 class PlayerBehaviour (BaseBehaviour):
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
19 def __init__(self, parent=None, layer=None):
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
20 super(PlayerBehaviour, self).__init__(layer)
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
21 self.parent = parent
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
22 self.idle_counter = 1
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
23 self.speed = 0
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
24 self.nextAction = None
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
25 self.agent = None
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
26
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
27 def onInstanceActionFinished(self, instance, action):
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
28 """@type instance: ???
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
29 @param instance: ???
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
30 @type action: ???
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
31 @param action: ???
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
32 @return: None"""
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
33 # First we reset the next behavior
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
34 act = self.nextAction
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
35 self.nextAction = None
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
36 self.idle()
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
37
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
38 if act:
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
39 act.execute()
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
40
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
41 if(action.getId() != 'stand'):
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
42 self.idle_counter = 1
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
43 else:
4311a0a5378c Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff changeset
44 self.idle_counter += 1