Mercurial > parpg-source
annotate behaviours/player.py @ 34:12071706020f
Fixed error in setting the initial state of the NPC behaviour
author | KarstenBock@gmx.net |
---|---|
date | Mon, 05 Sep 2011 14:14:42 +0200 |
parents | ec5a55266f6a |
children | bf506f739322 |
rev | line source |
---|---|
30
ec5a55266f6a
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. |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
2 |
ec5a55266f6a
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 |
ec5a55266f6a
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 |
ec5a55266f6a
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 |
ec5a55266f6a
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. |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
7 |
ec5a55266f6a
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, |
ec5a55266f6a
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 |
ec5a55266f6a
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 |
ec5a55266f6a
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. |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
12 |
ec5a55266f6a
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 |
ec5a55266f6a
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/>. |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
15 |
34
12071706020f
Fixed error in setting the initial state of the NPC behaviour
KarstenBock@gmx.net
parents:
30
diff
changeset
|
16 import base |
12071706020f
Fixed error in setting the initial state of the NPC behaviour
KarstenBock@gmx.net
parents:
30
diff
changeset
|
17 from base import BaseBehaviour |
30
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
18 |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
19 class PlayerBehaviour (BaseBehaviour): |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
20 def __init__(self, parent=None, layer=None): |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
21 super(PlayerBehaviour, self).__init__(layer) |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
22 self.parent = parent |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
23 self.idle_counter = 1 |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
24 self.speed = 0 |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
25 self.nextAction = None |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
26 self.agent = None |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
27 |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
28 def onInstanceActionFinished(self, instance, action): |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
29 """@type instance: ??? |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
30 @param instance: ??? |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
31 @type action: ??? |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
32 @param action: ??? |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
33 @return: None""" |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
34 # First we reset the next behavior |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
35 act = self.nextAction |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
36 self.nextAction = None |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
37 self.idle() |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
38 |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
39 if act: |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
40 act.execute() |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
41 |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
42 if(action.getId() != 'stand'): |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
43 self.idle_counter = 1 |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
44 else: |
ec5a55266f6a
Moved behaviours from objects/actors.py to files seperate files inside a behaviours directory.
KarstenBock@gmx.net
parents:
diff
changeset
|
45 self.idle_counter += 1 |